From 386e55a74880d726e73fd8c6c7e49266c710c15b Mon Sep 17 00:00:00 2001 From: Aevann Date: Fri, 26 Apr 2024 02:27:06 +0300 Subject: [PATCH] add word alert regex --- files/helpers/alerts.py | 6 +++++- files/helpers/regex.py | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/files/helpers/alerts.py b/files/helpers/alerts.py index feec5b991..23168cdfd 100644 --- a/files/helpers/alerts.py +++ b/files/helpers/alerts.py @@ -169,7 +169,11 @@ def NOTIFY_USERS(text, v, oldtext=None, ghost=False, obj=None, followers_ping=Tr user_ids = get_users(names, ids_only=True, graceful=True) notify_users.update(user_ids) - if SITE_NAME == "WPD" and (('daisy' in text and 'destruction' in text) or ('kill myself' in text and obj and isinstance(obj, Post))): + if SITE_NAME == "WPD" and ( + ('daisy' in text and 'destruction' in text) + or ('kill myself' in text and obj and isinstance(obj, Post)) + or word_alert_regex.search(text) + ): admin_ids = [x[0] for x in g.db.query(User.id).filter(User.admin_level >= PERMS['NOTIFICATIONS_SPECIFIC_WPD_COMMENTS'], User.id != AEVANN_ID)] notify_users.update(admin_ids) diff --git a/files/helpers/regex.py b/files/helpers/regex.py index a3a6a024f..bc748206a 100644 --- a/files/helpers/regex.py +++ b/files/helpers/regex.py @@ -161,6 +161,8 @@ html_title_regex = re.compile("(.{1,200})", flags=re.I) excessive_css_scale_regex = re.compile("scale\([^)]*?(\d{2})", flags=re.A) +word_alert_regex = re.compile(r'\b(764|o9a|9 angles|hurtcore|pthc)\b', flags=re.A|re.I) + commands = { "fortune": FORTUNE_REPLIES, "factcheck": FACTCHECK_REPLIES,