diff --git a/StreamerBot/StreamerBot.xaml.cs b/StreamerBot/StreamerBot.xaml.cs index 8284f18d..688ce32b 100644 --- a/StreamerBot/StreamerBot.xaml.cs +++ b/StreamerBot/StreamerBot.xaml.cs @@ -723,9 +723,10 @@ private void CheckFocus() && OptionFlags.TwitchAuthStreamerClientSecret != "" && OptionFlags.TwitchAuthStreamerAuthCode == ""; - Radio_Twitch_PubSubBotStart.IsEnabled = OptionFlags.TwitchStreamerUseToken ? - (OptionFlags.TwitchStreamOauthToken != "" && OptionFlags.TwitchStreamerValidToken) - : OptionFlags.TwitchBotAccessToken != ""; + Radio_Twitch_PubSubBotStart.IsEnabled = OptionFlags.TwitchTokenUseAuth ? + (OptionFlags.TwitchStreamerUseToken ? OptionFlags.TwitchAuthStreamerAccessToken != "" : OptionFlags.TwitchAuthBotAccessToken != "") : + OptionFlags.TwitchStreamerUseToken ? + (OptionFlags.TwitchStreamOauthToken != "" && OptionFlags.TwitchStreamerValidToken) : OptionFlags.TwitchBotAccessToken != ""; // Twitch diff --git a/StreamerBotLib/Culture/Msgs.resx b/StreamerBotLib/Culture/Msgs.resx index a81551bc..bfec1c69 100644 --- a/StreamerBotLib/Culture/Msgs.resx +++ b/StreamerBotLib/Culture/Msgs.resx @@ -405,6 +405,9 @@ display the number of viewers + + Shows the current viewers / current followers percentage for the current live stream. + display winner of Giveaway event @@ -662,7 +665,7 @@ #user has returned. Welcome back! - #user has been streaming for #uptime, with #viewers (#deltaviewers). + #user has been streaming for #uptime, now with #viewers (#deltaviewers). The current viewer to follower rate is #viewrate, note, all viewers may not be followers. leave #(variable) intact, the message otherwise can be re-arranged/translated as necessary. also used as default message to build data table diff --git a/StreamerBotLib/Data/DataManager.cs b/StreamerBotLib/Data/DataManager.cs index 670f0ce3..8f97ad91 100644 --- a/StreamerBotLib/Data/DataManager.cs +++ b/StreamerBotLib/Data/DataManager.cs @@ -1120,6 +1120,15 @@ public string GetNewestFollower() return ((FollowersRow)GetRows(_DataSource.Followers, null, $"{_DataSource.Followers.FollowedDateColumn.ColumnName} DESC").FirstOrDefault()).UserName; } + /// + /// Query the Follower table to count the current active channel followers. + /// + /// The count of the current follower list. + public int? GetFollowerCount() + { + return (GetRows(_DataSource.Followers, $"{_DataSource.Followers.IsFollowerColumn}='true'"))?.Length ?? null; + } + /// /// Clear all user watchtimes /// diff --git a/StreamerBotLib/Enums/MsgVars.cs b/StreamerBotLib/Enums/MsgVars.cs index 250c4b55..b8c746aa 100644 --- a/StreamerBotLib/Enums/MsgVars.cs +++ b/StreamerBotLib/Enums/MsgVars.cs @@ -50,6 +50,7 @@ public enum MsgVars quote, Pluralquote, Pluralbe, - be + be, + viewrate } } diff --git a/StreamerBotLib/StreamerBotLib.csproj b/StreamerBotLib/StreamerBotLib.csproj index 920f4da1..259124f3 100644 --- a/StreamerBotLib/StreamerBotLib.csproj +++ b/StreamerBotLib/StreamerBotLib.csproj @@ -16,6 +16,10 @@ 2024 + + + + @@ -36,6 +40,10 @@ + + + + True diff --git a/StreamerBotLib/Systems/CommandSystem.cs b/StreamerBotLib/Systems/CommandSystem.cs index 221b714a..477431fe 100644 --- a/StreamerBotLib/Systems/CommandSystem.cs +++ b/StreamerBotLib/Systems/CommandSystem.cs @@ -612,12 +612,16 @@ private string ParseCommand(string command, LiveUser User, List arglist, { int DeltaViewers = Convert.ToInt32(arglist[0]) - LastLiveViewerCount; - result = VariableParser.ParseReplace(OptionFlags.IsStreamOnline ? (DataManage.GetCommand(command).Message ?? LocalizedMsgSystem.GetDefaultComMsg(DefaultCommand.uptime)) : LocalizedMsgSystem.GetVar(Msg.Msgstreamoffline), VariableParser.BuildDictionary(new Tuple[] + result = VariableParser.ParseReplace(OptionFlags.IsStreamOnline ? + (DataManage.GetCommand(command).Message ?? LocalizedMsgSystem.GetDefaultComMsg(DefaultCommand.uptime)) : + LocalizedMsgSystem.GetVar(Msg.Msgstreamoffline), + VariableParser.BuildDictionary(new Tuple[] { new( MsgVars.user, ChannelName ), new( MsgVars.uptime, FormatData.FormatTimes(GetCurrentStreamStart) ), new( MsgVars.viewers, FormatData.Plurality(arglist.Count > 0 ? arglist[0] : "", MsgVars.Pluralviewers) ), - new( MsgVars.deltaviewers, $"{(DeltaViewers>0?'+':"")}{DeltaViewers}" ) + new( MsgVars.deltaviewers, $"{(DeltaViewers>0?'+':"")}{DeltaViewers}" ), + new( MsgVars.viewrate, arglist.Count > 0 ? (Convert.ToDouble(arglist[0])/(DataManage.GetFollowerCount() ?? 1)).ToString("{P2}") : "0") })); LastLiveViewerCount = Convert.ToInt32(arglist[0]);