Files

51 lines
1.4 KiB
C#
Raw Permalink Normal View History

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;
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;
namespace West.Entertainment.Handler.Fun
{
public class Bayan : AbstractAnimationReply
{
2022-01-04 17:45:06 +02:00
protected override TimeSpan Cooldown => TimeSpan.Zero;
public Bayan(CoreContext db, ILogger<Bayan> logger, ThreadSafeRandom rng) : base(db, logger, rng) { }
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";
2023-07-29 01:50:28 +03:00
[InChat(InChat.Public)]
[Command("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
2023-07-29 01:50:28 +03:00
[InChat(InChat.Public)]
[Message(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
}
}