mirror of
https://github.com/Bubuni-Team/telegram-bot.git
synced 2026-07-31 00:29:24 +03:00
Add ChatManagement commands. Drop appsettings from version control.
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
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
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user