mirror of
https://github.com/Bubuni-Team/telegram-bot.git
synced 2026-07-31 00:29:24 +03:00
50 lines
1.3 KiB
C#
50 lines
1.3 KiB
C#
#nullable enable
|
|
|
|
using System;
|
|
using System.Text.RegularExpressions;
|
|
using System.Threading.Tasks;
|
|
using BotFramework.Attributes;
|
|
using BotFramework.Enums;
|
|
using Kruzya.TelegramBot.Core;
|
|
using Kruzya.TelegramBot.Core.Data;
|
|
using Microsoft.Extensions.Logging;
|
|
using Telegram.Bot;
|
|
|
|
namespace West.Entertainment.Handler.Fun;
|
|
|
|
public class Bayan : AbstractAnimationReply
|
|
{
|
|
protected override TimeSpan Cooldown => TimeSpan.Zero;
|
|
|
|
public Bayan(CoreContext db, ILogger<Bayan> logger, ThreadSafeRandom rng) : base(db, logger, rng) { }
|
|
|
|
protected override Regex AnimationMatch
|
|
=> new("^баян$", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);
|
|
|
|
protected override string GetAnimationName()
|
|
=> "bayan";
|
|
|
|
[InChat(InChat.Public)]
|
|
[Command("setbayan", CommandParseMode.Both)]
|
|
public async Task HandleSetBayan()
|
|
=> await HandleSetAnimation();
|
|
|
|
[InChat(InChat.Public)]
|
|
[Message(MessageFlag.HasText)]
|
|
public async Task HandleBayan()
|
|
{
|
|
if (await HandleAnimation())
|
|
{
|
|
await Bot.DeleteMessage(Chat.Id, Message!.MessageId);
|
|
}
|
|
}
|
|
|
|
protected override int? GetMessageIdToReply()
|
|
{
|
|
return Message!.ReplyToMessage!.MessageId;
|
|
}
|
|
|
|
protected override bool CanHandle()
|
|
=> Message?.ReplyToMessage != null;
|
|
|
|
} |