From 2accae84cf503eec4586e6777f0a942929ca5882 Mon Sep 17 00:00:00 2001 From: barelyprofessional <150058423+barelyprofessional@users.noreply.github.com> Date: Sat, 7 Sep 2024 17:07:07 +0800 Subject: [PATCH] Added a feature to shill the ad-free re-stream when a Twitch commercial break is detected --- KfChatDotNetBot/Services/BotServices.cs | 17 +++++++++++++++++ KfChatDotNetBot/Settings/BuiltIn.cs | 10 ++++++++++ 2 files changed, 27 insertions(+) diff --git a/KfChatDotNetBot/Services/BotServices.cs b/KfChatDotNetBot/Services/BotServices.cs index c94738d..2563d21 100644 --- a/KfChatDotNetBot/Services/BotServices.cs +++ b/KfChatDotNetBot/Services/BotServices.cs @@ -148,6 +148,7 @@ public class BotServices } _twitch = new Twitch([settings[BuiltIn.Keys.TwitchBossmanJackId].ToType()], settings[BuiltIn.Keys.Proxy].Value, _cancellationToken); _twitch.OnStreamStateUpdated += OnTwitchStreamStateUpdated; + _twitch.OnStreamCommercial += OnTwitchStreamCommercial; await _twitch.StartWsClient(); _logger.Info("Built Twitch Websocket connection for livestream notifications"); } @@ -555,6 +556,22 @@ public class BotServices IsBmjLive = false; } + private void OnTwitchStreamCommercial(object sender, int channelId, int length, bool scheduled) + { + var settings = Helpers + .GetMultipleValues([BuiltIn.Keys.TwitchShillRestreamOnCommercial, BuiltIn.Keys.RestreamUrl]).Result; + if (!settings[BuiltIn.Keys.TwitchShillRestreamOnCommercial].ToBoolean()) + { + _logger.Debug("Not shilling as it's disabled"); + return; + } + + _chatBot.SendChatMessage( + $"Did you just get a {length} second ad on Twitch? The Kasino Kasino encourages Total Advertiser Death.[br]" + + $"Bossman streams are being re-streamed in low latency, ad-free form thanks to @Kees H. Do not watch ads.[br]{settings[BuiltIn.Keys.RestreamUrl].Value}", + true); + } + private void OnChipsggRecentBet(object sender, ChipsggBetModel bet) { var settings = Helpers diff --git a/KfChatDotNetBot/Settings/BuiltIn.cs b/KfChatDotNetBot/Settings/BuiltIn.cs index b2aa6a0..b957276 100644 --- a/KfChatDotNetBot/Settings/BuiltIn.cs +++ b/KfChatDotNetBot/Settings/BuiltIn.cs @@ -449,6 +449,15 @@ public static class BuiltIn Default = "[\"https://i.postimg.cc/QMzBRmH7/hiiiii.gif\"]", IsSecret = false, CacheDuration = TimeSpan.FromHours(1) + }, + new BuiltInSettingsModel + { + Key = Keys.TwitchShillRestreamOnCommercial, + Regex = "(true|false)", + Description = "Whether to shill the ad-free restream on commercial", + Default = "true", + IsSecret = false, + CacheDuration = TimeSpan.FromHours(1) } ]; @@ -491,5 +500,6 @@ public static class BuiltIn public static string RestreamUrl = "RestreamUrl"; public static string KiwiFarmsCookies = "KiwiFarms.Cookies"; public static string BotGmKasinoImageRotation = "Bot.GmKasinoImageRotation"; + public static string TwitchShillRestreamOnCommercial = "Twitch.ShillRestreamOnCommercial"; } } \ No newline at end of file