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

32 lines
1.0 KiB
C#
Raw Normal View History

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;
2023-07-29 15:14:52 +03:00
namespace West.Entertainment.Handler.Fun;
public class JavaScript : AbstractAnimationReply
{
2023-07-29 15:14:52 +03:00
public JavaScript(CoreContext db, ILogger<JavaScript> logger, ThreadSafeRandom rng) : base(db, logger, rng) { }
2023-07-29 15:14:52 +03:00
protected override Regex AnimationMatch => new(
@"((?<![\w])(жс|js|v8)(?![\w]))|жаваскрипт|javascript|жопаскрипт|жиес|жиэс|nodejs",
RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);
2023-07-29 15:14:52 +03:00
protected override string GetAnimationName() => "javascript";
2023-07-29 01:50:28 +03:00
2023-07-29 15:14:52 +03:00
[InChat(InChat.Public)]
[Command("setjs", CommandParseMode.Both)]
public async Task HandleSetJs()
=> await HandleSetAnimation();
2023-07-29 15:14:52 +03:00
[InChat(InChat.Public)]
[Message(MessageFlag.HasText)]
public async Task HandleJs()
{
await HandleAnimation();
}
}