mirror of
https://github.com/barelyprofessional/KfChatDotNet.git
synced 2026-05-02 04:22:04 -04:00
Added an event for Twitch commercials
This commit is contained in:
@@ -17,7 +17,9 @@ public class Twitch : IDisposable
|
||||
private string? _proxy;
|
||||
private List<int> _channels;
|
||||
public delegate void OnStreamStateUpdateEventHandler(object sender, int channelId, bool isLive);
|
||||
public delegate void OnStreamCommercialEventHandler(object sender, int channelId, int length, bool scheduled);
|
||||
public event OnStreamStateUpdateEventHandler OnStreamStateUpdated;
|
||||
public event OnStreamCommercialEventHandler OnStreamCommercial;
|
||||
private CancellationToken _cancellationToken = CancellationToken.None;
|
||||
private Task? _pingTask = null;
|
||||
private CancellationTokenSource _pingCts = new();
|
||||
@@ -161,6 +163,14 @@ public class Twitch : IDisposable
|
||||
db.SaveChanges();
|
||||
return;
|
||||
}
|
||||
|
||||
if (twitchMessage.GetProperty("type").GetString() == "commercial")
|
||||
{
|
||||
_logger.Info("Twitch commercial received");
|
||||
OnStreamCommercial?.Invoke(this, channelId, twitchMessage.GetProperty("length").GetInt32(),
|
||||
twitchMessage.GetProperty("scheduled").GetBoolean());
|
||||
return;
|
||||
}
|
||||
_logger.Info("Message from Twitch was unhandled");
|
||||
_logger.Info(message.Text);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user