broke for a sec, back to working
fyi `dotnet restore` will say "no need :)", so you have to delete bin/ and obj/ when you need to dotnet restore
This commit is contained in:
parent
cc5efacccc
commit
47de14dca9
@ -14,6 +14,8 @@ namespace director
|
||||
public string calendar_twitch { get; set; }
|
||||
public string calendar_other { get; set; }
|
||||
public TimeSpan preshowBufferTime { get; set; }
|
||||
public string show_template_yt_release { get; set; }
|
||||
public string show_template_twitch_streams { get; set; }
|
||||
public Dictionary<string, string> phase_handlers { get; set; }
|
||||
}
|
||||
}
|
44
Program.cs
44
Program.cs
@ -93,13 +93,20 @@ namespace director
|
||||
}
|
||||
}
|
||||
Console.WriteLine("calendars checked");
|
||||
#if(DEBUG)
|
||||
#if (DEBUG)
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
var psuedo = new Schedulable.Schedulable();
|
||||
psuedo.Showtime = DateTime.Now + TimeSpan.FromSeconds(30);
|
||||
var partiallyCopiable = scratch.agenda?.FirstOrDefault(s => s.ScedulableType == Schedulable.ScedulableType.YTRelease);
|
||||
psuedo.Occurrence = partiallyCopiable.Occurrence;
|
||||
psuedo.Occurrence.OccurrenceStart = psuedo.Showtime;
|
||||
psuedo.Occurrence.OccurrenceEnd = psuedo.Showtime;
|
||||
psuedo.ScedulableType = Schedulable.ScedulableType.YTRelease;
|
||||
workQueue.Enqueue(psuedo);
|
||||
_signal.Set();
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
private delegate void schedulableCreate(ref Schedulable.Schedulable creating);
|
||||
@ -136,7 +143,7 @@ namespace director
|
||||
|
||||
var napLength = (todo.Showtime - conf.preshowBufferTime) - DateTime.Now;
|
||||
Console.WriteLine($"threadwork consumes! showtime at {todo.Showtime}; napping until {todo.Showtime - conf.preshowBufferTime} ({napLength})");
|
||||
switch(todo.ScedulableType)
|
||||
switch (todo.ScedulableType)
|
||||
{
|
||||
case Schedulable.ScedulableType.TwitchStream:
|
||||
Console.WriteLine("it's a twitch stream");
|
||||
@ -145,38 +152,31 @@ namespace director
|
||||
Console.WriteLine("it's a yt release");
|
||||
break;
|
||||
}
|
||||
if(napLength.TotalMinutes > 0)
|
||||
if (napLength.TotalMinutes > 0)
|
||||
{
|
||||
Task.WaitAll(Task.Delay(napLength));
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
switch (todo.ScedulableType)
|
||||
{
|
||||
case Schedulable.ScedulableType.TwitchStream:
|
||||
try
|
||||
{
|
||||
TwitchStreamHandler.Handle(todo.Occurrence);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
Log.Panic($"error in twitch stream handler! Panicking!\n{JsonConvert.SerializeObject(e)}");
|
||||
}
|
||||
new TwitchStreamHandler().Handle(todo.Occurrence);
|
||||
break;
|
||||
case Schedulable.ScedulableType.YTRelease:
|
||||
try
|
||||
{
|
||||
YoutubeHandler.Handle(todo.Occurrence);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
Log.Panic($"error in youtube release handler! Panicking!\n{JsonConvert.SerializeObject(e)}");
|
||||
}
|
||||
new YoutubeHandler().Handle(todo.Occurrence);
|
||||
break;
|
||||
default:
|
||||
Log.Panic($"unknown schedulable type! abandoning!");
|
||||
break;
|
||||
throw new NotImplementedException($"unknown schedulable type!\n{JsonConvert.SerializeObject(todo)}");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Panic($"error in show handler! Panicking!\n{JsonConvert.SerializeObject(e)}");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,5 +7,7 @@
|
||||
"calendar_youtube": "calendars/1wingedangle/youtube-channel_shared_by_adam",
|
||||
"calendar_twitch": "calendars/1wingedangle/twitch-channel_shared_by_adam",
|
||||
"calendar_other": "calendars/1wingedangle/other_shared_by_adam",
|
||||
"preshowBufferTime": "04:00:00"
|
||||
"preshowBufferTime": "04:00:00",
|
||||
"show_template_yt_release": "./yt release/config.json",
|
||||
"show_template_twitch_streams": "./twitch stream configs/"
|
||||
}
|
@ -7,7 +7,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="silvermeddlists.franz" Version="0.0.2" />
|
||||
<PackageReference Include="silvermeddlists.franz" Version="0.0.4" />
|
||||
<PackageReference Include="WebDav.Client" Version="2.7.0" />
|
||||
<PackageReference Include="Ical.Net" Version="4.2.0" />
|
||||
</ItemGroup>
|
||||
|
37
schedulable/Show.cs
Normal file
37
schedulable/Show.cs
Normal file
@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Schedulable.Show
|
||||
{
|
||||
public class Show
|
||||
{
|
||||
public PreshowTaskList PreShow { get; set; }
|
||||
public TaskList PostShow { get; set; }
|
||||
|
||||
#region components
|
||||
public class TaskList
|
||||
{
|
||||
public IEnumerable<Checklistable> Manual { get; set; }
|
||||
public IEnumerable<string> Commands { get; set; }
|
||||
}
|
||||
public class PreshowTaskList : TaskList
|
||||
{
|
||||
public IEnumerable<string> AgentsNeeded { get; set; }
|
||||
public IEnumerable<string> Checks { get; set; }
|
||||
}
|
||||
public class Checklistable
|
||||
{
|
||||
//for humans
|
||||
public string Label { get; set; }
|
||||
public IEnumerable<Checklistable> Items { get; set; } //if no items, just throw up a checkbox
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
public class TwitchStream : Show
|
||||
{
|
||||
public string TwitchTitle { get; set; }
|
||||
public string TwitchCategory { get; set; }
|
||||
}
|
||||
public class YoutubeRelease : Show { }
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Schedulable.Show
|
||||
{
|
||||
public class Show
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public Preparation Preperation { get; set; }
|
||||
public IEnumerable<Phase> Procedure { get; set; }
|
||||
public TaskList Postshow { get; set; }
|
||||
}
|
||||
public class Phase
|
||||
{
|
||||
public string Name { get; set; }
|
||||
}
|
||||
public class TaskList
|
||||
{
|
||||
public IEnumerable<Checklistable> Manual { get; set; }
|
||||
public IEnumerable<string> Commands { get; set; }
|
||||
}
|
||||
public class Preparation : TaskList
|
||||
{
|
||||
public IEnumerable<string> AgentsNeeded { get; set; }
|
||||
public IEnumerable<string> Checks { get; set; }
|
||||
}
|
||||
public class Checklistable
|
||||
{
|
||||
//for humans
|
||||
public string Label { get; set; }
|
||||
public IEnumerable<Checklistable> Items { get; set; } //if no items, just throw up a checkbox
|
||||
}
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
namespace Schedulable.Show
|
||||
{
|
||||
public class TwitchStream : Show
|
||||
{
|
||||
public string TwitchCategory { get; set; }
|
||||
}
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
namespace Schedulable.Show
|
||||
{
|
||||
public class YoutubeRelease : Show
|
||||
{
|
||||
//do I even need anything?
|
||||
}
|
||||
}
|
10
showHandlers/ShowHandler.cs
Normal file
10
showHandlers/ShowHandler.cs
Normal file
@ -0,0 +1,10 @@
|
||||
using System;
|
||||
using director;
|
||||
|
||||
namespace ShowHandlers
|
||||
{
|
||||
public abstract class ShowHandler
|
||||
{
|
||||
public abstract void Handle(iCalHoopJumping.CalendarOccurrence evt);
|
||||
}
|
||||
}
|
@ -3,9 +3,9 @@ using director;
|
||||
|
||||
namespace ShowHandlers
|
||||
{
|
||||
public class TwitchStreamHandler
|
||||
public class TwitchStreamHandler : ShowHandler
|
||||
{
|
||||
public static void Handle(iCalHoopJumping.CalendarOccurrence evt)
|
||||
public override void Handle(iCalHoopJumping.CalendarOccurrence evt)
|
||||
{
|
||||
Console.WriteLine("I am a twitch stream handler, it falls to me to...");
|
||||
Console.WriteLine(" H A N D L E ");
|
||||
|
@ -1,15 +1,73 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using director;
|
||||
using franz;
|
||||
using Newtonsoft.Json;
|
||||
using Schedulable.Show;
|
||||
|
||||
namespace ShowHandlers
|
||||
{
|
||||
public class YoutubeHandler
|
||||
public class YoutubeHandler : ShowHandler
|
||||
{
|
||||
public static void Handle(iCalHoopJumping.CalendarOccurrence evt)
|
||||
private YoutubeRelease config;
|
||||
private List<string> agentsPresent = new List<string>();
|
||||
private bool essentialChecksPassed = false;
|
||||
private bool allChecksPassed = false;
|
||||
private readonly AutoResetEvent checkSignal = new AutoResetEvent(false);
|
||||
public override void Handle(iCalHoopJumping.CalendarOccurrence evt)
|
||||
{
|
||||
Console.WriteLine("I am a YT handler, it falls to me to...");
|
||||
Console.WriteLine(" H A N D L E ");
|
||||
Console.WriteLine($"current time is {DateTime.Now}");
|
||||
config = JsonConvert.DeserializeObject<YoutubeRelease>(Program.conf.show_template_yt_release);
|
||||
config.PreShow.AgentsNeeded = config.PreShow.AgentsNeeded.Select(s => s.ToLower());
|
||||
Telefranz.Instance.addHandler<silver_messages.global.report>(agentReports);
|
||||
Task.Run(() => PreShow(evt));
|
||||
if(evt.OccurrenceStart > DateTime.Now)
|
||||
{
|
||||
Task.WaitAll(Task.Delay(evt.OccurrenceStart - DateTime.Now));
|
||||
}
|
||||
PostShow(evt);
|
||||
}
|
||||
~YoutubeHandler()
|
||||
{
|
||||
Telefranz.Instance.removeHandler<silver_messages.global.report>(agentReports);
|
||||
}
|
||||
protected void PreShow(iCalHoopJumping.CalendarOccurrence evt)
|
||||
{
|
||||
Console.WriteLine($"it's the pre-show, showtime at: {evt.OccurrenceStart}");
|
||||
agentsPresent.Clear();
|
||||
essentialChecksPassed = false;
|
||||
allChecksPassed = false;
|
||||
Task.WaitAny(
|
||||
Task.Delay(10)
|
||||
);
|
||||
Telefranz.Instance.ProduceMessage(new silver_messages.global.sound_off());
|
||||
while(agentsPresent.Where(ap => !config.PreShow.AgentsNeeded.Contains(ap))?.Count() > 0)
|
||||
{
|
||||
checkSignal.WaitOne(TimeSpan.FromSeconds(45));
|
||||
}
|
||||
// //await sound offs for some timeout
|
||||
// config.PreShow.AgentsNeeded;
|
||||
// //once that's ok, await checks
|
||||
// config.PreShow.Checks;
|
||||
// //once that's ok, await first command, then start running them
|
||||
// config.PreShow.Commands;
|
||||
}
|
||||
protected void agentReports(silver_messages.global.report r)
|
||||
{
|
||||
if(config.PreShow.AgentsNeeded?.FirstOrDefault(an => an.ToLower() == r.name.ToLower()) != null)
|
||||
{
|
||||
lock(agentsPresent)
|
||||
{
|
||||
agentsPresent.Add(r.name.ToLower());
|
||||
checkSignal.Set();
|
||||
}
|
||||
}
|
||||
}
|
||||
protected void PostShow(iCalHoopJumping.CalendarOccurrence evt)
|
||||
{
|
||||
Console.WriteLine("can't do this bit without understanding when a show ends, sooo.");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user