refactor(ban): use ctors with def values to ban\unban

This commit is contained in:
Andriy
2025-03-23 12:03:26 +02:00
parent 71fa49ad52
commit 5ad7b7d453
2 changed files with 2 additions and 22 deletions
+1 -4
View File
@@ -41,10 +41,7 @@ public abstract class CommonHandler : BotEventHandler
await Bot.RestrictChatMember(
Chat.Id,
userId,
new ChatPermissions
{
CanSendMessages = false
},
new ChatPermissions(),
untilDate: banEnd
);
}
+1 -18
View File
@@ -60,25 +60,8 @@ public class Ban : CommonHandler
return;
}
// TODO: in Telegram.Bot >=22.4.0 this could be replaced with new ChatPermissions(true)
await Bot.RestrictChatMember(Chat.Id, RepliedUser!.Id,
new ChatPermissions
{
CanSendMessages = true,
CanAddWebPagePreviews = true,
CanChangeInfo = true,
CanInviteUsers = true,
CanManageTopics = true,
CanPinMessages = true,
CanSendAudios = true,
CanSendDocuments = true,
CanSendOtherMessages = true,
CanSendPhotos = true,
CanSendPolls = true,
CanSendVideos = true,
CanSendVideoNotes = true,
CanSendVoiceNotes = true,
});
new ChatPermissions(true));
await Reply($"{From.ToHtml()} <code>разблокировал</code> {RepliedUser!.ToHtml()}");
}