Add ChatManagement commands. Drop appsettings from version control.

This commit is contained in:
West14
2021-12-26 15:40:14 +02:00
parent 685caf52b7
commit 7b37e2f35d
7 changed files with 190 additions and 98 deletions
+38
View File
@@ -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
});
}
}
}