Files
2023-07-29 15:03:45 +03:00

33 lines
883 B
C#

using System.Threading.Tasks;
using BotFramework.Attributes;
using BotFramework.Enums;
using Kruzya.TelegramBot.Core.Data;
using Kruzya.TelegramBot.Core.Handler;
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!);
}
}