Fixes for multiple handlers

This commit is contained in:
2021-12-25 20:08:40 +04:00
parent e1c404c660
commit 1b3a4786bf
6 changed files with 8 additions and 8 deletions
+1
View File
@@ -3,6 +3,7 @@ obj/
/packages/ /packages/
.idea .idea
.vs
.DS_Store .DS_Store
appsettings.json appsettings.json
+2 -4
View File
@@ -28,9 +28,9 @@ namespace Kruzya.TelegramBot.Core
} }
[HandleEverything] [HandleEverything]
[Priority(-10)]
public async Task Listener() public async Task Listener()
{ {
Console.WriteLine("handle");
foreach (var message in new Message[] {RawUpdate.Message, RawUpdate.EditedMessage, RawUpdate.ChannelPost, RawUpdate.EditedChannelPost}) foreach (var message in new Message[] {RawUpdate.Message, RawUpdate.EditedMessage, RawUpdate.ChannelPost, RawUpdate.EditedChannelPost})
{ {
if (message == null) if (message == null)
@@ -38,10 +38,8 @@ namespace Kruzya.TelegramBot.Core
continue; continue;
} }
return new Task(); await VerifyChatPair(message);
} }
throw new ArgumentException();
} }
public async Task VerifyChatPair(Message message) public async Task VerifyChatPair(Message message)
+1
View File
@@ -1,5 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Core", "Core\Core.csproj", "{B41CB31A-641E-4079-87ED-5CE310B2D8C1}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Core", "Core\Core.csproj", "{B41CB31A-641E-4079-87ED-5CE310B2D8C1}"
EndProject EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Modules", "Modules", "{C7821F15-DEDD-474F-A575-A296D4B58F10}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Modules", "Modules", "{C7821F15-DEDD-474F-A575-A296D4B58F10}"
+2 -2
View File
@@ -1,5 +1,5 @@
# Build a project # Build a project
FROM mcr.microsoft.com/dotnet/sdk:3.1.416-bullseye-arm64v8 AS build FROM mcr.microsoft.com/dotnet/sdk:5.0.404-buster-slim-arm64v8 AS build
WORKDIR /source WORKDIR /source
# Copy project and perform restoring # Copy project and perform restoring
@@ -20,7 +20,7 @@ RUN dotnet publish -c release -o /app --no-restore Kruzya.TelegramBot.sln && \
rm -f /app/TelegramBot.*.{dll,pdb,json} rm -f /app/TelegramBot.*.{dll,pdb,json}
# Now reuse image with only runtime # Now reuse image with only runtime
FROM mcr.microsoft.com/dotnet/aspnet:3.1.22-alpine3.14-arm64v8 FROM mcr.microsoft.com/dotnet/aspnet:5.0.13-alpine3.14-arm64v8
WORKDIR /user WORKDIR /user
COPY --from=build /app /app COPY --from=build /app /app
ENTRYPOINT ["dotnet", "/app/TelegramBot.dll"] ENTRYPOINT ["dotnet", "/app/TelegramBot.dll"]
+1 -1
View File
@@ -53,7 +53,7 @@ namespace Kruzya.TelegramBot.CombotAntiSpam
if (canKickMembers) if (canKickMembers)
{ {
await Bot.KickChatMemberAsync(Chat, member.Id); await Bot.BanChatMemberAsync(Chat, member.Id);
} }
} }
} }
+1 -1
View File
@@ -49,7 +49,7 @@ namespace Kruzya.TelegramBot.UrlLimitations
{ {
var targetChat = new ChatId(Chat.Id); var targetChat = new ChatId(Chat.Id);
Task.WaitAll(new Task[] { Task.WaitAll(new Task[] {
Bot.KickChatMemberAsync(new ChatId(Chat.Id), From.Id, DateTime.Now.AddDays(1)), Bot.BanChatMemberAsync(new ChatId(Chat.Id), From.Id, DateTime.Now.AddDays(1)),
Bot.DeleteMessageAsync(targetChat, message.MessageId), Bot.DeleteMessageAsync(targetChat, message.MessageId),
Bot.SendTextMessageAsync(targetChat, Bot.SendTextMessageAsync(targetChat,
$"Member {From.ToHtml()} has been banned.\n<b>Reason</b>: <pre>Spam suspicion</pre>", ParseMode.Html) $"Member {From.ToHtml()} has been banned.\n<b>Reason</b>: <pre>Spam suspicion</pre>", ParseMode.Html)