Skip to content

Commit

Permalink
Added option to disable "!vanish" command
Browse files Browse the repository at this point in the history
  • Loading branch information
Abev08 committed Apr 12, 2024
1 parent d278c68 commit 27d3ea7
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Chat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public static class Chat
private static DateTime RespMsgFileTimestamp;
private static readonly List<SkipSongChatter> SkipSongChatters = new();
private static int s_chatMessagesSinceLastPeriodicMessage;
/// <summary> !vanish chat command enabled </summary>
public static bool VanishEnabled { get; set; }

public static void Start()
{
Expand Down Expand Up @@ -271,7 +273,8 @@ private static void Update()
}
else if (message[1][1..].StartsWith("!vanish")) // Check if the message starts with !vanish key
{
if (message[1].Length == 8)
if (!Chat.VanishEnabled) { } // Disabled - do nothing
else if (message[1].Length == 8)
{
// Vanish the command user
if (!userBadge.Equals("STR")) BanChatter("!vanish command", userID, userName);
Expand Down Expand Up @@ -814,7 +817,7 @@ private static void SendCommandsResponse(string userName)
{
StringBuilder sb = new();
string s;
sb.Append('@').Append(userName).Append(" ");
sb.Append('@').Append(userName).Append(' ');
if (Notifications.ChatTTSEnabled) sb.Append("!tts message, ");
s = MinigameFight.GetCommands();
if (s?.Length > 0) sb.Append(s).Append(", ");
Expand All @@ -833,6 +836,10 @@ private static void SendCommandsResponse(string userName)
if (Spotify.RequestEnabled) sb.Append("!songrequest, !sr, ");
if (Spotify.SkipEnabled) sb.Append("!skipsong, ");
}
if (Chat.VanishEnabled)
{
sb.Append("!vanish, ");
}

foreach (string key in ResponseMessages.Keys)
{
Expand Down
2 changes: 2 additions & 0 deletions Database.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public enum Keys
EnabledFight,
EnabledWelcomeMessages,
EnabledSpotifySkip, EnabledSpotifyRequest,
EnabledVanish,
SpotifyOAuth, SpotifyOAuthRefresh,
DiscordOAuth, DiscordOAuthRefresh, DiscordOAuthExpiration,
LastOnline
Expand Down Expand Up @@ -94,6 +95,7 @@ public static bool Init()
Notifications.WelcomeMessagesEnabled = bool.Parse(GetValueOrCreateFromConfig(Keys.EnabledWelcomeMessages, "True"));
Spotify.SkipEnabled = bool.Parse(GetValueOrCreateFromConfig(Keys.EnabledSpotifySkip, "True"));
Spotify.RequestEnabled = bool.Parse(GetValueOrCreateFromConfig(Keys.EnabledSpotifyRequest, "True"));
Chat.VanishEnabled = bool.Parse(GetValueOrCreateFromConfig(Keys.EnabledVanish, "True"));
MainWindow.I.SetEnabledStatus();

Connection.Close();
Expand Down
1 change: 1 addition & 0 deletions MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
<CheckBox x:Name="chkEnableWelcomeMessages" Content="!welcomemessage enabled" VerticalContentAlignment="Center" IsChecked="True" Checked="ChkWelcome_CheckChanged" Unchecked="ChkWelcome_CheckChanged" ToolTip="Welcome messages"/>
<CheckBox x:Name="chkEnableSongSkip" Content="!skipsong enabled (chat)" VerticalContentAlignment="Center" IsChecked="True" Checked="ChkSkip_CheckChanged" Unchecked="ChkSkip_CheckChanged" ToolTip="Song skip"/>
<CheckBox x:Name="chkEnableSongRequest" Content="!sr enabled (chat)" VerticalContentAlignment="Center" IsChecked="True" Checked="ChkRequest_CheckChanged" Unchecked="ChkRequest_CheckChanged" ToolTip="Song request"/>
<CheckBox x:Name="chkEnableVanish" Content="!vanish enabled (chat)" VerticalContentAlignment="Center" IsChecked="True" Checked="ChkVanish_CheckChanged" Unchecked="ChkVanish_CheckChanged" ToolTip="'!vanish' command (self timeout)"/>
</StackPanel>
</Border>
</StackPanel>
Expand Down
7 changes: 7 additions & 0 deletions MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,12 @@ private async void ChkRequest_CheckChanged(object sender, RoutedEventArgs e)
if (FinishedLoading) await Database.UpdateValueInConfig(Database.Keys.EnabledSpotifyRequest, Spotify.RequestEnabled);
}

private async void ChkVanish_CheckChanged(object sender, RoutedEventArgs e)
{
Chat.VanishEnabled = ((CheckBox)sender).IsChecked == true;
if (FinishedLoading) await Database.UpdateValueInConfig(Database.Keys.EnabledVanish, Chat.VanishEnabled);
}

private void MainVideoEnded(object sender, RoutedEventArgs e)
{
VideoPlayer.Source = null;
Expand Down Expand Up @@ -615,6 +621,7 @@ public void SetEnabledStatus()
chkEnableWelcomeMessages.IsChecked = Notifications.WelcomeMessagesEnabled;
chkEnableSongSkip.IsChecked = Spotify.SkipEnabled;
chkEnableSongRequest.IsChecked = Spotify.RequestEnabled;
chkEnableVanish.IsChecked = Chat.VanishEnabled;
}

public void GambaAnimationStart(FileInfo videoPath, string userName, int points, int pointsResult)
Expand Down

0 comments on commit 27d3ea7

Please sign in to comment.