pull/183/head
parent
18a6eed714
commit
3bcf4e3d22
|
@ -131,13 +131,7 @@ def execute_snappy(post, v):
|
||||||
elif body == '!pinggroup':
|
elif body == '!pinggroup':
|
||||||
group = g.db.query(Group).order_by(func.random()).first()
|
group = g.db.query(Group).order_by(func.random()).first()
|
||||||
|
|
||||||
group_members = group.member_ids
|
cost = len(group.member_ids) * 10
|
||||||
|
|
||||||
for user in g.db.query(User).filter(User.id.in_(group_members)):
|
|
||||||
user.pay_account('coins', 10)
|
|
||||||
g.db.add(user)
|
|
||||||
|
|
||||||
cost = len(group_members) * 10
|
|
||||||
snappy.charge_account('coins', cost)
|
snappy.charge_account('coins', cost)
|
||||||
|
|
||||||
body = f'!{group.name}'
|
body = f'!{group.name}'
|
||||||
|
|
|
@ -146,7 +146,6 @@ def NOTIFY_USERS(text, v, oldtext=None, ghost=False, log_cost=None):
|
||||||
|
|
||||||
if FEATURES['PING_GROUPS']:
|
if FEATURES['PING_GROUPS']:
|
||||||
cost = 0
|
cost = 0
|
||||||
total_members = set()
|
|
||||||
|
|
||||||
for i in group_mention_regex.finditer(text):
|
for i in group_mention_regex.finditer(text):
|
||||||
if oldtext and i.group(1) in oldtext:
|
if oldtext and i.group(1) in oldtext:
|
||||||
|
@ -157,8 +156,6 @@ def NOTIFY_USERS(text, v, oldtext=None, ghost=False, log_cost=None):
|
||||||
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!")
|
||||||
|
|
||||||
g.db.query(User).options(load_only(User.id)).update({ User.coins: User.coins + 10 })
|
|
||||||
|
|
||||||
v.charge_account('coins', cost)
|
v.charge_account('coins', cost)
|
||||||
if log_cost:
|
if log_cost:
|
||||||
log_cost.ping_cost = cost
|
log_cost.ping_cost = cost
|
||||||
|
@ -182,18 +179,12 @@ def NOTIFY_USERS(text, v, oldtext=None, ghost=False, log_cost=None):
|
||||||
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!")
|
||||||
|
|
||||||
total_members.update(members)
|
|
||||||
|
|
||||||
if log_cost:
|
if log_cost:
|
||||||
log_cost.ping_cost = cost
|
log_cost.ping_cost = cost
|
||||||
|
|
||||||
if total_members:
|
if cost:
|
||||||
g.db.query(User).options(load_only(User.id)).filter(User.id.in_(total_members)).update({ User.coins: User.coins + 10 })
|
|
||||||
|
|
||||||
v.charge_account('coins', cost)
|
v.charge_account('coins', cost)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return notify_users - BOT_IDs - {v.id, 0} - v.all_twoway_blocks
|
return notify_users - BOT_IDs - {v.id, 0} - v.all_twoway_blocks
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue