Fixed command permissions. Moved to using Twitch's EventSub via websockets. Cleaned some code up. Added detection for subscription messages (no TTS), message deletion, full or partial chat clear. Removes messages from TTS queue if applicable. Added command aliases for static parameters. Word filters use compiled regex if possible. Fixed TTS voice deletion.
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
using TwitchChatTTS.Twitch.Socket.Messages;
|
||||
|
||||
namespace TwitchChatTTS.Chat.Commands.Parameters
|
||||
{
|
||||
public abstract class CommandParameter : ICloneable
|
||||
public abstract class CommandParameter
|
||||
{
|
||||
public string Name { get; }
|
||||
public bool Optional { get; }
|
||||
@@ -11,10 +13,6 @@ namespace TwitchChatTTS.Chat.Commands.Parameters
|
||||
Optional = optional;
|
||||
}
|
||||
|
||||
public abstract bool Validate(string value);
|
||||
|
||||
public object Clone() {
|
||||
return (CommandParameter) MemberwiseClone();
|
||||
}
|
||||
public abstract bool Validate(string value, ChannelChatMessage message);
|
||||
}
|
||||
}
|
||||
16
Chat/Commands/Parameters/MentionParameter.cs
Normal file
16
Chat/Commands/Parameters/MentionParameter.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using TwitchChatTTS.Twitch.Socket.Messages;
|
||||
|
||||
namespace TwitchChatTTS.Chat.Commands.Parameters
|
||||
{
|
||||
public class MentionParameter : CommandParameter
|
||||
{
|
||||
public MentionParameter(string name, bool optional = false) : base(name, optional)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool Validate(string value, ChannelChatMessage message)
|
||||
{
|
||||
return value.StartsWith('@') && message.Message.Fragments.Any(f => f.Text == value && f.Mention != null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
using TwitchChatTTS.Twitch.Socket.Messages;
|
||||
|
||||
namespace TwitchChatTTS.Chat.Commands.Parameters
|
||||
{
|
||||
public class OBSTransformationParameter : CommandParameter
|
||||
@@ -8,7 +10,7 @@ namespace TwitchChatTTS.Chat.Commands.Parameters
|
||||
{
|
||||
}
|
||||
|
||||
public override bool Validate(string value)
|
||||
public override bool Validate(string value, ChannelChatMessage message)
|
||||
{
|
||||
return _values.Contains(value.ToLower());
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
using TwitchChatTTS.Twitch.Socket.Messages;
|
||||
|
||||
namespace TwitchChatTTS.Chat.Commands.Parameters
|
||||
{
|
||||
public class StateParameter : CommandParameter
|
||||
@@ -8,7 +10,7 @@ namespace TwitchChatTTS.Chat.Commands.Parameters
|
||||
{
|
||||
}
|
||||
|
||||
public override bool Validate(string value)
|
||||
public override bool Validate(string value, ChannelChatMessage message)
|
||||
{
|
||||
return _values.Contains(value.ToLower());
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
using TwitchChatTTS.Twitch.Socket.Messages;
|
||||
|
||||
namespace TwitchChatTTS.Chat.Commands.Parameters
|
||||
{
|
||||
public class StaticParameter : CommandParameter
|
||||
@@ -11,7 +13,7 @@ namespace TwitchChatTTS.Chat.Commands.Parameters
|
||||
_value = value.ToLower();
|
||||
}
|
||||
|
||||
public override bool Validate(string value)
|
||||
public override bool Validate(string value, ChannelChatMessage message)
|
||||
{
|
||||
return _value == value.ToLower();
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
using TwitchChatTTS.Twitch.Socket.Messages;
|
||||
|
||||
namespace TwitchChatTTS.Chat.Commands.Parameters
|
||||
{
|
||||
public class TTSVoiceNameParameter : CommandParameter
|
||||
@@ -11,7 +13,7 @@ namespace TwitchChatTTS.Chat.Commands.Parameters
|
||||
_user = user;
|
||||
}
|
||||
|
||||
public override bool Validate(string value)
|
||||
public override bool Validate(string value, ChannelChatMessage message)
|
||||
{
|
||||
if (_user.VoicesAvailable == null)
|
||||
return false;
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
using TwitchChatTTS.Twitch.Socket.Messages;
|
||||
|
||||
namespace TwitchChatTTS.Chat.Commands.Parameters
|
||||
{
|
||||
public class UnvalidatedParameter : CommandParameter
|
||||
@@ -6,7 +8,7 @@ namespace TwitchChatTTS.Chat.Commands.Parameters
|
||||
{
|
||||
}
|
||||
|
||||
public override bool Validate(string value)
|
||||
public override bool Validate(string value, ChannelChatMessage message)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user