Fixed some of the compiler warnings.
This commit is contained in:
parent
db1d57c218
commit
4f5dd8f24e
@ -107,7 +107,7 @@ namespace TwitchChatTTS.Chat.Commands
|
|||||||
_logger.Information("Cleared Nightbot queue.");
|
_logger.Information("Cleared Nightbot queue.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (HttpRequestException e)
|
catch (HttpRequestException)
|
||||||
{
|
{
|
||||||
_logger.Warning("Ensure your Nightbot account is linked to your TTS account.");
|
_logger.Warning("Ensure your Nightbot account is linked to your TTS account.");
|
||||||
}
|
}
|
||||||
|
@ -104,10 +104,11 @@ namespace TwitchChatTTS.Chat.Commands
|
|||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Execute(IDictionary<string, string> values, ChannelChatMessage message, HermesSocketClient hermes)
|
public Task Execute(IDictionary<string, string> values, ChannelChatMessage message, HermesSocketClient hermes)
|
||||||
{
|
{
|
||||||
_obsManager.ClearCache();
|
_obsManager.ClearCache();
|
||||||
_logger.Information("Cleared the cache used for OBS.");
|
_logger.Information("Cleared the cache used for OBS.");
|
||||||
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,15 +52,16 @@ namespace TwitchChatTTS.Chat.Commands
|
|||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Execute(IDictionary<string, string> values, ChannelChatMessage message, HermesSocketClient hermes)
|
public Task Execute(IDictionary<string, string> values, ChannelChatMessage message, HermesSocketClient hermes)
|
||||||
{
|
{
|
||||||
if (_player.Playing == null)
|
if (_player.Playing == null)
|
||||||
return;
|
return Task.CompletedTask;
|
||||||
|
|
||||||
_playback.RemoveMixerInput(_player.Playing.Audio!);
|
_playback.RemoveMixerInput(_player.Playing.Audio!);
|
||||||
_player.Playing = null;
|
_player.Playing = null;
|
||||||
|
|
||||||
_logger.Information("Skipped current tts.");
|
_logger.Information("Skipped current tts.");
|
||||||
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,17 +80,18 @@ namespace TwitchChatTTS.Chat.Commands
|
|||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Execute(IDictionary<string, string> values, ChannelChatMessage message, HermesSocketClient hermes)
|
public Task Execute(IDictionary<string, string> values, ChannelChatMessage message, HermesSocketClient hermes)
|
||||||
{
|
{
|
||||||
_player.RemoveAll();
|
_player.RemoveAll();
|
||||||
|
|
||||||
if (_player.Playing == null)
|
if (_player.Playing == null)
|
||||||
return;
|
return Task.CompletedTask;
|
||||||
|
|
||||||
_playback.RemoveMixerInput(_player.Playing.Audio!);
|
_playback.RemoveMixerInput(_player.Playing.Audio!);
|
||||||
_player.Playing = null;
|
_player.Playing = null;
|
||||||
|
|
||||||
_logger.Information("Skipped all queued and playing tts.");
|
_logger.Information("Skipped all queued and playing tts.");
|
||||||
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ namespace TwitchChatTTS.Chat.Groups
|
|||||||
{
|
{
|
||||||
var values = groupNames.Select(g => _groups.TryGetValue(g, out var group) ? group : null).Where(g => g != null);
|
var values = groupNames.Select(g => _groups.TryGetValue(g, out var group) ? group : null).Where(g => g != null);
|
||||||
if (values.Any())
|
if (values.Any())
|
||||||
return values.Max(g => g.Priority);
|
return values.Max(g => g!.Priority);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,49 +0,0 @@
|
|||||||
namespace TwitchChatTTS.Hermes
|
|
||||||
{
|
|
||||||
public interface ICustomDataManager
|
|
||||||
{
|
|
||||||
void Add(string key, object value, string type);
|
|
||||||
void Change(string key, object value);
|
|
||||||
void Delete(string key);
|
|
||||||
object? Get(string key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public class CustomDataManager : ICustomDataManager
|
|
||||||
{
|
|
||||||
private IDictionary<string, DataInfo> _data;
|
|
||||||
|
|
||||||
public CustomDataManager()
|
|
||||||
{
|
|
||||||
_data = new Dictionary<string, DataInfo>();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void Add(string key, object value, string type)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Change(string key, object value)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Delete(string key)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public object? Get(string key)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// type: text (string), whole number (int), number (double), boolean, formula (string, data type of number)
|
|
||||||
public struct DataInfo
|
|
||||||
{
|
|
||||||
public string Id { get; set; }
|
|
||||||
public string Type { get; set; }
|
|
||||||
public object Value { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,4 +1,3 @@
|
|||||||
using System.Text.Json;
|
|
||||||
using CommonSocketLibrary.Abstract;
|
using CommonSocketLibrary.Abstract;
|
||||||
using CommonSocketLibrary.Common;
|
using CommonSocketLibrary.Common;
|
||||||
using HermesSocketLibrary.Socket.Data;
|
using HermesSocketLibrary.Socket.Data;
|
||||||
@ -24,23 +23,30 @@ namespace TwitchChatTTS.Hermes.Socket.Handlers
|
|||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Execute<Data>(SocketClient<WebSocketMessage> sender, Data data)
|
public Task Execute<Data>(SocketClient<WebSocketMessage> sender, Data data)
|
||||||
{
|
{
|
||||||
if (data is not RequestAckMessage message || message == null)
|
if (data is not RequestAckMessage message || message == null)
|
||||||
return;
|
return Task.CompletedTask;
|
||||||
if (message.Request == null)
|
if (message.Request == null)
|
||||||
{
|
{
|
||||||
_logger.Warning("Received a Hermes request message without a proper request.");
|
_logger.Warning("Received a Hermes request message without a proper request.");
|
||||||
return;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.Debug($"Received a Hermes request message [type: {message.Request.Type}][data: {string.Join(',', message.Request.Data?.Select(entry => entry.Key + '=' + entry.Value) ?? Array.Empty<string>())}]");
|
_logger.Debug($"Received a Hermes request message [type: {message.Request.Type}][data: {string.Join(',', message.Request.Data?.Select(entry => entry.Key + '=' + entry.Value) ?? Array.Empty<string>())}]");
|
||||||
var json = message.Data?.ToString();
|
var json = message.Data?.ToString();
|
||||||
if (message.Request.Type == null)
|
if (message.Request.Type == null)
|
||||||
{
|
{
|
||||||
return;
|
_logger.Warning("Request type is null. Unknown what acknowlegement this is for.");
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
if (!string.IsNullOrWhiteSpace(message.Error))
|
||||||
|
{
|
||||||
|
_logger.Warning("An error occured while processing the request on the server: " + message.Error);
|
||||||
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
_manager.Fulfill(message.Request.Type, message.Request.RequestId, json, message.Request.Data);
|
_manager.Fulfill(message.Request.Type, message.Request.RequestId, json, message.Request.Data);
|
||||||
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ namespace TwitchChatTTS.Hermes.Socket.Requests
|
|||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Fulfill(string type, string requestId, string data, IDictionary<string, object>? requestData)
|
public void Fulfill(string type, string requestId, string? data, IDictionary<string, object>? requestData)
|
||||||
{
|
{
|
||||||
if (!_acknowledgements.TryGetValue(type, out var ack))
|
if (!_acknowledgements.TryGetValue(type, out var ack))
|
||||||
{
|
{
|
||||||
|
@ -1,13 +0,0 @@
|
|||||||
public class TTSVoice
|
|
||||||
{
|
|
||||||
public string Label { get; set; }
|
|
||||||
public int Value { get; set; }
|
|
||||||
public string? Gender { get; set; }
|
|
||||||
public string? Language { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class TTSChatterSelectedVoice
|
|
||||||
{
|
|
||||||
public long ChatterId { get; set; }
|
|
||||||
public string Voice { get; set; }
|
|
||||||
}
|
|
@ -17,19 +17,17 @@ namespace TwitchChatTTS.OBS.Socket.Handlers
|
|||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Execute<Data>(SocketClient<WebSocketMessage> sender, Data data)
|
public Task Execute<Data>(SocketClient<WebSocketMessage> sender, Data data)
|
||||||
{
|
{
|
||||||
if (data is not EventMessage message || message == null)
|
if (data is not EventMessage message || message == null)
|
||||||
return;
|
return Task.CompletedTask;
|
||||||
if (sender is not OBSSocketClient obs)
|
if (sender is not OBSSocketClient obs)
|
||||||
return;
|
return Task.CompletedTask;
|
||||||
|
|
||||||
switch (message.EventType)
|
switch (message.EventType)
|
||||||
{
|
{
|
||||||
case "StreamStateChanged":
|
case "StreamStateChanged":
|
||||||
if (sender is not OBSSocketClient client)
|
if (sender is not OBSSocketClient client)
|
||||||
return;
|
return Task.CompletedTask;
|
||||||
|
|
||||||
string? raw_state = message.EventData["outputState"].ToString();
|
string? raw_state = message.EventData["outputState"].ToString();
|
||||||
string? state = raw_state?.Substring(21).ToLower();
|
string? state = raw_state?.Substring(21).ToLower();
|
||||||
obs.Streaming = message.EventData["outputActive"].ToString()!.ToLower() == "true";
|
obs.Streaming = message.EventData["outputActive"].ToString()!.ToLower() == "true";
|
||||||
@ -44,6 +42,8 @@ namespace TwitchChatTTS.OBS.Socket.Handlers
|
|||||||
_logger.Debug(message.EventType + " EVENT: " + string.Join(" | ", message.EventData?.Select(x => x.Key + "=" + x.Value?.ToString()) ?? Array.Empty<string>()));
|
_logger.Debug(message.EventType + " EVENT: " + string.Join(" | ", message.EventData?.Select(x => x.Key + "=" + x.Value?.ToString()) ?? Array.Empty<string>()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -18,12 +18,12 @@ namespace TwitchChatTTS.OBS.Socket.Handlers
|
|||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Execute<Data>(SocketClient<WebSocketMessage> sender, Data data)
|
public Task Execute<Data>(SocketClient<WebSocketMessage> sender, Data data)
|
||||||
{
|
{
|
||||||
if (data is not RequestResponseMessage message || message == null)
|
if (data is not RequestResponseMessage message || message == null)
|
||||||
return;
|
return Task.CompletedTask;
|
||||||
if (sender is not OBSSocketClient obs)
|
if (sender is not OBSSocketClient obs)
|
||||||
return;
|
return Task.CompletedTask;
|
||||||
|
|
||||||
_logger.Debug($"Received an OBS request response [obs request id: {message.RequestId}]");
|
_logger.Debug($"Received an OBS request response [obs request id: {message.RequestId}]");
|
||||||
|
|
||||||
@ -31,13 +31,12 @@ namespace TwitchChatTTS.OBS.Socket.Handlers
|
|||||||
if (requestData == null)
|
if (requestData == null)
|
||||||
{
|
{
|
||||||
_logger.Warning($"OBS Request Response not being processed: request not stored [obs request id: {message.RequestId}]");
|
_logger.Warning($"OBS Request Response not being processed: request not stored [obs request id: {message.RequestId}]");
|
||||||
return;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
var request = requestData.Message;
|
var request = requestData.Message;
|
||||||
if (request == null)
|
if (request == null)
|
||||||
return;
|
return Task.CompletedTask;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
switch (request.RequestType)
|
switch (request.RequestType)
|
||||||
@ -50,26 +49,26 @@ namespace TwitchChatTTS.OBS.Socket.Handlers
|
|||||||
if (!request.RequestData.TryGetValue("sceneName", out object? sceneName) || sceneName == null)
|
if (!request.RequestData.TryGetValue("sceneName", out object? sceneName) || sceneName == null)
|
||||||
{
|
{
|
||||||
_logger.Warning($"Failed to find the scene name that was requested [obs request id: {message.RequestId}]");
|
_logger.Warning($"Failed to find the scene name that was requested [obs request id: {message.RequestId}]");
|
||||||
return;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
if (!request.RequestData.TryGetValue("sourceName", out object? sourceName) || sourceName == null)
|
if (!request.RequestData.TryGetValue("sourceName", out object? sourceName) || sourceName == null)
|
||||||
{
|
{
|
||||||
_logger.Warning($"Failed to find the scene item name that was requested [scene: {sceneName}][obs request id: {message.RequestId}]");
|
_logger.Warning($"Failed to find the scene item name that was requested [scene: {sceneName}][obs request id: {message.RequestId}]");
|
||||||
return;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
if (message.ResponseData == null)
|
if (message.ResponseData == null)
|
||||||
{
|
{
|
||||||
_logger.Warning($"OBS Response is null [scene: {sceneName}][scene item: {sourceName}][obs request id: {message.RequestId}]");
|
_logger.Warning($"OBS Response is null [scene: {sceneName}][scene item: {sourceName}][obs request id: {message.RequestId}]");
|
||||||
return;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
if (!message.ResponseData.TryGetValue("sceneItemId", out object? sceneItemId) || sceneItemId == null)
|
if (!message.ResponseData.TryGetValue("sceneItemId", out object? sceneItemId) || sceneItemId == null)
|
||||||
{
|
{
|
||||||
_logger.Warning($"Failed to fetch the scene item id [scene: {sceneName}][scene item: {sourceName}][obs request id: {message.RequestId}]");
|
_logger.Warning($"Failed to fetch the scene item id [scene: {sceneName}][scene item: {sourceName}][obs request id: {message.RequestId}]");
|
||||||
return;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.Debug($"Found the scene item by name [scene: {sceneName}][source: {sourceName}][id: {sceneItemId}][obs request id: {message.RequestId}].");
|
_logger.Debug($"Found the scene item by name [scene: {sceneName}][source: {sourceName}][id: {sceneItemId}][obs request id: {message.RequestId}].");
|
||||||
//_manager.AddSourceId(sceneName.ToString(), sourceName.ToString(), (long) sceneItemId);
|
obs.AddSourceId(sourceName.ToString()!, (long)sceneItemId);
|
||||||
|
|
||||||
requestData.ResponseValues = message.ResponseData;
|
requestData.ResponseValues = message.ResponseData;
|
||||||
break;
|
break;
|
||||||
@ -79,22 +78,22 @@ namespace TwitchChatTTS.OBS.Socket.Handlers
|
|||||||
if (!request.RequestData.TryGetValue("sceneName", out object? sceneName) || sceneName == null)
|
if (!request.RequestData.TryGetValue("sceneName", out object? sceneName) || sceneName == null)
|
||||||
{
|
{
|
||||||
_logger.Warning($"Failed to find the scene name that was requested [obs request id: {message.RequestId}]");
|
_logger.Warning($"Failed to find the scene name that was requested [obs request id: {message.RequestId}]");
|
||||||
return;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
if (!request.RequestData.TryGetValue("sceneItemId", out object? sceneItemId) || sceneItemId == null)
|
if (!request.RequestData.TryGetValue("sceneItemId", out object? sceneItemId) || sceneItemId == null)
|
||||||
{
|
{
|
||||||
_logger.Warning($"Failed to find the scene item name that was requested [scene: {sceneName}][obs request id: {message.RequestId}]");
|
_logger.Warning($"Failed to find the scene item name that was requested [scene: {sceneName}][obs request id: {message.RequestId}]");
|
||||||
return;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
if (message.ResponseData == null)
|
if (message.ResponseData == null)
|
||||||
{
|
{
|
||||||
_logger.Warning($"OBS Response is null [scene: {sceneName}][scene item id: {sceneItemId}][obs request id: {message.RequestId}]");
|
_logger.Warning($"OBS Response is null [scene: {sceneName}][scene item id: {sceneItemId}][obs request id: {message.RequestId}]");
|
||||||
return;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
if (!message.ResponseData.TryGetValue("sceneItemTransform", out object? transformData) || transformData == null)
|
if (!message.ResponseData.TryGetValue("sceneItemTransform", out object? transformData) || transformData == null)
|
||||||
{
|
{
|
||||||
_logger.Warning($"Failed to fetch the OBS transformation data [obs request id: {message.RequestId}]");
|
_logger.Warning($"Failed to fetch the OBS transformation data [obs request id: {message.RequestId}]");
|
||||||
return;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.Debug($"Fetched OBS transformation data [scene: {sceneName}][scene item id: {sceneItemId}][transformation: {transformData}][obs request id: {message.RequestId}]");
|
_logger.Debug($"Fetched OBS transformation data [scene: {sceneName}][scene item id: {sceneItemId}][transformation: {transformData}][obs request id: {message.RequestId}]");
|
||||||
@ -106,22 +105,22 @@ namespace TwitchChatTTS.OBS.Socket.Handlers
|
|||||||
if (!request.RequestData.TryGetValue("sceneName", out object? sceneName) || sceneName == null)
|
if (!request.RequestData.TryGetValue("sceneName", out object? sceneName) || sceneName == null)
|
||||||
{
|
{
|
||||||
_logger.Warning($"Failed to find the scene name that was requested [obs request id: {message.RequestId}]");
|
_logger.Warning($"Failed to find the scene name that was requested [obs request id: {message.RequestId}]");
|
||||||
return;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
if (!request.RequestData.TryGetValue("sceneItemId", out object? sceneItemId) || sceneItemId == null)
|
if (!request.RequestData.TryGetValue("sceneItemId", out object? sceneItemId) || sceneItemId == null)
|
||||||
{
|
{
|
||||||
_logger.Warning($"Failed to find the scene item name that was requested [scene: {sceneName}][obs request id: {message.RequestId}]");
|
_logger.Warning($"Failed to find the scene item name that was requested [scene: {sceneName}][obs request id: {message.RequestId}]");
|
||||||
return;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
if (message.ResponseData == null)
|
if (message.ResponseData == null)
|
||||||
{
|
{
|
||||||
_logger.Warning($"OBS Response is null [scene: {sceneName}][scene item id: {sceneItemId}][obs request id: {message.RequestId}]");
|
_logger.Warning($"OBS Response is null [scene: {sceneName}][scene item id: {sceneItemId}][obs request id: {message.RequestId}]");
|
||||||
return;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
if (!message.ResponseData.TryGetValue("sceneItemEnabled", out object? sceneItemVisibility) || sceneItemVisibility == null)
|
if (!message.ResponseData.TryGetValue("sceneItemEnabled", out object? sceneItemVisibility) || sceneItemVisibility == null)
|
||||||
{
|
{
|
||||||
_logger.Warning($"Failed to fetch the scene item visibility [scene: {sceneName}][scene item id: {sceneItemId}][obs request id: {message.RequestId}]");
|
_logger.Warning($"Failed to fetch the scene item visibility [scene: {sceneName}][scene item id: {sceneItemId}][obs request id: {message.RequestId}]");
|
||||||
return;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.Debug($"Fetched OBS scene item visibility [scene: {sceneName}][scene item id: {sceneItemId}][visibility: {sceneItemVisibility}][obs request id: {message.RequestId}]");
|
_logger.Debug($"Fetched OBS scene item visibility [scene: {sceneName}][scene item id: {sceneItemId}][visibility: {sceneItemVisibility}][obs request id: {message.RequestId}]");
|
||||||
@ -133,12 +132,12 @@ namespace TwitchChatTTS.OBS.Socket.Handlers
|
|||||||
if (!request.RequestData.TryGetValue("sceneName", out object? sceneName) || sceneName == null)
|
if (!request.RequestData.TryGetValue("sceneName", out object? sceneName) || sceneName == null)
|
||||||
{
|
{
|
||||||
_logger.Warning($"Failed to find the scene name that was requested [obs request id: {message.RequestId}]");
|
_logger.Warning($"Failed to find the scene name that was requested [obs request id: {message.RequestId}]");
|
||||||
return;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
if (!request.RequestData.TryGetValue("sceneItemId", out object? sceneItemId) || sceneItemId == null)
|
if (!request.RequestData.TryGetValue("sceneItemId", out object? sceneItemId) || sceneItemId == null)
|
||||||
{
|
{
|
||||||
_logger.Warning($"Failed to find the scene item name that was requested [scene: {sceneName}][obs request id: {message.RequestId}]");
|
_logger.Warning($"Failed to find the scene item name that was requested [scene: {sceneName}][obs request id: {message.RequestId}]");
|
||||||
return;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
_logger.Debug($"Received response from OBS for updating scene item transformation [scene: {sceneName}][scene item id: {sceneItemId}][obs request id: {message.RequestId}]");
|
_logger.Debug($"Received response from OBS for updating scene item transformation [scene: {sceneName}][scene item id: {sceneItemId}][obs request id: {message.RequestId}]");
|
||||||
break;
|
break;
|
||||||
@ -148,12 +147,12 @@ namespace TwitchChatTTS.OBS.Socket.Handlers
|
|||||||
if (!request.RequestData.TryGetValue("sceneName", out object? sceneName) || sceneName == null)
|
if (!request.RequestData.TryGetValue("sceneName", out object? sceneName) || sceneName == null)
|
||||||
{
|
{
|
||||||
_logger.Warning($"Failed to find the scene name that was requested [obs request id: {message.RequestId}]");
|
_logger.Warning($"Failed to find the scene name that was requested [obs request id: {message.RequestId}]");
|
||||||
return;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
if (!request.RequestData.TryGetValue("sceneItemId", out object? sceneItemId) || sceneItemId == null)
|
if (!request.RequestData.TryGetValue("sceneItemId", out object? sceneItemId) || sceneItemId == null)
|
||||||
{
|
{
|
||||||
_logger.Warning($"Failed to find the scene item name that was requested [scene: {sceneName}][obs request id: {message.RequestId}]");
|
_logger.Warning($"Failed to find the scene item name that was requested [scene: {sceneName}][obs request id: {message.RequestId}]");
|
||||||
return;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
_logger.Debug($"Received response from OBS for updating scene item visibility [scene: {sceneName}][scene item id: {sceneItemId}][obs request id: {message.RequestId}]");
|
_logger.Debug($"Received response from OBS for updating scene item visibility [scene: {sceneName}][scene item id: {sceneItemId}][obs request id: {message.RequestId}]");
|
||||||
break;
|
break;
|
||||||
@ -163,12 +162,12 @@ namespace TwitchChatTTS.OBS.Socket.Handlers
|
|||||||
if (message.ResponseData == null)
|
if (message.ResponseData == null)
|
||||||
{
|
{
|
||||||
_logger.Warning($"OBS Response is null [obs request id: {message.RequestId}]");
|
_logger.Warning($"OBS Response is null [obs request id: {message.RequestId}]");
|
||||||
return;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
if (!message.ResponseData.TryGetValue("groups", out object? value) || value == null)
|
if (!message.ResponseData.TryGetValue("groups", out object? value) || value == null)
|
||||||
{
|
{
|
||||||
_logger.Warning($"Failed to fetch the scene item visibility [obs request id: {message.RequestId}]");
|
_logger.Warning($"Failed to fetch the scene item visibility [obs request id: {message.RequestId}]");
|
||||||
return;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
var groups = JsonSerializer.Deserialize<IEnumerable<string>>(value.ToString());
|
var groups = JsonSerializer.Deserialize<IEnumerable<string>>(value.ToString());
|
||||||
_logger.Debug($"Fetched OBS groups [obs request id: {message.RequestId}]");
|
_logger.Debug($"Fetched OBS groups [obs request id: {message.RequestId}]");
|
||||||
@ -183,17 +182,17 @@ namespace TwitchChatTTS.OBS.Socket.Handlers
|
|||||||
if (!request.RequestData.TryGetValue("sceneName", out object? sceneName) || sceneName == null)
|
if (!request.RequestData.TryGetValue("sceneName", out object? sceneName) || sceneName == null)
|
||||||
{
|
{
|
||||||
_logger.Warning($"Failed to find the scene name that was requested [obs request id: {message.RequestId}]");
|
_logger.Warning($"Failed to find the scene name that was requested [obs request id: {message.RequestId}]");
|
||||||
return;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
if (message.ResponseData == null)
|
if (message.ResponseData == null)
|
||||||
{
|
{
|
||||||
_logger.Warning($"OBS Response is null [scene: {sceneName}][obs request id: {message.RequestId}]");
|
_logger.Warning($"OBS Response is null [scene: {sceneName}][obs request id: {message.RequestId}]");
|
||||||
return;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
if (!message.ResponseData.TryGetValue("sceneItems", out object? value) || value == null)
|
if (!message.ResponseData.TryGetValue("sceneItems", out object? value) || value == null)
|
||||||
{
|
{
|
||||||
_logger.Warning($"Failed to fetch the scene item visibility [scene: {sceneName}][obs request id: {message.RequestId}]");
|
_logger.Warning($"Failed to fetch the scene item visibility [scene: {sceneName}][obs request id: {message.RequestId}]");
|
||||||
return;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
_logger.Debug($"Fetched OBS scene items in group [scene: {sceneName}][obs request id: {message.RequestId}]");
|
_logger.Debug($"Fetched OBS scene items in group [scene: {sceneName}][obs request id: {message.RequestId}]");
|
||||||
var sceneItems = JsonSerializer.Deserialize<IEnumerable<OBSSceneItem>>(value.ToString()!, new JsonSerializerOptions()
|
var sceneItems = JsonSerializer.Deserialize<IEnumerable<OBSSceneItem>>(value.ToString()!, new JsonSerializerOptions()
|
||||||
@ -203,7 +202,7 @@ namespace TwitchChatTTS.OBS.Socket.Handlers
|
|||||||
if (sceneItems == null)
|
if (sceneItems == null)
|
||||||
{
|
{
|
||||||
_logger.Warning($"Failed to deserialize the data received [scene: {sceneName}][obs request id: {message.RequestId}]");
|
_logger.Warning($"Failed to deserialize the data received [scene: {sceneName}][obs request id: {message.RequestId}]");
|
||||||
return;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var sceneItem in sceneItems)
|
foreach (var sceneItem in sceneItems)
|
||||||
@ -220,7 +219,7 @@ namespace TwitchChatTTS.OBS.Socket.Handlers
|
|||||||
if (!request.RequestData.TryGetValue("sleepMillis", out object? sleepMillis) || sleepMillis == null)
|
if (!request.RequestData.TryGetValue("sleepMillis", out object? sleepMillis) || sleepMillis == null)
|
||||||
{
|
{
|
||||||
_logger.Warning($"Failed to find the amount of time to sleep for [obs request id: {message.RequestId}]");
|
_logger.Warning($"Failed to find the amount of time to sleep for [obs request id: {message.RequestId}]");
|
||||||
return;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
_logger.Debug($"Received response from OBS for sleeping [sleep: {sleepMillis}][obs request id: {message.RequestId}]");
|
_logger.Debug($"Received response from OBS for sleeping [sleep: {sleepMillis}][obs request id: {message.RequestId}]");
|
||||||
break;
|
break;
|
||||||
@ -230,12 +229,12 @@ namespace TwitchChatTTS.OBS.Socket.Handlers
|
|||||||
if (message.ResponseData == null)
|
if (message.ResponseData == null)
|
||||||
{
|
{
|
||||||
_logger.Warning($"OBS Response is null [obs request id: {message.RequestId}]");
|
_logger.Warning($"OBS Response is null [obs request id: {message.RequestId}]");
|
||||||
return;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
if (!message.ResponseData.TryGetValue("outputActive", out object? outputActive) || outputActive == null)
|
if (!message.ResponseData.TryGetValue("outputActive", out object? outputActive) || outputActive == null)
|
||||||
{
|
{
|
||||||
_logger.Warning($"Failed to fetch the scene item visibility [obs request id: {message.RequestId}]");
|
_logger.Warning($"Failed to fetch the scene item visibility [obs request id: {message.RequestId}]");
|
||||||
return;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
obs.Streaming = outputActive?.ToString()!.ToLower() == "true";
|
obs.Streaming = outputActive?.ToString()!.ToLower() == "true";
|
||||||
@ -257,6 +256,8 @@ namespace TwitchChatTTS.OBS.Socket.Handlers
|
|||||||
if (requestData.Callback != null)
|
if (requestData.Callback != null)
|
||||||
requestData.Callback(requestData.ResponseValues);
|
requestData.Callback(requestData.ResponseValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -167,7 +167,7 @@ namespace TwitchChatTTS.OBS.Socket
|
|||||||
await Send(8, new RequestBatchMessage(uid, list));
|
await Send(8, new RequestBatchMessage(uid, list));
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Send(RequestMessage message, Action<Dictionary<string, object>>? callback = null)
|
public async Task Send(RequestMessage message, Action<Dictionary<string, object>?>? callback = null)
|
||||||
{
|
{
|
||||||
if (!Connected)
|
if (!Connected)
|
||||||
{
|
{
|
||||||
@ -335,7 +335,7 @@ namespace TwitchChatTTS.OBS.Socket
|
|||||||
}
|
}
|
||||||
|
|
||||||
var m = new RequestMessage("GetSceneItemId", string.Empty, new Dictionary<string, object>() { { "sceneName", sceneName }, { "sourceName", sceneItemName } });
|
var m = new RequestMessage("GetSceneItemId", string.Empty, new Dictionary<string, object>() { { "sceneName", sceneName }, { "sourceName", sceneItemName } });
|
||||||
await Send(m, async (d) =>
|
await Send(m, (d) =>
|
||||||
{
|
{
|
||||||
if (d == null || !d.TryGetValue("sceneItemId", out object? value) || value == null || !long.TryParse(value.ToString(), out long sceneItemId))
|
if (d == null || !d.TryGetValue("sceneItemId", out object? value) || value == null || !long.TryParse(value.ToString(), out long sceneItemId))
|
||||||
return;
|
return;
|
||||||
@ -357,7 +357,7 @@ namespace TwitchChatTTS.OBS.Socket
|
|||||||
public RequestMessage Message { get; }
|
public RequestMessage Message { get; }
|
||||||
public string ParentId { get; }
|
public string ParentId { get; }
|
||||||
public Dictionary<string, object>? ResponseValues { get; set; }
|
public Dictionary<string, object>? ResponseValues { get; set; }
|
||||||
public Action<Dictionary<string, object>>? Callback { get; set; }
|
public Action<Dictionary<string, object>?>? Callback { get; set; }
|
||||||
|
|
||||||
public RequestData(RequestMessage message, string parentId)
|
public RequestData(RequestMessage message, string parentId)
|
||||||
{
|
{
|
||||||
|
@ -2,6 +2,7 @@ namespace TwitchChatTTS.Seven.Socket.Data
|
|||||||
{
|
{
|
||||||
public class ErrorMessage
|
public class ErrorMessage
|
||||||
{
|
{
|
||||||
|
public Exception Exception { get; set; }
|
||||||
|
public string Message { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -20,15 +20,15 @@ namespace TwitchChatTTS.Seven.Socket.Handlers
|
|||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Execute<Data>(SocketClient<WebSocketMessage> sender, Data data)
|
public Task Execute<Data>(SocketClient<WebSocketMessage> sender, Data data)
|
||||||
{
|
{
|
||||||
if (data is not DispatchMessage message || message == null)
|
if (data is not DispatchMessage message || message == null)
|
||||||
return;
|
return Task.CompletedTask;
|
||||||
|
|
||||||
ApplyChanges(message?.Body?.Pulled, cf => cf.OldValue, true);
|
ApplyChanges(message?.Body?.Pulled, cf => cf.OldValue, true);
|
||||||
ApplyChanges(message?.Body?.Pushed, cf => cf.Value, false);
|
ApplyChanges(message?.Body?.Pushed, cf => cf.Value, false);
|
||||||
ApplyChanges(message?.Body?.Removed, cf => cf.OldValue, true);
|
ApplyChanges(message?.Body?.Removed, cf => cf.OldValue, true);
|
||||||
ApplyChanges(message?.Body?.Updated, cf => cf.OldValue, false, cf => cf.Value);
|
ApplyChanges(message?.Body?.Updated, cf => cf.OldValue, false, cf => cf.Value);
|
||||||
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ApplyChanges(IEnumerable<ChangeField>? fields, Func<ChangeField, object> getter, bool removing, Func<ChangeField, object>? updater = null)
|
private void ApplyChanges(IEnumerable<ChangeField>? fields, Func<ChangeField, object> getter, bool removing, Func<ChangeField, object>? updater = null)
|
||||||
|
@ -15,10 +15,16 @@ namespace TwitchChatTTS.Seven.Socket.Handlers
|
|||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Execute<Data>(SocketClient<WebSocketMessage> sender, Data data)
|
public Task Execute<Data>(SocketClient<WebSocketMessage> sender, Data data)
|
||||||
{
|
{
|
||||||
if (data is not ErrorMessage message || message == null)
|
if (data is not ErrorMessage message || message == null)
|
||||||
return;
|
return Task.CompletedTask;
|
||||||
|
|
||||||
|
if (message.Exception != null)
|
||||||
|
_logger.Error(message.Exception, message.Message);
|
||||||
|
else
|
||||||
|
_logger.Error(message.Message);
|
||||||
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -15,15 +15,16 @@ namespace TwitchChatTTS.Seven.Socket.Handlers
|
|||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Execute<Data>(SocketClient<WebSocketMessage> sender, Data data)
|
public Task Execute<Data>(SocketClient<WebSocketMessage> sender, Data data)
|
||||||
{
|
{
|
||||||
if (data is not SevenHelloMessage message || message == null)
|
if (data is not SevenHelloMessage message || message == null)
|
||||||
return;
|
return Task.CompletedTask;
|
||||||
if (sender is not SevenSocketClient seven || seven == null)
|
if (sender is not SevenSocketClient seven || seven == null)
|
||||||
return;
|
return Task.CompletedTask;
|
||||||
|
|
||||||
seven.ConnectionDetails = message;
|
seven.ConnectionDetails = message;
|
||||||
_logger.Debug("Received hello handshake ack.");
|
_logger.Debug("Received hello handshake ack.");
|
||||||
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -83,12 +83,12 @@ namespace TwitchChatTTS.Twitch.Redemptions
|
|||||||
switch (action.Type)
|
switch (action.Type)
|
||||||
{
|
{
|
||||||
case "WRITE_TO_FILE":
|
case "WRITE_TO_FILE":
|
||||||
Directory.CreateDirectory(Path.GetDirectoryName(action.Data["file_path"]));
|
Directory.CreateDirectory(Path.GetDirectoryName(action.Data["file_path"])!);
|
||||||
await File.WriteAllTextAsync(action.Data["file_path"], ReplaceContentText(action.Data["file_content"], senderDisplayName));
|
await File.WriteAllTextAsync(action.Data["file_path"], ReplaceContentText(action.Data["file_content"], senderDisplayName));
|
||||||
_logger.Debug($"Overwritten text to file [file: {action.Data["file_path"]}][chatter: {senderDisplayName}][chatter id: {senderId}]");
|
_logger.Debug($"Overwritten text to file [file: {action.Data["file_path"]}][chatter: {senderDisplayName}][chatter id: {senderId}]");
|
||||||
break;
|
break;
|
||||||
case "APPEND_TO_FILE":
|
case "APPEND_TO_FILE":
|
||||||
Directory.CreateDirectory(Path.GetDirectoryName(action.Data["file_path"]));
|
Directory.CreateDirectory(Path.GetDirectoryName(action.Data["file_path"])!);
|
||||||
await File.AppendAllTextAsync(action.Data["file_path"], ReplaceContentText(action.Data["file_content"], senderDisplayName));
|
await File.AppendAllTextAsync(action.Data["file_path"], ReplaceContentText(action.Data["file_content"], senderDisplayName));
|
||||||
_logger.Debug($"Appended text to file [file: {action.Data["file_path"]}][chatter: {senderDisplayName}][chatter id: {senderId}]");
|
_logger.Debug($"Appended text to file [file: {action.Data["file_path"]}][chatter: {senderDisplayName}][chatter id: {senderId}]");
|
||||||
break;
|
break;
|
||||||
@ -193,12 +193,12 @@ namespace TwitchChatTTS.Twitch.Redemptions
|
|||||||
if (_user.VoicesSelected.ContainsKey(senderId))
|
if (_user.VoicesSelected.ContainsKey(senderId))
|
||||||
{
|
{
|
||||||
await _hermes.UpdateTTSUser(senderId, voiceId);
|
await _hermes.UpdateTTSUser(senderId, voiceId);
|
||||||
_logger.Debug($"Sent request to create chat TTS voice [voice: {voiceName}][chatter id: {senderId}][source: redemption][chatter: {senderDisplayName}][chatter id: {senderId}]");
|
_logger.Debug($"Sent request to update chat TTS voice [voice: {voiceName}][chatter id: {senderId}][source: redemption][chatter: {senderDisplayName}][chatter id: {senderId}]");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
await _hermes.CreateTTSUser(senderId, voiceId);
|
await _hermes.CreateTTSUser(senderId, voiceId);
|
||||||
_logger.Debug($"Sent request to update chat TTS voice [voice: {voiceName}][chatter id: {senderId}][source: redemption][chatter: {senderDisplayName}][chatter id: {senderId}]");
|
_logger.Debug($"Sent request to create chat TTS voice [voice: {voiceName}][chatter id: {senderId}][source: redemption][chatter: {senderDisplayName}][chatter id: {senderId}]");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "AUDIO_FILE":
|
case "AUDIO_FILE":
|
||||||
|
@ -47,6 +47,7 @@ namespace TwitchChatTTS.Twitch.Socket.Handlers
|
|||||||
else
|
else
|
||||||
_logger.Debug($"No redeemable actions for ad break begin was found");
|
_logger.Debug($"No redeemable actions for ad break begin was found");
|
||||||
|
|
||||||
|
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
|
||||||
Task.Run(async () =>
|
Task.Run(async () =>
|
||||||
{
|
{
|
||||||
await Task.Delay(TimeSpan.FromSeconds(message.DurationSeconds));
|
await Task.Delay(TimeSpan.FromSeconds(message.DurationSeconds));
|
||||||
@ -73,6 +74,7 @@ namespace TwitchChatTTS.Twitch.Socket.Handlers
|
|||||||
else
|
else
|
||||||
_logger.Debug($"No redeemable actions for ad break end was found");
|
_logger.Debug($"No redeemable actions for ad break end was found");
|
||||||
});
|
});
|
||||||
|
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@ -52,7 +52,9 @@ namespace TwitchChatTTS.Twitch.Socket.Handlers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
|
||||||
Task.Run(async () => await EndOfRaidSpamProtection(message.ToBroadcasterUserId, endDate));
|
Task.Run(async () => await EndOfRaidSpamProtection(message.ToBroadcasterUserId, endDate));
|
||||||
|
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task EndOfRaidSpamProtection(string raidedId, DateTime endDate)
|
private async Task EndOfRaidSpamProtection(string raidedId, DateTime endDate)
|
||||||
|
@ -29,7 +29,9 @@ namespace TwitchChatTTS.Twitch.Socket.Handlers
|
|||||||
|
|
||||||
long broadcasterId = long.Parse(message.BroadcasterUserId);
|
long broadcasterId = long.Parse(message.BroadcasterUserId);
|
||||||
long chatterId = message.UserId == null ? 0 : long.Parse(message.UserId);
|
long chatterId = message.UserId == null ? 0 : long.Parse(message.UserId);
|
||||||
|
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
|
||||||
Task.Run(async () => await _reader.Read(sender, broadcasterId, chatterId, message.UserLogin, null, null, message.Message.Fragments, 100));
|
Task.Run(async () => await _reader.Read(sender, broadcasterId, chatterId, message.UserLogin, null, null, message.Message.Fragments, 100));
|
||||||
|
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -93,7 +93,7 @@ namespace TwitchChatTTS.Twitch.Socket
|
|||||||
_disconnected = false;
|
_disconnected = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
OnDisconnected += async (sender, e) =>
|
OnDisconnected += (sender, e) =>
|
||||||
{
|
{
|
||||||
lock (_lock)
|
lock (_lock)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user