[cm] ability to ban user for an arbitrary period

This commit is contained in:
West14
2022-04-23 21:03:33 +03:00
parent 634695d0d8
commit 5b77ef2b85
6 changed files with 66 additions and 24 deletions
+3 -17
View File
@@ -35,21 +35,8 @@ namespace Kruzya.TelegramBot.Core
return RepliedUser != null && await Bot.CanPunishMember(Chat, From, RepliedUser);
}
#region Bans
protected async Task BanMember(User user, DateTime? banEnd = null, bool sendMessage = true)
{
await BanMember(user.Id, banEnd);
if (sendMessage)
{
await Bot.SendTextMessageAsync(
Chat.Id,
$"{From.ToHtml()} <code>заблокировал</code> {user.ToHtml()} <code>на 7 дней</code>",
disableNotification: true, parseMode: ParseMode.Html);
}
}
protected async Task BanMember(long userId, DateTime? banEnd = null)
protected async Task BanMember(long userId, DateTime banEnd)
{
await Bot.RestrictChatMemberAsync(
Chat.Id,
@@ -58,10 +45,9 @@ namespace Kruzya.TelegramBot.Core
{
CanSendMessages = false
},
banEnd ?? DateTime.Now.AddDays(7)
banEnd
);
}
#endregion
protected async Task<BotUserValue> GetWarnOption(User user)
{