Files
telegram-bot/modules/Entertainment/Handler/Fun/Bayan.cs
T

45 lines
1.3 KiB
C#
Raw Normal View History

2022-01-02 21:56:14 +02:00
#nullable enable
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using BotFramework.Attributes;
using BotFramework.Enums;
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;
namespace West.Entertainment.Handler.Fun
{
public class Bayan : AbstractAnimationReply
{
2022-01-03 15:55:42 +02:00
public Bayan(CoreContext db, ILogger<Bayan> logger) : base(db, logger) { }
2022-01-02 21:56:14 +02:00
2022-01-03 14:58:53 +02:00
protected override Regex AnimationMatch
=> new("^баян$", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);
2022-01-02 21:56:14 +02:00
2022-01-03 14:58:53 +02:00
protected override string GetAnimationName()
=> "bayan";
2022-01-02 21:56:14 +02:00
[Command(InChat.Public, "setbayan", CommandParseMode.Both)]
2022-01-03 14:58:53 +02:00
public async Task HandleSetBayan()
=> await HandleSetAnimation();
2022-01-02 21:56:14 +02:00
2022-01-03 14:58:53 +02:00
[Message(InChat.Public, MessageFlag.HasText)]
public async Task HandleBayan()
2022-01-02 21:56:14 +02:00
{
if (await HandleAnimation())
2022-01-02 21:56:14 +02:00
{
await Bot.DeleteMessageAsync(Chat.Id, Message!.MessageId);
}
}
2022-01-03 14:58:53 +02:00
protected override int? GetMessageIdToReply()
{
return Message!.ReplyToMessage!.MessageId;
}
protected override bool CanHandle()
=> Message?.ReplyToMessage != null;
2022-01-02 21:56:14 +02:00
}
}