forked from rDrama/rDrama
make !jannies dynamic
parent
90629ed9e8
commit
f0b51ed2c0
|
@ -164,28 +164,32 @@ def NOTIFY_USERS(text, v, oldtext=None, ghost=False, log_cost=None):
|
||||||
if log_cost:
|
if log_cost:
|
||||||
log_cost.ping_cost = cost
|
log_cost.ping_cost = cost
|
||||||
return 'everyone'
|
return 'everyone'
|
||||||
|
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()])
|
||||||
else:
|
else:
|
||||||
group = g.db.get(Group, i.group(1))
|
group = g.db.get(Group, i.group(1))
|
||||||
if not group: continue
|
if not group: continue
|
||||||
|
member_ids = group.member_ids
|
||||||
|
|
||||||
members = group.member_ids - notify_users - v.all_twoway_blocks
|
members = member_ids - notify_users - v.all_twoway_blocks
|
||||||
|
|
||||||
notify_users.update(members)
|
notify_users.update(members)
|
||||||
|
|
||||||
if ghost or v.id not in group.member_ids:
|
if ghost or v.id not in member_ids:
|
||||||
if group.name == 'biofoids': mul = 20
|
if group and group.name == 'biofoids': mul = 20
|
||||||
else: mul = 10
|
else: mul = 10
|
||||||
|
|
||||||
cost += len(members) * mul
|
cost += len(members) * mul
|
||||||
if cost > v.coins:
|
if cost > v.coins:
|
||||||
abort(403, f"You need {cost} coins to mention these ping groups!")
|
abort(403, f"You need {cost} coins to mention these ping groups!")
|
||||||
|
|
||||||
if log_cost:
|
if log_cost:
|
||||||
log_cost.ping_cost = cost
|
log_cost.ping_cost = cost
|
||||||
|
|
||||||
for user in g.db.query(User).filter(User.id.in_(members)).all():
|
for user in g.db.query(User).filter(User.id.in_(members)).all():
|
||||||
user.pay_account('coins', mul)
|
user.pay_account('coins', mul)
|
||||||
g.db.add(user)
|
g.db.add(user)
|
||||||
|
|
||||||
v.charge_account('coins', cost)
|
v.charge_account('coins', cost)
|
||||||
|
|
||||||
|
|
|
@ -419,6 +419,8 @@ def sanitize(sanitized, golden=True, limit_pings=0, showmore=False, count_emojis
|
||||||
|
|
||||||
if name == 'everyone':
|
if name == 'everyone':
|
||||||
return f'<a href="/users">!{name}</a>'
|
return f'<a href="/users">!{name}</a>'
|
||||||
|
elif name == 'jannies':
|
||||||
|
return f'<a href="/admins">!{name}</a>'
|
||||||
elif g.db.get(Group, name):
|
elif g.db.get(Group, name):
|
||||||
return f'<a href="/!{name}">!{name}</a>'
|
return f'<a href="/!{name}">!{name}</a>'
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -32,7 +32,7 @@ def create_group(v):
|
||||||
if not valid_sub_regex.fullmatch(name):
|
if not valid_sub_regex.fullmatch(name):
|
||||||
return redirect(f"/ping_groups?error=Name does not match the required format!")
|
return redirect(f"/ping_groups?error=Name does not match the required format!")
|
||||||
|
|
||||||
if name == 'everyone' 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!")
|
return redirect(f"/ping_groups?error=This group already exists!")
|
||||||
|
|
||||||
if not v.charge_account('combined', GROUP_COST)[0]:
|
if not v.charge_account('combined', GROUP_COST)[0]:
|
||||||
|
|
Loading…
Reference in New Issue