Files

38 lines
1.1 KiB
C#

using System.Threading.Tasks;
using BotFramework.Attributes;
using BotFramework.Enums;
using Telegram.Bot;
using Telegram.Bot.Types;
namespace West.TelegramBot.ChatManagement.Handler
{
public class Ban : ManagementHandler
{
[Command("ban", CommandParseMode.Both)]
public async Task HandleBan()
{
if (!await CanPunish()) return;
await BanMember(GetVictim());
}
[Command("unban", CommandParseMode.Both)]
public async Task HandleUnban()
{
if (!await CanPunish()) return;
await Bot.RestrictChatMemberAsync(Chat.Id, GetVictim().Id,
new ChatPermissions
{
CanSendMessages = true,
CanChangeInfo = true,
CanInviteUsers = true,
CanPinMessages = true,
CanSendPolls = true,
CanSendMediaMessages = true,
CanSendOtherMessages = true,
CanAddWebPagePreviews = true
});
}
}
}