Skip to content

Commit

Permalink
Add temporary chat ignore list used in case of error
Browse files Browse the repository at this point in the history
  • Loading branch information
pietrodicaprio committed Oct 15, 2022
1 parent 5598ba9 commit 0bed14e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
18 changes: 18 additions & 0 deletions Unifiedban.Terminal/Bot/Manager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down Expand Up @@ -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"))
{
Expand Down
3 changes: 2 additions & 1 deletion Unifiedban.Terminal/CacheData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ public class CacheData

public static ConcurrentDictionary<string, Timer> CaptchaAutoKickTimers = new();
public static Dictionary<long, int> CaptchaStrikes = new();


public static List<long> IgnoredChats = new();
public static List<long> BetaAuthChats = new();

public static string GetTranslation(
Expand Down
6 changes: 3 additions & 3 deletions Unifiedban.Terminal/Unifiedban.Terminal.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<Version>3.13.11</Version>
<Version>3.13.12</Version>
<Authors>fabricators</Authors>
<Product>Unifiedban Terminal</Product>
<Copyright>Fabricators 2022</Copyright>
<RepositoryUrl>https://github.com/unified-ban/Terminal</RepositoryUrl>
<RepositoryType>GIT</RepositoryType>
<AssemblyVersion>3.13.11</AssemblyVersion>
<FileVersion>3.13.11.2</FileVersion>
<AssemblyVersion>3.13.12</AssemblyVersion>
<FileVersion>3.13.12.3</FileVersion>
<LangVersion>9</LangVersion>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion Unifiedban.Terminal/Utils/ConfigTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 0bed14e

Please sign in to comment.