From 0bed14effaadcbc71e32a7c89f5c48b331758749 Mon Sep 17 00:00:00 2001 From: Pietro di Caprio Date: Sat, 15 Oct 2022 23:40:16 +0200 Subject: [PATCH] Add temporary chat ignore list used in case of error --- Unifiedban.Terminal/Bot/Manager.cs | 18 ++++++++++++++++++ Unifiedban.Terminal/CacheData.cs | 3 ++- Unifiedban.Terminal/Unifiedban.Terminal.csproj | 6 +++--- Unifiedban.Terminal/Utils/ConfigTools.cs | 2 +- 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/Unifiedban.Terminal/Bot/Manager.cs b/Unifiedban.Terminal/Bot/Manager.cs index ec62422..2e56be1 100644 --- a/Unifiedban.Terminal/Bot/Manager.cs +++ b/Unifiedban.Terminal/Bot/Manager.cs @@ -370,6 +370,21 @@ private static async Task HandleUpdateAsync(Message message) UserId = -1 }); + if (CacheData.IgnoredChats.Contains(message.Chat.Id)) + { + Logging.AddLog(new SystemLog() + { + LoggerName = CacheData.LoggerName, + Date = DateTime.Now, + Function = "Unifiedban.Bot.Manager.BotClient_OnMessage", + Level = SystemLog.Levels.Debug, + Message = $"Ignoring message of chat {message.Chat.Id}", + UserId = -1 + }); + + return; + } + if(CacheData.Groups.Keys.Contains(message.Chat.Id)) if (CacheData.Groups[message.Chat.Id].State != TelegramGroup.Status.Active && @@ -431,6 +446,9 @@ await BotClient.SendTextMessageAsync(message.Chat.Id, Message = $"Can't send left notification in {message.Chat.Id} due to missing permission.\n\n{ex}", UserId = -1 }); + + if(!CacheData.IgnoredChats.Contains(message.Chat.Id)) + CacheData.IgnoredChats.Add(message.Chat.Id); if (!ex.Message.Contains("kicked")) { diff --git a/Unifiedban.Terminal/CacheData.cs b/Unifiedban.Terminal/CacheData.cs index 67118b8..b650e28 100644 --- a/Unifiedban.Terminal/CacheData.cs +++ b/Unifiedban.Terminal/CacheData.cs @@ -61,7 +61,8 @@ public class CacheData public static ConcurrentDictionary CaptchaAutoKickTimers = new(); public static Dictionary CaptchaStrikes = new(); - + + public static List IgnoredChats = new(); public static List BetaAuthChats = new(); public static string GetTranslation( diff --git a/Unifiedban.Terminal/Unifiedban.Terminal.csproj b/Unifiedban.Terminal/Unifiedban.Terminal.csproj index 7eabe21..5ab8a06 100644 --- a/Unifiedban.Terminal/Unifiedban.Terminal.csproj +++ b/Unifiedban.Terminal/Unifiedban.Terminal.csproj @@ -3,14 +3,14 @@ Exe net5.0 - 3.13.11 + 3.13.12 fabricators Unifiedban Terminal Fabricators 2022 https://github.com/unified-ban/Terminal GIT - 3.13.11 - 3.13.11.2 + 3.13.12 + 3.13.12.3 9 enable diff --git a/Unifiedban.Terminal/Utils/ConfigTools.cs b/Unifiedban.Terminal/Utils/ConfigTools.cs index 063918c..48e70c7 100644 --- a/Unifiedban.Terminal/Utils/ConfigTools.cs +++ b/Unifiedban.Terminal/Utils/ConfigTools.cs @@ -442,7 +442,7 @@ static void LoadRabbitMQManager() Date = DateTime.Now, Function = "ConfigTools.LoadRabbitMQManager", Level = Models.SystemLog.Levels.Info, - Message = "Connecting to RabbitMQ server...", + Message = $"Connecting to RabbitMQ server... {factory.HostName}:{factory.Port}", UserId = -1 }); var conn = factory.CreateConnection();