From 5eb2c0dc27e687bbc0525fc93b54031f7f6d3750 Mon Sep 17 00:00:00 2001 From: Aevann Date: Fri, 11 Aug 2023 16:34:56 +0300 Subject: [PATCH] add !followers --- files/helpers/alerts.py | 8 +++++--- files/helpers/sanitize.py | 3 +++ files/routes/groups.py | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/files/helpers/alerts.py b/files/helpers/alerts.py index bfc856309..cc0b90015 100644 --- a/files/helpers/alerts.py +++ b/files/helpers/alerts.py @@ -164,7 +164,9 @@ def NOTIFY_USERS(text, v, oldtext=None, ghost=False, log_cost=None): elif i.group(1) == 'jannies': group = None member_ids = set([x[0] for x in g.db.query(User.id).filter(User.admin_level > 0, User.id != AEVANN_ID)]) - coin_receivers.update(member_ids) + elif i.group(1) == 'followers': + group = None + member_ids = set([x[0] for x in g.db.query(Follow.user_id).filter_by(target_id=v.id)]) else: group = g.db.get(Group, i.group(1)) if not group: continue @@ -174,7 +176,7 @@ def NOTIFY_USERS(text, v, oldtext=None, ghost=False, log_cost=None): notify_users.update(members) - if ghost or v.id not in member_ids: + if (ghost or v.id not in member_ids) and i.group(1) != 'followers': if group and group.name == 'verifiedrich': abort(403, f"Only !verifiedrich members can mention it!") cost += len(members) * 10 @@ -184,7 +186,7 @@ def NOTIFY_USERS(text, v, oldtext=None, ghost=False, log_cost=None): if log_cost: log_cost.ping_cost = cost - if group and group.name in {'biofoids','neofoids'}: + if i.group(1) in {'biofoids','neofoids','jannies'}: coin_receivers.update(member_ids) if cost: diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index 90ca80249..16d9365a3 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -18,6 +18,7 @@ from files.classes.domains import BannedDomain from files.classes.mod_logs import ModAction from files.classes.notifications import Notification from files.classes.group import Group +from files.classes.follows import Follow from files.helpers.config.const import * from files.helpers.const_stateful import * @@ -487,6 +488,8 @@ def sanitize(sanitized, golden=True, limit_pings=0, showmore=False, count_emojis return f'!{name}' elif name == 'jannies': return f'!{name}' + elif name == 'followers': + return f'!{name}' elif g.db.get(Group, name): return f'!{name}' else: diff --git a/files/routes/groups.py b/files/routes/groups.py index fc45b2089..bc5d7e3eb 100644 --- a/files/routes/groups.py +++ b/files/routes/groups.py @@ -32,7 +32,7 @@ def create_group(v): if not valid_sub_regex.fullmatch(name): return redirect(f"/ping_groups?error=Name does not match the required format!") - if name in {'everyone', 'jannies'} or g.db.get(Group, name): + if name in {'everyone', 'jannies', 'followers'} or g.db.get(Group, name): return redirect(f"/ping_groups?error=This group already exists!") if not v.charge_account('combined', GROUP_COST)[0]: