2024-06-16 20:19:31 -04:00
|
|
|
using CommonSocketLibrary.Abstract;
|
|
|
|
using CommonSocketLibrary.Common;
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
using Serilog;
|
|
|
|
using TwitchChatTTS.Chat.Commands.Parameters;
|
2024-06-24 18:11:36 -04:00
|
|
|
using TwitchChatTTS.OBS.Socket.Data;
|
|
|
|
using TwitchChatTTS.OBS.Socket.Manager;
|
2024-06-16 20:19:31 -04:00
|
|
|
using TwitchLib.Client.Models;
|
|
|
|
|
|
|
|
namespace TwitchChatTTS.Chat.Commands
|
|
|
|
{
|
|
|
|
public class OBSCommand : ChatCommand
|
|
|
|
{
|
2024-06-24 18:11:36 -04:00
|
|
|
private readonly User _user;
|
|
|
|
private readonly OBSManager _manager;
|
|
|
|
private readonly ILogger _logger;
|
2024-06-16 20:19:31 -04:00
|
|
|
|
|
|
|
public OBSCommand(
|
|
|
|
[FromKeyedServices("parameter-unvalidated")] ChatCommandParameter unvalidatedParameter,
|
2024-06-24 18:11:36 -04:00
|
|
|
User user,
|
|
|
|
OBSManager manager,
|
|
|
|
[FromKeyedServices("obs")] SocketClient<WebSocketMessage> hermesClient,
|
2024-06-16 20:19:31 -04:00
|
|
|
ILogger logger
|
|
|
|
) : base("obs", "Various obs commands.")
|
|
|
|
{
|
2024-06-24 18:11:36 -04:00
|
|
|
_user = user;
|
|
|
|
_manager = manager;
|
2024-06-16 20:19:31 -04:00
|
|
|
_logger = logger;
|
|
|
|
|
|
|
|
AddParameter(unvalidatedParameter);
|
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task<bool> CheckPermissions(ChatMessage message, long broadcasterId)
|
|
|
|
{
|
|
|
|
return message.IsModerator || message.IsBroadcaster;
|
|
|
|
}
|
|
|
|
|
|
|
|
public override async Task Execute(IList<string> args, ChatMessage message, long broadcasterId)
|
|
|
|
{
|
2024-06-24 18:11:36 -04:00
|
|
|
if (_user == null || _user.VoicesAvailable == null)
|
2024-06-16 20:19:31 -04:00
|
|
|
return;
|
|
|
|
|
|
|
|
var voiceName = args[0].ToLower();
|
2024-06-24 18:11:36 -04:00
|
|
|
var voiceId = _user.VoicesAvailable.FirstOrDefault(v => v.Value.ToLower() == voiceName).Key;
|
2024-06-16 20:19:31 -04:00
|
|
|
var action = args[1].ToLower();
|
|
|
|
|
2024-06-24 18:11:36 -04:00
|
|
|
switch (action)
|
|
|
|
{
|
2024-06-16 20:19:31 -04:00
|
|
|
case "sleep":
|
2024-06-24 18:11:36 -04:00
|
|
|
await _manager.Send(new RequestMessage("Sleep", string.Empty, new Dictionary<string, object>() { { "sleepMillis", 10000 } }));
|
|
|
|
break;
|
2024-06-16 20:19:31 -04:00
|
|
|
case "get_scene_item_id":
|
2024-06-24 18:11:36 -04:00
|
|
|
await _manager.Send(new RequestMessage("GetSceneItemId", string.Empty, new Dictionary<string, object>() { { "sceneName", "Generic" }, { "sourceName", "ABCDEF" }, { "rotation", 90 } }));
|
|
|
|
break;
|
2024-06-16 20:19:31 -04:00
|
|
|
case "transform":
|
2024-06-24 18:11:36 -04:00
|
|
|
await _manager.UpdateTransformation(args[1], args[2], (d) =>
|
2024-06-16 20:19:31 -04:00
|
|
|
{
|
2024-06-24 18:11:36 -04:00
|
|
|
|
2024-06-16 20:19:31 -04:00
|
|
|
});
|
2024-06-24 18:11:36 -04:00
|
|
|
await _manager.Send(new RequestMessage("Transform", string.Empty, new Dictionary<string, object>() { { "sceneName", "Generic" }, { "sceneItemId", 90 }, { "rotation", 90 } }));
|
|
|
|
break;
|
2024-06-16 20:19:31 -04:00
|
|
|
case "remove":
|
2024-06-24 18:11:36 -04:00
|
|
|
await _manager.Send(new RequestMessage("Sleep", string.Empty, new Dictionary<string, object>() { { "sleepMillis", 10000 } }));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2024-06-16 20:19:31 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|