yt handler checks just need to be issued, and events unsubscribed
This commit is contained in:
parent
ac3b998da9
commit
5fc0359e04
@ -41,14 +41,18 @@ namespace Director
|
|||||||
{
|
{
|
||||||
Console.WriteLine($"[{DateTime.Now.ToLongTimeString()}] [{logLevel.ToString()}] {message}");
|
Console.WriteLine($"[{DateTime.Now.ToLongTimeString()}] [{logLevel.ToString()}] {message}");
|
||||||
|
|
||||||
var httpWebRequest = (HttpWebRequest)WebRequest.Create(call_for_humans_discord_webhook);
|
//if(logLevel >= LogLevel.Warning && false)
|
||||||
httpWebRequest.ContentType = "application/json";
|
if(false) //TODO: re-enable
|
||||||
httpWebRequest.Method = "POST";
|
|
||||||
using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
|
|
||||||
{
|
{
|
||||||
streamWriter.Write($"{{\"content\":\"[{DateTime.Now.ToLongTimeString()}] [{logLevel.ToString()}] {message}\"}}");
|
var httpWebRequest = (HttpWebRequest)WebRequest.Create(call_for_humans_discord_webhook);
|
||||||
|
httpWebRequest.ContentType = "application/json";
|
||||||
|
httpWebRequest.Method = "POST";
|
||||||
|
using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
|
||||||
|
{
|
||||||
|
streamWriter.Write($"{{\"content\":\"[{DateTime.Now.ToLongTimeString()}] [{logLevel.ToString()}] {message}\"}}");
|
||||||
|
}
|
||||||
|
httpWebRequest.GetResponse();
|
||||||
}
|
}
|
||||||
httpWebRequest.GetResponse();
|
|
||||||
}
|
}
|
||||||
public enum LogLevel { Trace, Verbose, Info, Warning, Error, Showstopper }
|
public enum LogLevel { Trace, Verbose, Info, Warning, Error, Showstopper }
|
||||||
}
|
}
|
||||||
|
@ -29,9 +29,12 @@ namespace Schedulable.Show
|
|||||||
{
|
{
|
||||||
public string cmd { get; set; }
|
public string cmd { get; set; }
|
||||||
public string args { get; set; }
|
public string args { get; set; }
|
||||||
|
public TimeSpan leadTime { get; set; }
|
||||||
}
|
}
|
||||||
public class CommandLineCheck : CommandLine
|
public class CommandLineCheck
|
||||||
{
|
{
|
||||||
|
public string cmd { get; set; }
|
||||||
|
public string args { get; set; }
|
||||||
public string target { get; set; }
|
public string target { get; set; }
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -5,7 +5,6 @@ namespace ShowHandlers
|
|||||||
{
|
{
|
||||||
public abstract class ShowHandler
|
public abstract class ShowHandler
|
||||||
{
|
{
|
||||||
protected abstract TimeSpan AgentsRespondingBuffer { get; }
|
|
||||||
public abstract void Handle(iCalHoopJumping.CalendarOccurrence evt);
|
public abstract void Handle(iCalHoopJumping.CalendarOccurrence evt);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -5,7 +5,6 @@ namespace ShowHandlers
|
|||||||
{
|
{
|
||||||
public class TwitchStreamHandler : ShowHandler
|
public class TwitchStreamHandler : ShowHandler
|
||||||
{
|
{
|
||||||
protected override TimeSpan AgentsRespondingBuffer { get { return TimeSpan.FromHours(1); } }
|
|
||||||
public override 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("I am a twitch stream handler, it falls to me to...");
|
||||||
|
@ -19,15 +19,12 @@ namespace ShowHandlers
|
|||||||
private Dictionary<string, bool> checksProgress = new Dictionary<string, bool>();
|
private Dictionary<string, bool> checksProgress = new Dictionary<string, bool>();
|
||||||
private readonly AutoResetEvent checkSignal = new AutoResetEvent(false);
|
private readonly AutoResetEvent checkSignal = new AutoResetEvent(false);
|
||||||
|
|
||||||
protected override TimeSpan AgentsRespondingBuffer { get { return TimeSpan.FromHours(1); } }
|
|
||||||
|
|
||||||
public override void Handle(iCalHoopJumping.CalendarOccurrence evt)
|
public override void Handle(iCalHoopJumping.CalendarOccurrence evt)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"begin youtube handler. current time {DateTime.Now.ToLongTimeString()}");
|
Console.WriteLine($"begin youtube handler. current time {DateTime.Now.ToLongTimeString()}");
|
||||||
Console.WriteLine(JsonConvert.SerializeObject(evt));
|
Console.WriteLine(JsonConvert.SerializeObject(evt));
|
||||||
var ytConfig = File.ReadAllText(Program.conf.show_template_yt_release);
|
var ytConfig = File.ReadAllText(Program.conf.show_template_yt_release);
|
||||||
config = JsonConvert.DeserializeObject<YoutubeRelease>(ytConfig);
|
config = JsonConvert.DeserializeObject<YoutubeRelease>(ytConfig);
|
||||||
config.PreShow.AgentsNeeded = config.PreShow.AgentsNeeded.Select(s => s.ToLower()).ToList();
|
|
||||||
Task.Run(() => PreShow(evt));
|
Task.Run(() => PreShow(evt));
|
||||||
Console.WriteLine("kicked off the pre-show");
|
Console.WriteLine("kicked off the pre-show");
|
||||||
if (evt.OccurrenceStart > DateTime.Now)
|
if (evt.OccurrenceStart > DateTime.Now)
|
||||||
@ -44,12 +41,21 @@ namespace ShowHandlers
|
|||||||
protected void PreShow(iCalHoopJumping.CalendarOccurrence evt)
|
protected void PreShow(iCalHoopJumping.CalendarOccurrence evt)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"it's the pre-show, showtime at: {evt.OccurrenceStart}");
|
Console.WriteLine($"it's the pre-show, showtime at: {evt.OccurrenceStart}");
|
||||||
|
config.PreShow.AgentsNeeded = config.PreShow.AgentsNeeded.Select(s => s.ToLower()).ToList();
|
||||||
|
|
||||||
preShow_GetAgents(evt);
|
var commandLeadNeeded = TimeSpan.FromMinutes(15);
|
||||||
preShow_RunChecks(evt);
|
foreach(var cl in config.PreShow.Commands)
|
||||||
|
{
|
||||||
|
if(cl.leadTime > commandLeadNeeded){
|
||||||
|
commandLeadNeeded = cl.leadTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
preShow_GetAgents(evt, commandLeadNeeded + TimeSpan.FromMinutes(10));
|
||||||
|
preShow_RunChecks(evt, commandLeadNeeded);
|
||||||
preShow_RunCommands(evt);
|
preShow_RunCommands(evt);
|
||||||
}
|
}
|
||||||
protected void preShow_GetAgents(iCalHoopJumping.CalendarOccurrence evt)
|
protected void preShow_GetAgents(iCalHoopJumping.CalendarOccurrence evt, TimeSpan leadNeeded)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"preshow agents needed: {string.Join(", ", config.PreShow.AgentsNeeded)}");
|
Console.WriteLine($"preshow agents needed: {string.Join(", ", config.PreShow.AgentsNeeded)}");
|
||||||
agentsPresent.Clear();
|
agentsPresent.Clear();
|
||||||
@ -59,8 +65,8 @@ namespace ShowHandlers
|
|||||||
//Telefranz.Instance.ProduceMessage(new silver_messages.global.sound_off());
|
//Telefranz.Instance.ProduceMessage(new silver_messages.global.sound_off());
|
||||||
while (config.PreShow.AgentsNeeded.Where(ap => !agentsPresent.Contains(ap))?.Count() > 0)
|
while (config.PreShow.AgentsNeeded.Where(ap => !agentsPresent.Contains(ap))?.Count() > 0)
|
||||||
{
|
{
|
||||||
checkSignal.WaitOne(TimeSpan.FromMinutes(1));
|
checkSignal.WaitOne(TimeSpan.FromSeconds(15));
|
||||||
if(DateTime.Now > evt.OccurrenceStart - AgentsRespondingBuffer)
|
if(DateTime.Now > evt.OccurrenceStart - leadNeeded)
|
||||||
{
|
{
|
||||||
var miaAgents = string.Join(", ", config.PreShow.AgentsNeeded.Where(ap => !agentsPresent.Contains(ap)));
|
var miaAgents = string.Join(", ", config.PreShow.AgentsNeeded.Where(ap => !agentsPresent.Contains(ap)));
|
||||||
HumanCommunication.Instance.Say($"Youtube handler getting antsy and going forward. mia agents: {miaAgents}",
|
HumanCommunication.Instance.Say($"Youtube handler getting antsy and going forward. mia agents: {miaAgents}",
|
||||||
@ -70,27 +76,41 @@ namespace ShowHandlers
|
|||||||
}
|
}
|
||||||
Console.WriteLine("going forward");
|
Console.WriteLine("going forward");
|
||||||
}
|
}
|
||||||
protected void preShow_RunChecks(iCalHoopJumping.CalendarOccurrence evt)
|
protected void preShow_RunChecks(iCalHoopJumping.CalendarOccurrence evt, TimeSpan leadNeeded)
|
||||||
{
|
{
|
||||||
Console.WriteLine("pre show: run checks:");
|
Console.WriteLine("pre show: run checks:");
|
||||||
//TODO
|
|
||||||
checksProgress.Clear();
|
checksProgress.Clear();
|
||||||
var argsList = new List<string>() { JsonConvert.SerializeObject(evt) };
|
var argsList = new List<string>() { JsonConvert.SerializeObject(evt) };
|
||||||
//Telefranz.Instance.addHandler()
|
//Telefranz.Instance.addHandler()
|
||||||
foreach (var c in config.PreShow.Checks)
|
foreach (var c in config.PreShow.Checks)
|
||||||
{
|
{
|
||||||
checksProgress.Add(c.cmd, false);
|
checksProgress.Add(c.cmd, false);
|
||||||
Telefranz.Instance.ProduceMessage(new silver_messages.directorial.execute_check()
|
}
|
||||||
|
Action issueChecks = () => {
|
||||||
|
foreach (var checkCmd in checksProgress.Where(cp => cp.Value == false).Select(kvp => kvp.Key))
|
||||||
{
|
{
|
||||||
check = c.cmd,
|
var check = config.PreShow.Checks.First(clc => clc.cmd == checkCmd);
|
||||||
args = argsList.Append(c.args).ToList()
|
// Telefranz.Instance.ProduceMessage(new silver_messages.directorial.execute_check()
|
||||||
});
|
// {
|
||||||
}
|
// check = check.cmd,
|
||||||
while (true)
|
// args = argsList.Append(check.args).ToList()
|
||||||
|
// });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
issueChecks();
|
||||||
|
while (checksProgress.ContainsValue(false))
|
||||||
{
|
{
|
||||||
checkSignal.WaitOne(TimeSpan.FromSeconds(45));
|
checkSignal.WaitOne(TimeSpan.FromSeconds(15));
|
||||||
|
if(DateTime.Now > evt.OccurrenceStart - leadNeeded)
|
||||||
|
{
|
||||||
|
var stillFailing = string.Join(", ", checksProgress.Where(cp => cp.Value == false).Select(cp => cp.Key));
|
||||||
|
HumanCommunication.Instance.Say($"Youtube handler getting antsy and going forward. checks still failing: {stillFailing}",
|
||||||
|
HumanCommunication.LogLevel.Error);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
issueChecks();
|
||||||
}
|
}
|
||||||
|
Console.WriteLine("going forward");
|
||||||
}
|
}
|
||||||
protected void preShow_RunCommands(iCalHoopJumping.CalendarOccurrence evt)
|
protected void preShow_RunCommands(iCalHoopJumping.CalendarOccurrence evt)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user