mirror of
https://github.com/Jetsparrow/antiantiswearingbot.git
synced 2026-04-26 05:55:05 +03:00
Fix unbleeper triggering on bot commands
This commit is contained in:
parent
65a5c57465
commit
0effb60e58
@ -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);
|
||||
|
||||
|
||||
@ -26,6 +26,9 @@ public class Unbleeper
|
||||
if (string.IsNullOrWhiteSpace(text))
|
||||
return null;
|
||||
|
||||
if (StringEx.IsTelegramCommand(text))
|
||||
return null;
|
||||
|
||||
text = text.Trim();
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user