2023-07-29 15:03:45 +03:00
|
|
|
using System.Threading.Tasks;
|
2021-12-26 15:40:14 +02:00
|
|
|
using BotFramework.Attributes;
|
|
|
|
|
using BotFramework.Enums;
|
|
|
|
|
using Kruzya.TelegramBot.Core.Data;
|
2023-07-20 21:22:35 +03:00
|
|
|
using Kruzya.TelegramBot.Core.Handler;
|
2022-05-05 13:26:17 +03:00
|
|
|
using West.TelegramBot.ChatManagement.Service;
|
2021-12-26 15:40:14 +02:00
|
|
|
|
2022-02-14 10:35:28 +02:00
|
|
|
namespace West.TelegramBot.ChatManagement.Handler;
|
|
|
|
|
|
|
|
|
|
public class Warn : CommonHandler
|
2021-12-26 15:40:14 +02:00
|
|
|
{
|
2022-05-05 13:26:17 +03:00
|
|
|
private readonly WarnService _warnService;
|
|
|
|
|
public Warn(CoreContext db, WarnService warnService) : base(db)
|
|
|
|
|
{
|
|
|
|
|
_warnService = warnService;
|
|
|
|
|
}
|
2021-12-27 22:53:13 +02:00
|
|
|
|
2022-02-14 10:35:28 +02:00
|
|
|
[Command("warn", CommandParseMode.Both)]
|
|
|
|
|
public async Task HandleWarn()
|
|
|
|
|
{
|
|
|
|
|
if (!await CanPunish()) return;
|
2022-04-24 22:38:09 +03:00
|
|
|
|
2022-05-05 13:26:17 +03:00
|
|
|
await _warnService.WarnChatUserAsync(Chat, From, RepliedUser!);
|
2022-02-14 10:35:28 +02:00
|
|
|
}
|
2021-12-26 15:40:14 +02:00
|
|
|
|
2022-02-14 10:35:28 +02:00
|
|
|
[Command("unwarn", CommandParseMode.Both)]
|
|
|
|
|
public async Task HandleUnwarn()
|
|
|
|
|
{
|
|
|
|
|
if (!await CanPunish()) return;
|
2021-12-26 15:40:14 +02:00
|
|
|
|
2022-05-05 13:26:17 +03:00
|
|
|
await _warnService.UnWarnChatUserAsync(Chat, From, RepliedUser!);
|
2021-12-26 15:40:14 +02:00
|
|
|
}
|
|
|
|
|
}
|