Whois command. Some refactorings.

This commit is contained in:
West14
2021-12-27 22:53:13 +02:00
parent 9bc08c58b7
commit b91d6cfdb5
6 changed files with 94 additions and 36 deletions
+8 -3
View File
@@ -1,6 +1,9 @@
using System.Threading.Tasks;
#nullable enable
using System.Threading.Tasks;
using BotFramework.Attributes;
using BotFramework.Enums;
using Kruzya.TelegramBot.Core.Data;
using Telegram.Bot;
using Telegram.Bot.Types;
@@ -8,12 +11,14 @@ namespace West.TelegramBot.ChatManagement.Handler
{
public class Ban : ManagementHandler
{
public Ban(CoreContext db) : base(db) {}
[Command("ban", CommandParseMode.Both)]
public async Task HandleBan()
{
if (!await CanPunish()) return;
await BanMember(GetVictim());
await BanMember(RepliedUser!);
}
[Command("unban", CommandParseMode.Both)]
@@ -21,7 +26,7 @@ namespace West.TelegramBot.ChatManagement.Handler
{
if (!await CanPunish()) return;
await Bot.RestrictChatMemberAsync(Chat.Id, GetVictim().Id,
await Bot.RestrictChatMemberAsync(Chat.Id, RepliedUser!.Id,
new ChatPermissions
{
CanSendMessages = true,