Files
telegram-bot/modules/ChatManagement/Handler/Warn.cs
T
2022-05-05 13:26:17 +03:00

35 lines
893 B
C#

#nullable enable
using System.Threading.Tasks;
using BotFramework.Attributes;
using BotFramework.Enums;
using Kruzya.TelegramBot.Core;
using Kruzya.TelegramBot.Core.Data;
using West.TelegramBot.ChatManagement.Service;
namespace West.TelegramBot.ChatManagement.Handler;
public class Warn : CommonHandler
{
private readonly WarnService _warnService;
public Warn(CoreContext db, WarnService warnService) : base(db)
{
_warnService = warnService;
}
[Command("warn", CommandParseMode.Both)]
public async Task HandleWarn()
{
if (!await CanPunish()) return;
await _warnService.WarnChatUserAsync(Chat, From, RepliedUser!);
}
[Command("unwarn", CommandParseMode.Both)]
public async Task HandleUnwarn()
{
if (!await CanPunish()) return;
await _warnService.UnWarnChatUserAsync(Chat, From, RepliedUser!);
}
}