2024-06-16 20:19:31 -04:00
|
|
|
using Serilog;
|
2024-07-16 00:48:55 -04:00
|
|
|
using TwitchChatTTS.Hermes.Socket;
|
2024-03-15 08:27:35 -04:00
|
|
|
using TwitchLib.Client.Models;
|
|
|
|
|
|
|
|
namespace TwitchChatTTS.Chat.Commands
|
|
|
|
{
|
|
|
|
public class SkipAllCommand : ChatCommand
|
|
|
|
{
|
2024-06-24 18:11:36 -04:00
|
|
|
private readonly TTSPlayer _ttsPlayer;
|
|
|
|
private readonly ILogger _logger;
|
2024-03-15 08:27:35 -04:00
|
|
|
|
2024-06-24 18:11:36 -04:00
|
|
|
public SkipAllCommand(TTSPlayer ttsPlayer, ILogger logger)
|
2024-06-16 20:19:31 -04:00
|
|
|
: base("skipall", "Skips all text to speech messages in queue and playing.")
|
|
|
|
{
|
2024-06-24 18:11:36 -04:00
|
|
|
_ttsPlayer = ttsPlayer;
|
2024-03-15 08:27:35 -04:00
|
|
|
_logger = logger;
|
|
|
|
}
|
|
|
|
|
2024-07-16 00:48:55 -04:00
|
|
|
public override async Task<bool> CheckDefaultPermissions(ChatMessage message)
|
2024-03-15 08:27:35 -04:00
|
|
|
{
|
|
|
|
return message.IsModerator || message.IsVip || message.IsBroadcaster;
|
|
|
|
}
|
|
|
|
|
2024-07-16 00:48:55 -04:00
|
|
|
public override async Task Execute(IList<string> args, ChatMessage message, HermesSocketClient client)
|
2024-03-15 08:27:35 -04:00
|
|
|
{
|
2024-06-24 18:11:36 -04:00
|
|
|
_ttsPlayer.RemoveAll();
|
2024-03-15 08:27:35 -04:00
|
|
|
|
2024-06-24 18:11:36 -04:00
|
|
|
if (_ttsPlayer.Playing == null)
|
2024-03-15 08:27:35 -04:00
|
|
|
return;
|
2024-06-16 20:19:31 -04:00
|
|
|
|
2024-06-24 18:11:36 -04:00
|
|
|
AudioPlaybackEngine.Instance.RemoveMixerInput(_ttsPlayer.Playing);
|
|
|
|
_ttsPlayer.Playing = null;
|
2024-03-15 08:27:35 -04:00
|
|
|
|
2024-06-16 20:19:31 -04:00
|
|
|
_logger.Information("Skipped all queued and playing tts.");
|
2024-03-15 08:27:35 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|