2024-06-16 20:19:31 -04:00
|
|
|
using Serilog;
|
2024-03-15 08:27:35 -04:00
|
|
|
using TwitchLib.Client.Models;
|
|
|
|
|
|
|
|
namespace TwitchChatTTS.Chat.Commands
|
|
|
|
{
|
|
|
|
public class SkipCommand : 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 SkipCommand(TTSPlayer ttsPlayer, ILogger logger)
|
2024-06-16 20:19:31 -04:00
|
|
|
: base("skip", "Skips the current text to speech message.")
|
|
|
|
{
|
2024-06-24 18:11:36 -04:00
|
|
|
_ttsPlayer = ttsPlayer;
|
2024-03-15 08:27:35 -04:00
|
|
|
_logger = logger;
|
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task<bool> CheckPermissions(ChatMessage message, long broadcasterId)
|
|
|
|
{
|
|
|
|
return message.IsModerator || message.IsVip || message.IsBroadcaster;
|
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task Execute(IList<string> args, ChatMessage message, long broadcasterId)
|
|
|
|
{
|
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 current tts.");
|
2024-03-15 08:27:35 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|