Files
2023-07-29 01:50:28 +03:00

51 lines
1.4 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.DeleteMessageAsync(Chat.Id, Message!.MessageId);
}
}
protected override int? GetMessageIdToReply()
{
return Message!.ReplyToMessage!.MessageId;
}
protected override bool CanHandle()
=> Message?.ReplyToMessage != null;
}
}