2024-08-04 23:46:10 +00:00
|
|
|
using TwitchChatTTS.Twitch.Socket.Messages;
|
|
|
|
|
2024-03-15 12:27:35 +00:00
|
|
|
namespace TwitchChatTTS.Chat.Commands.Parameters
|
|
|
|
{
|
2024-07-19 16:56:41 +00:00
|
|
|
public class TTSVoiceNameParameter : CommandParameter
|
2024-03-15 12:27:35 +00:00
|
|
|
{
|
2024-07-19 16:56:41 +00:00
|
|
|
private bool _enabled;
|
2024-06-24 22:11:36 +00:00
|
|
|
private readonly User _user;
|
2024-03-15 12:27:35 +00:00
|
|
|
|
2024-07-19 16:56:41 +00:00
|
|
|
public TTSVoiceNameParameter(string name, bool enabled, User user, bool optional = false) : base(name, optional)
|
2024-03-15 12:27:35 +00:00
|
|
|
{
|
2024-07-19 16:56:41 +00:00
|
|
|
_enabled = enabled;
|
2024-06-24 22:11:36 +00:00
|
|
|
_user = user;
|
2024-03-15 12:27:35 +00:00
|
|
|
}
|
|
|
|
|
2024-08-12 19:45:17 +00:00
|
|
|
public override bool Validate(string value, TwitchChatFragment[] fragments)
|
2024-03-15 12:27:35 +00:00
|
|
|
{
|
2024-06-24 22:11:36 +00:00
|
|
|
if (_user.VoicesAvailable == null)
|
2024-03-15 12:27:35 +00:00
|
|
|
return false;
|
2024-07-19 16:56:41 +00:00
|
|
|
|
2024-03-15 12:27:35 +00:00
|
|
|
value = value.ToLower();
|
2024-07-19 16:56:41 +00:00
|
|
|
if (_enabled)
|
|
|
|
return _user.VoicesEnabled.Any(v => v.ToLower() == value);
|
|
|
|
|
2024-06-24 22:11:36 +00:00
|
|
|
return _user.VoicesAvailable.Any(e => e.Value.ToLower() == value);
|
2024-03-15 12:27:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|