Added hermes websocket support. Added chat command support. Added selectable voice command via websocket. Added websocket heartbeat management.
This commit is contained in:
17
Chat/Commands/Parameters/ChatCommandParameter.cs
Normal file
17
Chat/Commands/Parameters/ChatCommandParameter.cs
Normal file
@ -0,0 +1,17 @@
|
||||
namespace TwitchChatTTS.Chat.Commands.Parameters
|
||||
{
|
||||
public abstract class ChatCommandParameter
|
||||
{
|
||||
public string Name { get; }
|
||||
public string Description { get; }
|
||||
public bool Optional { get; }
|
||||
|
||||
public ChatCommandParameter(string name, string description, bool optional = false) {
|
||||
Name = name;
|
||||
Description = description;
|
||||
Optional = optional;
|
||||
}
|
||||
|
||||
public abstract bool Validate(string value);
|
||||
}
|
||||
}
|
23
Chat/Commands/Parameters/TTSVoiceNameParameter.cs
Normal file
23
Chat/Commands/Parameters/TTSVoiceNameParameter.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
namespace TwitchChatTTS.Chat.Commands.Parameters
|
||||
{
|
||||
public class TTSVoiceNameParameter : ChatCommandParameter
|
||||
{
|
||||
private IServiceProvider _serviceProvider;
|
||||
|
||||
public TTSVoiceNameParameter(IServiceProvider serviceProvider, bool optional = false) : base("TTS Voice Name", "Name of a TTS voice", optional)
|
||||
{
|
||||
_serviceProvider = serviceProvider;
|
||||
}
|
||||
|
||||
public override bool Validate(string value)
|
||||
{
|
||||
var user = _serviceProvider.GetRequiredService<User>();
|
||||
if (user.VoicesAvailable == null)
|
||||
return false;
|
||||
|
||||
value = value.ToLower();
|
||||
return user.VoicesAvailable.Any(e => e.Value.ToLower() == value);
|
||||
}
|
||||
}
|
||||
}
|
14
Chat/Commands/Parameters/UnvalidatedParameter.cs
Normal file
14
Chat/Commands/Parameters/UnvalidatedParameter.cs
Normal file
@ -0,0 +1,14 @@
|
||||
namespace TwitchChatTTS.Chat.Commands.Parameters
|
||||
{
|
||||
public class UnvalidatedParameter : ChatCommandParameter
|
||||
{
|
||||
public UnvalidatedParameter(bool optional = false) : base("TTS Voice Name", "Name of a TTS voice", optional)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool Validate(string value)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user