Merge pull request #13 from Bubuni-Team/feature/timed-bans

[cm] ability to ban user for an arbitrary period
This commit is contained in:
Andriy
2022-04-23 22:06:54 +03:00
committed by GitHub
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)
{