make !verifiecdrich a real ping group so ppl are able to leave it

pull/173/head
Aevann 2023-08-02 00:56:13 +03:00
parent 84191d224b
commit 7fd46442d2
4 changed files with 15 additions and 8 deletions

View File

@ -165,11 +165,6 @@ 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).all()])
elif i.group(1) == 'verifiedrich':
if not v.patron:
abort(403, f"Only !verifiedrich members can mention it!")
group = None
member_ids = set([x[0] for x in g.db.query(User.id).filter(User.patron > 0).all()])
else:
group = g.db.get(Group, i.group(1))
if not group: continue
@ -180,6 +175,8 @@ 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 group.name == 'verifiedrich':
abort(403, f"Only !verifiedrich members can mention it!")
cost += len(members) * 10
if cost > v.coins:
abort(403, f"You need {cost} coins to mention these ping groups!")

View File

@ -199,6 +199,15 @@ def _process_timer(attr, badge_ids, text, extra_attrs={}):
for uid in uids:
send_repeatable_notification(uid, text)
if attr == User.patron_utc:
verifiedrich_memberships = g.db.query(GroupMembership).filter(
GroupMembership.user_id.in_(uids),
GroupMembership.group_name == 'verifiedrich'
).all()
for membership in verifiedrich_memberships:
g.db.delete(membership)
def _award_timers_task():
#only awards

View File

@ -420,8 +420,6 @@ def sanitize(sanitized, golden=True, limit_pings=0, showmore=False, count_emojis
return f'<a href="/users">!{name}</a>'
elif name == 'jannies':
return f'<a href="/admins">!{name}</a>'
elif name == 'verifiedrich':
return f'<a href="/h/highrollerclub">!{name}</a>'
elif g.db.get(Group, name):
return f'<a href="/!{name}">!{name}</a>'
else:

View File

@ -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', 'verifiedrich'} or g.db.get(Group, name):
if name in {'everyone', 'jannies'} 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]:
@ -67,6 +67,9 @@ def create_group(v):
def join_group(v, group_name):
group_name = group_name.strip().lower()
if group_name == 'verifiedrich' and not v.patron:
abort(403, f"Only {patron}s can join !verifiedrich")
group = g.db.get(Group, group_name)
if not group: abort(404)
existing = g.db.query(GroupMembership).filter_by(user_id=v.id, group_name=group_name).one_or_none()