From 4f5dd8f24e73ed8428e2170ff41c55ad69a1ac4e Mon Sep 17 00:00:00 2001 From: Tom Date: Sat, 28 Dec 2024 21:19:28 +0000 Subject: [PATCH] Fixed some of the compiler warnings. --- Chat/Commands/NightbotCommand.cs | 2 +- Chat/Commands/RefreshCommand.cs | 3 +- Chat/Commands/SkipCommand.cs | 10 +-- Chat/Groups/ChatterGroupManager.cs | 2 +- Hermes/CustomDataManager.cs | 49 -------------- Hermes/Socket/Handlers/RequestAckHandler.cs | 16 +++-- Hermes/Socket/Requests/RequestAckManager.cs | 2 +- Hermes/TTSVoice.cs | 13 ---- OBS/Socket/Handlers/EventMessageHandler.cs | 12 ++-- OBS/Socket/Handlers/RequestResponseHandler.cs | 65 ++++++++++--------- OBS/Socket/OBSSocketClient.cs | 6 +- Seven/Socket/Data/ErrorMessage.cs | 3 +- Seven/Socket/Handlers/DispatchHandler.cs | 6 +- Seven/Socket/Handlers/ErrorHandler.cs | 10 ++- Seven/Socket/Handlers/SevenHelloHandler.cs | 9 +-- Twitch/Redemptions/RedemptionManager.cs | 8 +-- .../Handlers/ChannelAdBreakBeginHandler.cs | 2 + Twitch/Socket/Handlers/ChannelRaidHandler.cs | 2 + .../Handlers/ChannelResubscriptionHandler.cs | 2 + Twitch/Socket/TwitchWebsocketClient.cs | 2 +- 20 files changed, 93 insertions(+), 131 deletions(-) delete mode 100644 Hermes/CustomDataManager.cs delete mode 100644 Hermes/TTSVoice.cs diff --git a/Chat/Commands/NightbotCommand.cs b/Chat/Commands/NightbotCommand.cs index e5af1e5..894f05a 100644 --- a/Chat/Commands/NightbotCommand.cs +++ b/Chat/Commands/NightbotCommand.cs @@ -107,7 +107,7 @@ namespace TwitchChatTTS.Chat.Commands _logger.Information("Cleared Nightbot queue."); } } - catch (HttpRequestException e) + catch (HttpRequestException) { _logger.Warning("Ensure your Nightbot account is linked to your TTS account."); } diff --git a/Chat/Commands/RefreshCommand.cs b/Chat/Commands/RefreshCommand.cs index 1632e7b..fe8261d 100644 --- a/Chat/Commands/RefreshCommand.cs +++ b/Chat/Commands/RefreshCommand.cs @@ -104,10 +104,11 @@ namespace TwitchChatTTS.Chat.Commands _logger = logger; } - public async Task Execute(IDictionary values, ChannelChatMessage message, HermesSocketClient hermes) + public Task Execute(IDictionary values, ChannelChatMessage message, HermesSocketClient hermes) { _obsManager.ClearCache(); _logger.Information("Cleared the cache used for OBS."); + return Task.CompletedTask; } } diff --git a/Chat/Commands/SkipCommand.cs b/Chat/Commands/SkipCommand.cs index 452efa1..c456267 100644 --- a/Chat/Commands/SkipCommand.cs +++ b/Chat/Commands/SkipCommand.cs @@ -52,15 +52,16 @@ namespace TwitchChatTTS.Chat.Commands _logger = logger; } - public async Task Execute(IDictionary values, ChannelChatMessage message, HermesSocketClient hermes) + public Task Execute(IDictionary values, ChannelChatMessage message, HermesSocketClient hermes) { if (_player.Playing == null) - return; + return Task.CompletedTask; _playback.RemoveMixerInput(_player.Playing.Audio!); _player.Playing = null; _logger.Information("Skipped current tts."); + return Task.CompletedTask; } } @@ -79,17 +80,18 @@ namespace TwitchChatTTS.Chat.Commands _logger = logger; } - public async Task Execute(IDictionary values, ChannelChatMessage message, HermesSocketClient hermes) + public Task Execute(IDictionary values, ChannelChatMessage message, HermesSocketClient hermes) { _player.RemoveAll(); if (_player.Playing == null) - return; + return Task.CompletedTask; _playback.RemoveMixerInput(_player.Playing.Audio!); _player.Playing = null; _logger.Information("Skipped all queued and playing tts."); + return Task.CompletedTask; } } } diff --git a/Chat/Groups/ChatterGroupManager.cs b/Chat/Groups/ChatterGroupManager.cs index 123e48f..7413d5c 100644 --- a/Chat/Groups/ChatterGroupManager.cs +++ b/Chat/Groups/ChatterGroupManager.cs @@ -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); if (values.Any()) - return values.Max(g => g.Priority); + return values.Max(g => g!.Priority); return 0; } diff --git a/Hermes/CustomDataManager.cs b/Hermes/CustomDataManager.cs deleted file mode 100644 index 303e02f..0000000 --- a/Hermes/CustomDataManager.cs +++ /dev/null @@ -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 _data; - - public CustomDataManager() - { - _data = new Dictionary(); - } - - - 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; } - } -} \ No newline at end of file diff --git a/Hermes/Socket/Handlers/RequestAckHandler.cs b/Hermes/Socket/Handlers/RequestAckHandler.cs index 6d5bcda..ef43fce 100644 --- a/Hermes/Socket/Handlers/RequestAckHandler.cs +++ b/Hermes/Socket/Handlers/RequestAckHandler.cs @@ -1,4 +1,3 @@ -using System.Text.Json; using CommonSocketLibrary.Abstract; using CommonSocketLibrary.Common; using HermesSocketLibrary.Socket.Data; @@ -24,23 +23,30 @@ namespace TwitchChatTTS.Hermes.Socket.Handlers _logger = logger; } - public async Task Execute(SocketClient sender, Data data) + public Task Execute(SocketClient sender, Data data) { if (data is not RequestAckMessage message || message == null) - return; + return Task.CompletedTask; if (message.Request == null) { _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())}]"); var json = message.Data?.ToString(); 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); + return Task.CompletedTask; } } diff --git a/Hermes/Socket/Requests/RequestAckManager.cs b/Hermes/Socket/Requests/RequestAckManager.cs index 6d91d0c..eb50a5a 100644 --- a/Hermes/Socket/Requests/RequestAckManager.cs +++ b/Hermes/Socket/Requests/RequestAckManager.cs @@ -13,7 +13,7 @@ namespace TwitchChatTTS.Hermes.Socket.Requests _logger = logger; } - public void Fulfill(string type, string requestId, string data, IDictionary? requestData) + public void Fulfill(string type, string requestId, string? data, IDictionary? requestData) { if (!_acknowledgements.TryGetValue(type, out var ack)) { diff --git a/Hermes/TTSVoice.cs b/Hermes/TTSVoice.cs deleted file mode 100644 index f98d682..0000000 --- a/Hermes/TTSVoice.cs +++ /dev/null @@ -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; } -} \ No newline at end of file diff --git a/OBS/Socket/Handlers/EventMessageHandler.cs b/OBS/Socket/Handlers/EventMessageHandler.cs index 2f7c30c..04bc7c2 100644 --- a/OBS/Socket/Handlers/EventMessageHandler.cs +++ b/OBS/Socket/Handlers/EventMessageHandler.cs @@ -17,19 +17,17 @@ namespace TwitchChatTTS.OBS.Socket.Handlers _logger = logger; } - public async Task Execute(SocketClient sender, Data data) + public Task Execute(SocketClient sender, Data data) { if (data is not EventMessage message || message == null) - return; + return Task.CompletedTask; if (sender is not OBSSocketClient obs) - return; - + return Task.CompletedTask; switch (message.EventType) { case "StreamStateChanged": if (sender is not OBSSocketClient client) - return; - + return Task.CompletedTask; string? raw_state = message.EventData["outputState"].ToString(); string? state = raw_state?.Substring(21).ToLower(); 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())); break; } + + return Task.CompletedTask; } } } \ No newline at end of file diff --git a/OBS/Socket/Handlers/RequestResponseHandler.cs b/OBS/Socket/Handlers/RequestResponseHandler.cs index d5c6223..3574ddd 100644 --- a/OBS/Socket/Handlers/RequestResponseHandler.cs +++ b/OBS/Socket/Handlers/RequestResponseHandler.cs @@ -18,12 +18,12 @@ namespace TwitchChatTTS.OBS.Socket.Handlers _logger = logger; } - public async Task Execute(SocketClient sender, Data data) + public Task Execute(SocketClient sender, Data data) { if (data is not RequestResponseMessage message || message == null) - return; + return Task.CompletedTask; if (sender is not OBSSocketClient obs) - return; + return Task.CompletedTask; _logger.Debug($"Received an OBS request response [obs request id: {message.RequestId}]"); @@ -31,13 +31,12 @@ namespace TwitchChatTTS.OBS.Socket.Handlers if (requestData == null) { _logger.Warning($"OBS Request Response not being processed: request not stored [obs request id: {message.RequestId}]"); - return; + return Task.CompletedTask; } var request = requestData.Message; if (request == null) - return; - + return Task.CompletedTask; try { switch (request.RequestType) @@ -50,26 +49,26 @@ namespace TwitchChatTTS.OBS.Socket.Handlers 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}]"); - return; + return Task.CompletedTask; } 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}]"); - return; + return Task.CompletedTask; } if (message.ResponseData == null) { _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) { _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}]."); - //_manager.AddSourceId(sceneName.ToString(), sourceName.ToString(), (long) sceneItemId); + obs.AddSourceId(sourceName.ToString()!, (long)sceneItemId); requestData.ResponseValues = message.ResponseData; break; @@ -79,22 +78,22 @@ namespace TwitchChatTTS.OBS.Socket.Handlers 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}]"); - return; + return Task.CompletedTask; } 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}]"); - return; + return Task.CompletedTask; } if (message.ResponseData == null) { _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) { _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}]"); @@ -106,22 +105,22 @@ namespace TwitchChatTTS.OBS.Socket.Handlers 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}]"); - return; + return Task.CompletedTask; } 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}]"); - return; + return Task.CompletedTask; } if (message.ResponseData == null) { _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) { _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}]"); @@ -133,12 +132,12 @@ namespace TwitchChatTTS.OBS.Socket.Handlers 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}]"); - return; + return Task.CompletedTask; } 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}]"); - 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}]"); break; @@ -148,12 +147,12 @@ namespace TwitchChatTTS.OBS.Socket.Handlers 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}]"); - return; + return Task.CompletedTask; } 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}]"); - 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}]"); break; @@ -163,12 +162,12 @@ namespace TwitchChatTTS.OBS.Socket.Handlers if (message.ResponseData == null) { _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) { _logger.Warning($"Failed to fetch the scene item visibility [obs request id: {message.RequestId}]"); - return; + return Task.CompletedTask; } var groups = JsonSerializer.Deserialize>(value.ToString()); _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) { _logger.Warning($"Failed to find the scene name that was requested [obs request id: {message.RequestId}]"); - return; + return Task.CompletedTask; } if (message.ResponseData == null) { _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) { _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}]"); var sceneItems = JsonSerializer.Deserialize>(value.ToString()!, new JsonSerializerOptions() @@ -203,7 +202,7 @@ namespace TwitchChatTTS.OBS.Socket.Handlers if (sceneItems == null) { _logger.Warning($"Failed to deserialize the data received [scene: {sceneName}][obs request id: {message.RequestId}]"); - return; + return Task.CompletedTask; } foreach (var sceneItem in sceneItems) @@ -220,7 +219,7 @@ namespace TwitchChatTTS.OBS.Socket.Handlers 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}]"); - return; + return Task.CompletedTask; } _logger.Debug($"Received response from OBS for sleeping [sleep: {sleepMillis}][obs request id: {message.RequestId}]"); break; @@ -230,12 +229,12 @@ namespace TwitchChatTTS.OBS.Socket.Handlers if (message.ResponseData == null) { _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) { _logger.Warning($"Failed to fetch the scene item visibility [obs request id: {message.RequestId}]"); - return; + return Task.CompletedTask; } obs.Streaming = outputActive?.ToString()!.ToLower() == "true"; @@ -257,6 +256,8 @@ namespace TwitchChatTTS.OBS.Socket.Handlers if (requestData.Callback != null) requestData.Callback(requestData.ResponseValues); } + + return Task.CompletedTask; } } } \ No newline at end of file diff --git a/OBS/Socket/OBSSocketClient.cs b/OBS/Socket/OBSSocketClient.cs index f06d7c6..4d2b680 100644 --- a/OBS/Socket/OBSSocketClient.cs +++ b/OBS/Socket/OBSSocketClient.cs @@ -167,7 +167,7 @@ namespace TwitchChatTTS.OBS.Socket await Send(8, new RequestBatchMessage(uid, list)); } - public async Task Send(RequestMessage message, Action>? callback = null) + public async Task Send(RequestMessage message, Action?>? callback = null) { if (!Connected) { @@ -335,7 +335,7 @@ namespace TwitchChatTTS.OBS.Socket } var m = new RequestMessage("GetSceneItemId", string.Empty, new Dictionary() { { "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)) return; @@ -357,7 +357,7 @@ namespace TwitchChatTTS.OBS.Socket public RequestMessage Message { get; } public string ParentId { get; } public Dictionary? ResponseValues { get; set; } - public Action>? Callback { get; set; } + public Action?>? Callback { get; set; } public RequestData(RequestMessage message, string parentId) { diff --git a/Seven/Socket/Data/ErrorMessage.cs b/Seven/Socket/Data/ErrorMessage.cs index aa397f5..6a9d9d4 100644 --- a/Seven/Socket/Data/ErrorMessage.cs +++ b/Seven/Socket/Data/ErrorMessage.cs @@ -2,6 +2,7 @@ namespace TwitchChatTTS.Seven.Socket.Data { public class ErrorMessage { - + public Exception Exception { get; set; } + public string Message { get; set; } } } \ No newline at end of file diff --git a/Seven/Socket/Handlers/DispatchHandler.cs b/Seven/Socket/Handlers/DispatchHandler.cs index 60634e4..f0e077b 100644 --- a/Seven/Socket/Handlers/DispatchHandler.cs +++ b/Seven/Socket/Handlers/DispatchHandler.cs @@ -20,15 +20,15 @@ namespace TwitchChatTTS.Seven.Socket.Handlers _logger = logger; } - public async Task Execute(SocketClient sender, Data data) + public Task Execute(SocketClient sender, Data data) { if (data is not DispatchMessage message || message == null) - return; - + return Task.CompletedTask; ApplyChanges(message?.Body?.Pulled, cf => cf.OldValue, true); ApplyChanges(message?.Body?.Pushed, cf => cf.Value, false); ApplyChanges(message?.Body?.Removed, cf => cf.OldValue, true); ApplyChanges(message?.Body?.Updated, cf => cf.OldValue, false, cf => cf.Value); + return Task.CompletedTask; } private void ApplyChanges(IEnumerable? fields, Func getter, bool removing, Func? updater = null) diff --git a/Seven/Socket/Handlers/ErrorHandler.cs b/Seven/Socket/Handlers/ErrorHandler.cs index 67db0bf..239ad3e 100644 --- a/Seven/Socket/Handlers/ErrorHandler.cs +++ b/Seven/Socket/Handlers/ErrorHandler.cs @@ -15,10 +15,16 @@ namespace TwitchChatTTS.Seven.Socket.Handlers _logger = logger; } - public async Task Execute(SocketClient sender, Data data) + public Task Execute(SocketClient sender, Data data) { 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; } } } \ No newline at end of file diff --git a/Seven/Socket/Handlers/SevenHelloHandler.cs b/Seven/Socket/Handlers/SevenHelloHandler.cs index 92e8058..28d1c1b 100644 --- a/Seven/Socket/Handlers/SevenHelloHandler.cs +++ b/Seven/Socket/Handlers/SevenHelloHandler.cs @@ -15,15 +15,16 @@ namespace TwitchChatTTS.Seven.Socket.Handlers _logger = logger; } - public async Task Execute(SocketClient sender, Data data) + public Task Execute(SocketClient sender, Data data) { if (data is not SevenHelloMessage message || message == null) - return; + return Task.CompletedTask; if (sender is not SevenSocketClient seven || seven == null) - return; - + return Task.CompletedTask; + seven.ConnectionDetails = message; _logger.Debug("Received hello handshake ack."); + return Task.CompletedTask; } } } \ No newline at end of file diff --git a/Twitch/Redemptions/RedemptionManager.cs b/Twitch/Redemptions/RedemptionManager.cs index f5de744..eff0984 100644 --- a/Twitch/Redemptions/RedemptionManager.cs +++ b/Twitch/Redemptions/RedemptionManager.cs @@ -83,12 +83,12 @@ namespace TwitchChatTTS.Twitch.Redemptions switch (action.Type) { 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)); _logger.Debug($"Overwritten text to file [file: {action.Data["file_path"]}][chatter: {senderDisplayName}][chatter id: {senderId}]"); break; 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)); _logger.Debug($"Appended text to file [file: {action.Data["file_path"]}][chatter: {senderDisplayName}][chatter id: {senderId}]"); break; @@ -193,12 +193,12 @@ namespace TwitchChatTTS.Twitch.Redemptions if (_user.VoicesSelected.ContainsKey(senderId)) { 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 { 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; case "AUDIO_FILE": diff --git a/Twitch/Socket/Handlers/ChannelAdBreakBeginHandler.cs b/Twitch/Socket/Handlers/ChannelAdBreakBeginHandler.cs index b1e5a40..7c9b8c1 100644 --- a/Twitch/Socket/Handlers/ChannelAdBreakBeginHandler.cs +++ b/Twitch/Socket/Handlers/ChannelAdBreakBeginHandler.cs @@ -47,6 +47,7 @@ namespace TwitchChatTTS.Twitch.Socket.Handlers else _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 () => { await Task.Delay(TimeSpan.FromSeconds(message.DurationSeconds)); @@ -73,6 +74,7 @@ namespace TwitchChatTTS.Twitch.Socket.Handlers else _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) { diff --git a/Twitch/Socket/Handlers/ChannelRaidHandler.cs b/Twitch/Socket/Handlers/ChannelRaidHandler.cs index 43da7c6..abf37d2 100644 --- a/Twitch/Socket/Handlers/ChannelRaidHandler.cs +++ b/Twitch/Socket/Handlers/ChannelRaidHandler.cs @@ -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)); +#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) diff --git a/Twitch/Socket/Handlers/ChannelResubscriptionHandler.cs b/Twitch/Socket/Handlers/ChannelResubscriptionHandler.cs index 9681c5c..d1287ec 100644 --- a/Twitch/Socket/Handlers/ChannelResubscriptionHandler.cs +++ b/Twitch/Socket/Handlers/ChannelResubscriptionHandler.cs @@ -29,7 +29,9 @@ namespace TwitchChatTTS.Twitch.Socket.Handlers long broadcasterId = long.Parse(message.BroadcasterUserId); 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)); +#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed try { diff --git a/Twitch/Socket/TwitchWebsocketClient.cs b/Twitch/Socket/TwitchWebsocketClient.cs index 95e054d..6a8b2ee 100644 --- a/Twitch/Socket/TwitchWebsocketClient.cs +++ b/Twitch/Socket/TwitchWebsocketClient.cs @@ -93,7 +93,7 @@ namespace TwitchChatTTS.Twitch.Socket _disconnected = false; }; - OnDisconnected += async (sender, e) => + OnDisconnected += (sender, e) => { lock (_lock) {