mirror of
https://github.com/Bubuni-Team/telegram-bot.git
synced 2026-07-31 00:29:24 +03:00
Merge pull request #13 from Bubuni-Team/feature/timed-bans
[cm] ability to ban user for an arbitrary period
This commit is contained in:
+3
-17
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user