mirror of
https://github.com/Bubuni-Team/telegram-bot.git
synced 2026-07-31 00:29:24 +03:00
46 lines
1.2 KiB
C#
46 lines
1.2 KiB
C#
#nullable enable
|
|
|
|
using System.Threading.Tasks;
|
|
using BotFramework.Attributes;
|
|
using BotFramework.Enums;
|
|
using Kruzya.TelegramBot.Core;
|
|
using Kruzya.TelegramBot.Core.Data;
|
|
using Kruzya.TelegramBot.Core.Extensions;
|
|
using Telegram.Bot;
|
|
using Telegram.Bot.Types;
|
|
|
|
namespace West.TelegramBot.ChatManagement.Handler;
|
|
|
|
public class Ban : CommonHandler
|
|
{
|
|
public Ban(CoreContext db) : base(db) {}
|
|
|
|
[Command("ban", CommandParseMode.Both)]
|
|
public async Task HandleBan()
|
|
{
|
|
if (!await CanPunish()) return;
|
|
|
|
await BanMember(RepliedUser!);
|
|
}
|
|
|
|
[Command("unban", CommandParseMode.Both)]
|
|
public async Task HandleUnban()
|
|
{
|
|
if (!await CanPunish()) return;
|
|
|
|
await Bot.RestrictChatMemberAsync(Chat.Id, RepliedUser!.Id,
|
|
new ChatPermissions
|
|
{
|
|
CanSendMessages = true,
|
|
CanChangeInfo = true,
|
|
CanInviteUsers = true,
|
|
CanPinMessages = true,
|
|
CanSendPolls = true,
|
|
CanSendMediaMessages = true,
|
|
CanSendOtherMessages = true,
|
|
CanAddWebPagePreviews = true
|
|
});
|
|
|
|
await Reply($"{From.ToHtml()} <code>разблокировал</code> {RepliedUser!.ToHtml()}");
|
|
}
|
|
} |