Spaces:
Running
Running
# 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 | |
import requests | |
import json | |
WHITELIST_WORDS = {"eval", "admin", "bot", "python", "ok", "done", "anti"} | |
def check_anti_word_by_ryzenth(text: str): | |
reason = "" | |
try: | |
response = requests.get( | |
f"https://randydev-ryu-js.hf.space/api/v1/ai/akenox/antievalai-v2?query={text}", | |
headers={"x-api-key": "akeno_UKQEQMt991kh2Ehh7JqJYKapx8CCyeC"} | |
).json() | |
ok = json.loads(response["results"]) | |
if ok.get("reason"): | |
reason += ok["reason"] | |
if ok.get("is_detect") is True: | |
return True, reason | |
return False, reason | |
except (json.decoder.JSONDecodeError, KeyError, TypeError): | |
return False, reason | |
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 | |
) | |
try: | |
text_wo_emoji = emoji_pattern.sub('', text) | |
except TypeError: | |
return False | |
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 |