From 0015deba7aa7e9731136971899ab975d1960c92a Mon Sep 17 00:00:00 2001 From: Aevann Date: Sat, 18 Feb 2023 18:58:59 +0200 Subject: [PATCH] add !biofoids ping group --- files/helpers/alerts.py | 15 +++++++++++---- files/helpers/config/const.py | 2 ++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/files/helpers/alerts.py b/files/helpers/alerts.py index 26f764dbd..9aa99a9e9 100644 --- a/files/helpers/alerts.py +++ b/files/helpers/alerts.py @@ -112,21 +112,28 @@ def NOTIFY_USERS(text, v): if v.age < NOTIFICATION_SPAM_AGE_THRESHOLD: return set() + text = text.lower() notify_users = set() + for word, id in NOTIFIED_USERS.items(): - if id == 0 or v.id == id: continue - if word in text.lower() and id not in notify_users: notify_users.add(id) + if word in text and id not in notify_users: + notify_users.add(id) + + if '!biofoids' in text: + if v.id not in BIOFOIDS: + abort(403, "Only members of the ping group can ping it!") + notify_users.update(BIOFOIDS) names = set(m.group(2) for m in mention_regex.finditer(text)) for user in get_users(names, graceful=True): if v.id != user.id and not v.any_block_exists(user): notify_users.add(user.id) - if SITE_NAME == "WPD" and 'daisy' in text.lower(): + if SITE_NAME == "WPD" and 'daisy' in text: admin_ids = [x[0] for x in g.db.query(User.id).filter(User.admin_level >= PERMS['NOTIFICATIONS_SPECIFIC_WPD_COMMENTS']).all()] notify_users.update(admin_ids) - return notify_users - bots + return notify_users - bots - {v.id, 0} def push_notif(uids, title, body, url): diff --git a/files/helpers/config/const.py b/files/helpers/config/const.py index 5d69f1c82..59c84b9bb 100644 --- a/files/helpers/config/const.py +++ b/files/helpers/config/const.py @@ -1039,3 +1039,5 @@ AUDIO_FORMATS = ('mp3','wav','ogg','aac','m4a','flac') if not IS_LOCALHOST and SECRET_KEY == DEFAULT_CONFIG_VALUE: from warnings import warn warn("Secret key is the default value! Please change it to a secure random number. Thanks <3", RuntimeWarning) + +BIOFOIDS = {2654,12966,10682,11375,18523,2432,1054,2054,15869,18339,2113}