Using Serilog. Added partial OBS batch request support. Added update checking. Added more commands. Added enabled/disabled TTS voices. And more.
This commit is contained in:
@@ -2,7 +2,7 @@ using CommonSocketLibrary.Abstract;
|
||||
using CommonSocketLibrary.Common;
|
||||
using HermesSocketLibrary.Socket.Data;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Serilog;
|
||||
using TwitchChatTTS.Chat.Commands.Parameters;
|
||||
using TwitchLib.Client.Models;
|
||||
|
||||
@@ -11,13 +11,14 @@ namespace TwitchChatTTS.Chat.Commands
|
||||
public class VoiceCommand : ChatCommand
|
||||
{
|
||||
private IServiceProvider _serviceProvider;
|
||||
private ILogger<VoiceCommand> _logger;
|
||||
private ILogger _logger;
|
||||
|
||||
public VoiceCommand(
|
||||
[FromKeyedServices("parameter-ttsvoicename")] ChatCommandParameter ttsVoiceParameter,
|
||||
IServiceProvider serviceProvider,
|
||||
ILogger<VoiceCommand> logger
|
||||
) : base("voice", "Select a TTS voice as the default for that user.") {
|
||||
ILogger logger
|
||||
) : base("voice", "Select a TTS voice as the default for that user.")
|
||||
{
|
||||
_serviceProvider = serviceProvider;
|
||||
_logger = logger;
|
||||
|
||||
@@ -26,7 +27,7 @@ namespace TwitchChatTTS.Chat.Commands
|
||||
|
||||
public override async Task<bool> CheckPermissions(ChatMessage message, long broadcasterId)
|
||||
{
|
||||
return message.IsModerator || message.IsBroadcaster || message.IsSubscriber || message.Bits >= 100 || message.UserId == "126224566";
|
||||
return message.IsModerator || message.IsBroadcaster || message.IsSubscriber || message.Bits >= 100;
|
||||
}
|
||||
|
||||
public override async Task Execute(IList<string> args, ChatMessage message, long broadcasterId)
|
||||
@@ -42,19 +43,12 @@ namespace TwitchChatTTS.Chat.Commands
|
||||
var voiceName = args.First().ToLower();
|
||||
var voice = context.VoicesAvailable.First(v => v.Value.ToLower() == voiceName);
|
||||
|
||||
if (context.VoicesSelected.ContainsKey(chatterId)) {
|
||||
await client.Send(3, new RequestMessage() {
|
||||
Type = "update_tts_user",
|
||||
Data = new Dictionary<string, string>() { { "@user", message.UserId }, { "@broadcaster", broadcasterId.ToString() }, { "@voice", voice.Key } }
|
||||
});
|
||||
_logger.LogInformation($"Updated {message.Username}'s (id: {message.UserId}) tts voice to {voice.Value} (id: {voice.Key}).");
|
||||
} else {
|
||||
await client.Send(3, new RequestMessage() {
|
||||
Type = "create_tts_user",
|
||||
Data = new Dictionary<string, string>() { { "@user", message.UserId }, { "@broadcaster", broadcasterId.ToString() }, { "@voice", voice.Key } }
|
||||
});
|
||||
_logger.LogInformation($"Added {message.Username}'s (id: {message.UserId}) tts voice as {voice.Value} (id: {voice.Key}).");
|
||||
}
|
||||
await client.Send(3, new RequestMessage()
|
||||
{
|
||||
Type = context.VoicesSelected.ContainsKey(chatterId) ? "update_tts_user" : "create_tts_user",
|
||||
Data = new Dictionary<string, object>() { { "chatter", chatterId }, { "voice", voice.Key } }
|
||||
});
|
||||
_logger.Information($"Updated {message.Username}'s [id: {chatterId}] tts voice to {voice.Value} (id: {voice.Key}).");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user