Added a feature to shill the ad-free re-stream when a Twitch commercial break is detected

This commit is contained in:
barelyprofessional
2024-09-07 17:07:07 +08:00
parent 450f26f763
commit 2accae84cf
2 changed files with 27 additions and 0 deletions

View File

@@ -148,6 +148,7 @@ public class BotServices
} }
_twitch = new Twitch([settings[BuiltIn.Keys.TwitchBossmanJackId].ToType<int>()], settings[BuiltIn.Keys.Proxy].Value, _cancellationToken); _twitch = new Twitch([settings[BuiltIn.Keys.TwitchBossmanJackId].ToType<int>()], settings[BuiltIn.Keys.Proxy].Value, _cancellationToken);
_twitch.OnStreamStateUpdated += OnTwitchStreamStateUpdated; _twitch.OnStreamStateUpdated += OnTwitchStreamStateUpdated;
_twitch.OnStreamCommercial += OnTwitchStreamCommercial;
await _twitch.StartWsClient(); await _twitch.StartWsClient();
_logger.Info("Built Twitch Websocket connection for livestream notifications"); _logger.Info("Built Twitch Websocket connection for livestream notifications");
} }
@@ -555,6 +556,22 @@ public class BotServices
IsBmjLive = false; 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) private void OnChipsggRecentBet(object sender, ChipsggBetModel bet)
{ {
var settings = Helpers var settings = Helpers

View File

@@ -449,6 +449,15 @@ public static class BuiltIn
Default = "[\"https://i.postimg.cc/QMzBRmH7/hiiiii.gif\"]", Default = "[\"https://i.postimg.cc/QMzBRmH7/hiiiii.gif\"]",
IsSecret = false, IsSecret = false,
CacheDuration = TimeSpan.FromHours(1) 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 RestreamUrl = "RestreamUrl";
public static string KiwiFarmsCookies = "KiwiFarms.Cookies"; public static string KiwiFarmsCookies = "KiwiFarms.Cookies";
public static string BotGmKasinoImageRotation = "Bot.GmKasinoImageRotation"; public static string BotGmKasinoImageRotation = "Bot.GmKasinoImageRotation";
public static string TwitchShillRestreamOnCommercial = "Twitch.ShillRestreamOnCommercial";
} }
} }