mirror of
https://github.com/Bubuni-Team/telegram-bot.git
synced 2026-07-31 00:29:24 +03:00
Fixes for multiple handlers
This commit is contained in:
@@ -3,6 +3,7 @@ obj/
|
|||||||
/packages/
|
/packages/
|
||||||
|
|
||||||
.idea
|
.idea
|
||||||
|
.vs
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
||||||
appsettings.json
|
appsettings.json
|
||||||
|
|||||||
@@ -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,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}"
|
||||||
|
|||||||
@@ -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"]
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ namespace Kruzya.TelegramBot.CombotAntiSpam
|
|||||||
|
|
||||||
if (canKickMembers)
|
if (canKickMembers)
|
||||||
{
|
{
|
||||||
await Bot.KickChatMemberAsync(Chat, member.Id);
|
await Bot.BanChatMemberAsync(Chat, member.Id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user