anti-eval-bot / helper_regex.py
randydev's picture
_
3d2533e verified
raw
history blame
1.22 kB
# Copyright (C) 2019-2025 TeamKillerX <https://github.com/TeamKillerX>
#
# This file is part of TeamKillerX project,
# and licensed under GNU Affero General Public License v3.
# See the GNU Affero General Public License for more details.
#
# All rights reserved. See COPYING, AUTHORS.
# credits xtdevs
import re
WHITELIST_WORDS = {"eval", "admin", "bot", "python", "ok", "done", "anti"}
def contains_stylish_with_whitelist(text: str) -> bool:
emoji_pattern = re.compile(
"[\U0001F600-\U0001F64F"
"\U0001F300-\U0001F5FF"
"\U0001F680-\U0001F6FF"
"\U0001F1E6-\U0001F1FF"
"\u2600-\u26FF\u2700-\u27BF]+", flags=re.UNICODE
)
text_wo_emoji = emoji_pattern.sub('', text)
words = text_wo_emoji.split()
for word in words:
if word.lower() in WHITELIST_WORDS:
continue
for char in word:
if ord(char) > 127 and not char.isascii():
return True
return False
def is_blocked_markdown_code(message):
pattern = r"(?:python|py|javascript|js|bash|sh|html|go|cpp|c|json)\n.*?"
match = re.search(pattern, message, re.DOTALL | re.IGNORECASE)
if match:
return True
else:
return False