2022-01-02 21:56:14 +02:00
|
|
|
#nullable enable
|
|
|
|
|
|
2022-01-04 17:45:06 +02:00
|
|
|
using System;
|
2022-01-02 21:56:14 +02:00
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using BotFramework.Attributes;
|
|
|
|
|
using BotFramework.Enums;
|
2023-01-17 23:13:06 +02:00
|
|
|
using Kruzya.TelegramBot.Core;
|
2022-01-02 21:56:14 +02:00
|
|
|
using Kruzya.TelegramBot.Core.Data;
|
2022-01-03 15:55:42 +02:00
|
|
|
using Microsoft.Extensions.Logging;
|
2022-01-02 21:56:14 +02:00
|
|
|
using Telegram.Bot;
|
|
|
|
|
|
2023-07-29 15:14:52 +03:00
|
|
|
namespace West.Entertainment.Handler.Fun;
|
|
|
|
|
|
|
|
|
|
public class Bayan : AbstractAnimationReply
|
2022-01-02 21:56:14 +02:00
|
|
|
{
|
2023-07-29 15:14:52 +03:00
|
|
|
protected override TimeSpan Cooldown => TimeSpan.Zero;
|
2022-01-04 17:45:06 +02:00
|
|
|
|
2023-07-29 15:14:52 +03:00
|
|
|
public Bayan(CoreContext db, ILogger<Bayan> logger, ThreadSafeRandom rng) : base(db, logger, rng) { }
|
2022-01-02 21:56:14 +02:00
|
|
|
|
2023-07-29 15:14:52 +03:00
|
|
|
protected override Regex AnimationMatch
|
|
|
|
|
=> new("^баян$", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);
|
2022-01-02 21:56:14 +02:00
|
|
|
|
2023-07-29 15:14:52 +03:00
|
|
|
protected override string GetAnimationName()
|
|
|
|
|
=> "bayan";
|
2023-07-29 01:50:28 +03:00
|
|
|
|
2023-07-29 15:14:52 +03:00
|
|
|
[InChat(InChat.Public)]
|
|
|
|
|
[Command("setbayan", CommandParseMode.Both)]
|
|
|
|
|
public async Task HandleSetBayan()
|
|
|
|
|
=> await HandleSetAnimation();
|
2022-01-02 21:56:14 +02:00
|
|
|
|
2023-07-29 15:14:52 +03:00
|
|
|
[InChat(InChat.Public)]
|
|
|
|
|
[Message(MessageFlag.HasText)]
|
|
|
|
|
public async Task HandleBayan()
|
|
|
|
|
{
|
|
|
|
|
if (await HandleAnimation())
|
2022-01-02 21:56:14 +02:00
|
|
|
{
|
2025-02-09 17:40:03 +02:00
|
|
|
await Bot.DeleteMessage(Chat.Id, Message!.MessageId);
|
2022-01-02 21:56:14 +02:00
|
|
|
}
|
2023-07-29 15:14:52 +03:00
|
|
|
}
|
2022-01-02 21:56:14 +02:00
|
|
|
|
2023-07-29 15:14:52 +03:00
|
|
|
protected override int? GetMessageIdToReply()
|
|
|
|
|
{
|
|
|
|
|
return Message!.ReplyToMessage!.MessageId;
|
|
|
|
|
}
|
2022-01-03 14:58:53 +02:00
|
|
|
|
2023-07-29 15:14:52 +03:00
|
|
|
protected override bool CanHandle()
|
|
|
|
|
=> Message?.ReplyToMessage != null;
|
2022-01-02 21:56:14 +02:00
|
|
|
|
|
|
|
|
}
|