deflector award
This commit is contained in:
parent
35c78209d5
commit
8b813caf29
16 changed files with 56 additions and 26 deletions
|
@ -229,14 +229,20 @@ def award_post(pid, v):
|
|||
if author.id == PIZZASHILL_ID:
|
||||
return {"error": "Pizzashill is immune to awards."}, 403
|
||||
|
||||
if v.id != author.id:
|
||||
if kind == "benefactor" and author.id == v.id:
|
||||
return {"error": "You can't use this award on yourself."}, 400
|
||||
|
||||
if author.deflector:
|
||||
msg = f"@{v.username} has tried to give your [post]({post.shortlink}) the {AWARDS[kind]['title']} Award but it was deflected and applied to them :marseytroll:"
|
||||
send_repeatable_notification(author.id, msg)
|
||||
msg = f"@{author.username} is under the effect of a deflector award; your {AWARDS[kind]['title']} Award has been deflected back to you :marseytroll:"
|
||||
send_repeatable_notification(v.id, msg)
|
||||
author = v
|
||||
elif v.id != author.id:
|
||||
msg = f"@{v.username} has given your [post]({post.shortlink}) the {AWARDS[kind]['title']} Award!"
|
||||
if note: msg += f"\n\n> {note}"
|
||||
send_repeatable_notification(author.id, msg)
|
||||
|
||||
if kind == "benefactor" and author.id == v.id:
|
||||
return {"error": "You can't use this award on yourself."}, 400
|
||||
|
||||
if kind == "ban":
|
||||
link = f"[this post]({post.shortlink})"
|
||||
|
||||
|
@ -402,6 +408,9 @@ def award_post(pid, v):
|
|||
g.db.add(badge)
|
||||
g.db.flush()
|
||||
send_notification(author.id, f"@AutoJanny has given you the following profile badge:\n\n\n\n{badge.name}")
|
||||
elif kind == "deflector":
|
||||
if author.deflector: author.deflector += 36000
|
||||
else: author.deflector = int(time.time()) + 36000
|
||||
|
||||
if author.received_award_count: author.received_award_count += 1
|
||||
else: author.received_award_count = 1
|
||||
|
@ -450,7 +459,13 @@ def award_comment(cid, v):
|
|||
if author.id == PIZZASHILL_ID:
|
||||
return {"error": "Pizzashill is immune to awards."}, 403
|
||||
|
||||
if v.id != author.id:
|
||||
if author.deflector:
|
||||
msg = f"@{v.username} has tried to give your [comment]({c.shortlink}) the {AWARDS[kind]['title']} Award but it was deflected and applied to them :marseytroll:"
|
||||
send_repeatable_notification(author.id, msg)
|
||||
msg = f"@{author.username} is under the effect of a deflector award; your {AWARDS[kind]['title']} Award has been deflected back to you :marseytroll:"
|
||||
send_repeatable_notification(v.id, msg)
|
||||
author = v
|
||||
elif v.id != author.id:
|
||||
msg = f"@{v.username} has given your [comment]({c.shortlink}) the {AWARDS[kind]['title']} Award!"
|
||||
if note: msg += f"\n\n> {note}"
|
||||
send_repeatable_notification(author.id, msg)
|
||||
|
@ -458,6 +473,8 @@ def award_comment(cid, v):
|
|||
if kind == "benefactor" and author.id == v.id:
|
||||
return {"error": "You can't use this award on yourself."}, 400
|
||||
|
||||
if author.deflector: author = v
|
||||
|
||||
if kind == "ban":
|
||||
link = f"[this comment]({c.shortlink})"
|
||||
|
||||
|
@ -620,6 +637,9 @@ def award_comment(cid, v):
|
|||
g.db.add(badge)
|
||||
g.db.flush()
|
||||
send_notification(author.id, f"@AutoJanny has given you the following profile badge:\n\n\n\n{badge.name}")
|
||||
elif kind == "deflector":
|
||||
if author.deflector: author.deflector += 36000
|
||||
else: author.deflector = int(time.time()) + 36000
|
||||
|
||||
if author.received_award_count: author.received_award_count += 1
|
||||
else: author.received_award_count = 1
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue