From dbc4ef2ba1c6fef05085ef527375b9f890cf2461 Mon Sep 17 00:00:00 2001 From: barelyprofessional <150058423+barelyprofessional@users.noreply.github.com> Date: Mon, 17 Feb 2025 21:10:41 +0800 Subject: [PATCH] Added separate restream shill message for commercial breaks --- KfChatDotNetBot/Commands/RestreamCommands.cs | 17 +++++++++++++++++ KfChatDotNetBot/Services/BotServices.cs | 4 ++-- KfChatDotNetBot/Settings/BuiltIn.cs | 11 +++++++++++ 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/KfChatDotNetBot/Commands/RestreamCommands.cs b/KfChatDotNetBot/Commands/RestreamCommands.cs index 3bf6cb8..c18095d 100644 --- a/KfChatDotNetBot/Commands/RestreamCommands.cs +++ b/KfChatDotNetBot/Commands/RestreamCommands.cs @@ -40,7 +40,24 @@ public class SetRestreamCommand : ICommand await Helpers.SetValue(BuiltIn.Keys.RestreamUrl, arguments["url"].Value); await botInstance.SendChatMessageAsync($"@{message.Author.Username}, updated URL", true); } +} +public class SetShillRestreamCommand : ICommand +{ + public List Patterns => [ + new Regex("^restream setshill (?.+)$") + ]; + + public string? HelpText => "Set restream shill URL"; + public UserRight RequiredRight => UserRight.TrueAndHonest; + public TimeSpan Timeout => TimeSpan.FromSeconds(10); + + public async Task RunCommand(ChatBot botInstance, MessageModel message, UserDbModel user, GroupCollection arguments, + CancellationToken ctx) + { + await Helpers.SetValue(BuiltIn.Keys.TwitchCommercialRestreamShillMessage, arguments["url"].Value); + await botInstance.SendChatMessageAsync($"@{message.Author.Username}, updated URL for the commercial break restream shill", true); + } } public class SelfPromoCommand : ICommand diff --git a/KfChatDotNetBot/Services/BotServices.cs b/KfChatDotNetBot/Services/BotServices.cs index dd70372..8c829d7 100644 --- a/KfChatDotNetBot/Services/BotServices.cs +++ b/KfChatDotNetBot/Services/BotServices.cs @@ -582,7 +582,7 @@ public class BotServices private void OnTwitchStreamCommercial(object sender, int channelId, int length, bool scheduled) { var settings = Helpers - .GetMultipleValues([BuiltIn.Keys.TwitchShillRestreamOnCommercial, BuiltIn.Keys.RestreamUrl, BuiltIn.Keys.TwitchBossmanJackUsername]).Result; + .GetMultipleValues([BuiltIn.Keys.TwitchShillRestreamOnCommercial, BuiltIn.Keys.TwitchCommercialRestreamShillMessage, BuiltIn.Keys.TwitchBossmanJackUsername]).Result; if (!settings[BuiltIn.Keys.TwitchShillRestreamOnCommercial].ToBoolean()) { _logger.Debug("Not shilling as it's disabled"); @@ -591,7 +591,7 @@ public class BotServices _chatBot.SendChatMessage( $"Did you just get a {length} second ad on Twitch? The Keno Kasino encourages Total Advertiser Death.[br]" + - $"{settings[BuiltIn.Keys.TwitchBossmanJackUsername].Value} 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}", + $"{settings[BuiltIn.Keys.TwitchBossmanJackUsername].Value} streams are being re-streamed in low latency, ad-free form thanks to @Kees H. Do not watch ads.[br]{settings[BuiltIn.Keys.TwitchCommercialRestreamShillMessage].Value}", true); } diff --git a/KfChatDotNetBot/Settings/BuiltIn.cs b/KfChatDotNetBot/Settings/BuiltIn.cs index 0af0ed6..937a35e 100644 --- a/KfChatDotNetBot/Settings/BuiltIn.cs +++ b/KfChatDotNetBot/Settings/BuiltIn.cs @@ -840,6 +840,16 @@ public static class BuiltIn IsSecret = false, CacheDuration = TimeSpan.FromHours(1), ValueType = SettingValueType.Boolean + }, + new BuiltInSettingsModel + { + Key = Keys.TwitchCommercialRestreamShillMessage, + Regex = ".+", + Description = "The specific restream to shill when a commercial is detected if shilling is enabled", + Default = "No commercial restream shill message set", + IsSecret = false, + CacheDuration = TimeSpan.FromHours(1), + ValueType = SettingValueType.Text } ]; @@ -908,5 +918,6 @@ public static class BuiltIn public static string BotToyStoryImage = "Bot.ToyStoryImage"; public static string BotImageRandomSliceDivideBy = "Bot.Image.RandomSliceDivideBy"; public static string BotToyStoryImageOnChrisDjLive = "Bot.ToyStoryImageOnChrisDjLive"; + public static string TwitchCommercialRestreamShillMessage = "Twitch.CommercialRestreamShillMessage"; } } \ No newline at end of file