Changed command dictionary to a command tree. Fixed various requests. OBS reconnection added if identified previously.
This commit is contained in:
@@ -1,27 +0,0 @@
|
||||
namespace TwitchChatTTS.Chat.Commands.Parameters
|
||||
{
|
||||
public abstract class ChatCommandParameter : ICloneable
|
||||
{
|
||||
public string Name { get; }
|
||||
public string Description { get; }
|
||||
public bool Optional { get; private set; }
|
||||
|
||||
public ChatCommandParameter(string name, string description, bool optional = false)
|
||||
{
|
||||
Name = name;
|
||||
Description = description;
|
||||
Optional = optional;
|
||||
}
|
||||
|
||||
public abstract bool Validate(string value);
|
||||
|
||||
public object Clone() {
|
||||
return (ChatCommandParameter) MemberwiseClone();
|
||||
}
|
||||
|
||||
public ChatCommandParameter Permissive() {
|
||||
Optional = true;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
20
Chat/Commands/Parameters/CommandParameter.cs
Normal file
20
Chat/Commands/Parameters/CommandParameter.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
namespace TwitchChatTTS.Chat.Commands.Parameters
|
||||
{
|
||||
public abstract class CommandParameter : ICloneable
|
||||
{
|
||||
public string Name { get; }
|
||||
public bool Optional { get; }
|
||||
|
||||
public CommandParameter(string name, bool optional)
|
||||
{
|
||||
Name = name;
|
||||
Optional = optional;
|
||||
}
|
||||
|
||||
public abstract bool Validate(string value);
|
||||
|
||||
public object Clone() {
|
||||
return (CommandParameter) MemberwiseClone();
|
||||
}
|
||||
}
|
||||
}
|
||||
16
Chat/Commands/Parameters/OBSTransformationParameter.cs
Normal file
16
Chat/Commands/Parameters/OBSTransformationParameter.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
namespace TwitchChatTTS.Chat.Commands.Parameters
|
||||
{
|
||||
public class OBSTransformationParameter : CommandParameter
|
||||
{
|
||||
private string[] _values = ["x", "y", "rotation", "rotate", "r"];
|
||||
|
||||
public OBSTransformationParameter(string name, bool optional = false) : base(name, optional)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool Validate(string value)
|
||||
{
|
||||
return _values.Contains(value.ToLower());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
namespace TwitchChatTTS.Chat.Commands.Parameters
|
||||
{
|
||||
public class SimpleListedParameter : ChatCommandParameter
|
||||
{
|
||||
private readonly string[] _values;
|
||||
|
||||
public SimpleListedParameter(string[] possibleValues, bool optional = false) : base("TTS Voice Name", "Name of a TTS voice", optional)
|
||||
{
|
||||
_values = possibleValues;
|
||||
}
|
||||
|
||||
public override bool Validate(string value)
|
||||
{
|
||||
return _values.Contains(value.ToLower());
|
||||
}
|
||||
}
|
||||
}
|
||||
16
Chat/Commands/Parameters/StateParameter.cs
Normal file
16
Chat/Commands/Parameters/StateParameter.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
namespace TwitchChatTTS.Chat.Commands.Parameters
|
||||
{
|
||||
public class StateParameter : CommandParameter
|
||||
{
|
||||
private string[] _values = ["on", "off", "true", "false", "enabled", "disabled", "enable", "disable", "yes", "no"];
|
||||
|
||||
public StateParameter(string name, bool optional = false) : base(name, optional)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool Validate(string value)
|
||||
{
|
||||
return _values.Contains(value.ToLower());
|
||||
}
|
||||
}
|
||||
}
|
||||
19
Chat/Commands/Parameters/StaticParameter.cs
Normal file
19
Chat/Commands/Parameters/StaticParameter.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
namespace TwitchChatTTS.Chat.Commands.Parameters
|
||||
{
|
||||
public class StaticParameter : CommandParameter
|
||||
{
|
||||
private readonly string _value;
|
||||
|
||||
public string Value { get => _value; }
|
||||
|
||||
public StaticParameter(string name, string value, bool optional = false) : base(name, optional)
|
||||
{
|
||||
_value = value.ToLower();
|
||||
}
|
||||
|
||||
public override bool Validate(string value)
|
||||
{
|
||||
return _value == value.ToLower();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,13 @@
|
||||
namespace TwitchChatTTS.Chat.Commands.Parameters
|
||||
{
|
||||
public class TTSVoiceNameParameter : ChatCommandParameter
|
||||
public class TTSVoiceNameParameter : CommandParameter
|
||||
{
|
||||
private bool _enabled;
|
||||
private readonly User _user;
|
||||
|
||||
public TTSVoiceNameParameter(User user, bool optional = false) : base("TTS Voice Name", "Name of a TTS voice", optional)
|
||||
public TTSVoiceNameParameter(string name, bool enabled, User user, bool optional = false) : base(name, optional)
|
||||
{
|
||||
_enabled = enabled;
|
||||
_user = user;
|
||||
}
|
||||
|
||||
@@ -13,8 +15,11 @@ namespace TwitchChatTTS.Chat.Commands.Parameters
|
||||
{
|
||||
if (_user.VoicesAvailable == null)
|
||||
return false;
|
||||
|
||||
|
||||
value = value.ToLower();
|
||||
if (_enabled)
|
||||
return _user.VoicesEnabled.Any(v => v.ToLower() == value);
|
||||
|
||||
return _user.VoicesAvailable.Any(e => e.Value.ToLower() == value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
namespace TwitchChatTTS.Chat.Commands.Parameters
|
||||
{
|
||||
public class UnvalidatedParameter : ChatCommandParameter
|
||||
public class UnvalidatedParameter : CommandParameter
|
||||
{
|
||||
public UnvalidatedParameter(bool optional = false) : base("TTS Voice Name", "Name of a TTS voice", optional)
|
||||
public UnvalidatedParameter(string name, bool optional = false) : base(name, optional)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user