Fix unbleeper triggering on bot commands

This commit is contained in:
jetsparrow 2026-04-05 22:08:41 +03:00
parent 65a5c57465
commit 0effb60e58
2 changed files with 5 additions and 0 deletions

View File

@ -52,11 +52,13 @@ public static class StringEx
=> a == b || !char.IsLetterOrDigit(a) || !char.IsLetterOrDigit(b);
static readonly Regex MentionRegex = new Regex("^@[a-zA-Z0-9_]+$", RegexOptions.Compiled);
static readonly Regex TelegramCommandRegex = new Regex("^/[a-zA-Z0-9_]+@?[a-zA-Z0-9_]*", RegexOptions.Compiled);
static readonly Regex EmailPartRegex = new Regex("^\\w+@\\w+$", RegexOptions.Compiled);
static readonly Regex HashTagRegex = new Regex("^#\\w+$", RegexOptions.Compiled);
public static bool IsTelegramMention(string word) => MentionRegex.IsMatch(word);
public static bool IsTelegramCommand(string word) => TelegramCommandRegex.IsMatch(word);
public static bool IsEmailPart(string word) => EmailPartRegex.IsMatch(word);

View File

@ -26,6 +26,9 @@ public class Unbleeper
if (string.IsNullOrWhiteSpace(text))
return null;
if (StringEx.IsTelegramCommand(text))
return null;
text = text.Trim();