From ace5646f3600d171327e1ed448b8f38dd59efce8 Mon Sep 17 00:00:00 2001 From: barelyprofessional <150058423+barelyprofessional@users.noreply.github.com> Date: Mon, 2 Sep 2024 00:39:39 +0800 Subject: [PATCH] Fixed missing Pusher channels setting causing the bot to fail to start and fixed code so a single failing task won't take down the whole bot --- KfChatDotNetBot/Services/BotServices.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/KfChatDotNetBot/Services/BotServices.cs b/KfChatDotNetBot/Services/BotServices.cs index ffe83f6..c94738d 100644 --- a/KfChatDotNetBot/Services/BotServices.cs +++ b/KfChatDotNetBot/Services/BotServices.cs @@ -68,12 +68,14 @@ public class BotServices BuildKick(), BuildTwitch() ]; - Task.WaitAll(tasks, _cancellationToken); - var faulted = tasks.Where(task => task.IsFaulted); - foreach (var task in faulted) + try { - _logger.Error("A task faulted, exception follows"); - _logger.Error(task.Exception); + Task.WaitAll(tasks, _cancellationToken); + } + catch (Exception e) + { + _logger.Error("A service failed, exception follows"); + _logger.Error(e); } BuildRainbet(); @@ -162,7 +164,8 @@ public class BotServices private async Task BuildKick() { var settings = await Helpers.GetMultipleValues([ - BuiltIn.Keys.PusherEndpoint, BuiltIn.Keys.Proxy, BuiltIn.Keys.PusherReconnectTimeout, BuiltIn.Keys.KickEnabled + BuiltIn.Keys.PusherEndpoint, BuiltIn.Keys.Proxy, BuiltIn.Keys.PusherReconnectTimeout, BuiltIn.Keys.KickEnabled, + BuiltIn.Keys.PusherChannels ]); _kickClient = new KickWsClient.KickWsClient(settings[BuiltIn.Keys.PusherEndpoint].Value!, settings[BuiltIn.Keys.Proxy].Value, settings[BuiltIn.Keys.PusherReconnectTimeout].ToType());