From bc9437497d18a8a40214f3cae6f21a66e39c6a84 Mon Sep 17 00:00:00 2001 From: Aevann Date: Tue, 28 Feb 2023 21:27:38 +0200 Subject: [PATCH] do this https://stupidpol.site/h/countryclub/post/79285/-/3681399#context --- files/helpers/alerts.py | 15 +++++++++++++-- files/helpers/config/const.py | 1 - 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/files/helpers/alerts.py b/files/helpers/alerts.py index a8426dd55..b0f2f7252 100644 --- a/files/helpers/alerts.py +++ b/files/helpers/alerts.py @@ -132,14 +132,25 @@ def NOTIFY_USERS(text, v): if word in text and id not in notify_users: notify_users.add(id) + billed = set() if FEATURES['PING_GROUPS']: for i in group_mention_regex.finditer(text): group = g.db.get(Group, i.group(2)) if group: - if v.id not in group.member_ids and v.admin_level < PERMS['CAN_PING_ALL_GROUPS']: - abort(403, "Only members of the ping group can ping it!") + if v.id not in group.member_ids: + billed.update(group.member_ids) notify_users.update(group.member_ids) + if billed: + cost = len(billed) * 5 + if cost > v.coins: + abort(403, f"You need {cost} coins for this!") + v.coins -= cost + g.db.add(v) + + g.db.query(User).filter(User.id.in_(billed)).update({ User.coins: User.coins + 5 }) + + 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): diff --git a/files/helpers/config/const.py b/files/helpers/config/const.py index f38be9180..cba2b5d04 100644 --- a/files/helpers/config/const.py +++ b/files/helpers/config/const.py @@ -496,7 +496,6 @@ PERMS = { # Minimum admin_level to perform action. 'SEE_GHOST_VOTES': 7, 'MODS_EVERY_HOLE': 8, - 'CAN_PING_ALL_GROUPS': 8, } FEATURES = {