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