deflector award

remotes/1693045480750635534/spooky-22
Aevann1 2022-03-24 00:42:33 +02:00
parent a01376e687
commit 6fc9de8278
15 changed files with 55 additions and 25 deletions

View File

@ -98,6 +98,7 @@ class User(Base):
sigs_disabled = Column(Boolean)
fish = Column(Boolean)
progressivestack = Column(Integer)
deflector = Column(Integer)
friends = deferred(Column(String))
friends_html = deferred(Column(String))
enemies = deferred(Column(String))

View File

@ -470,6 +470,14 @@ AWARDS = {
"color": "text-blue",
"price": 4000
},
"deflector": {
"kind": "deflector",
"title": "deflector",
"description": "Causes all awards received for the next 10 hours to be deflected back at their giver.",
"icon": "fas fa-shield",
"color": "text-pink",
"price": 7000
},
"grass": {
"kind": "grass",
"title": "Grass",

View File

@ -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![]({badge.path})\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![]({badge.path})\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

View File

@ -271,6 +271,12 @@ def front_all(v, sub=None, subdomain=None):
if badge: g.db.delete(badge)
g.db.commit()
if v.deflector and v.deflector < time.time():
v.deflector = None
send_repeatable_notification(v.id, "Your deflector has expired!")
g.db.add(v)
g.db.commit()
if request.headers.get("Authorization"): return {"data": [x.json for x in posts], "next_exists": next_exists}
return render_template("home.html", v=v, listing=posts, next_exists=next_exists, sort=sort, t=t, page=page, ccmode=ccmode, sub=sub, home=True)

View File

@ -15,7 +15,7 @@
{% if v %}
<style>:root{--primary:#{{v.themecolor}}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?v=186"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?v=30">
<link rel="stylesheet" href="/static/assets/css/main.css?v=187"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?v=30">
{% if v.agendaposter %}
<style>
html {
@ -39,7 +39,7 @@
{% endif %}
{% else %}
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?v=186"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=30">
<link rel="stylesheet" href="/static/assets/css/main.css?v=187"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=30">
{% endif %}
</head>

View File

@ -19,11 +19,6 @@
<div class="text-muted"><span id="{{award.kind}}-owned">{{award.owned}}</span> owned</div>
</a>
{% endfor %}
<a class="card disabled d-md-none" style="border:none">
<i class="fas fa-volume-mute" style="opacity:0"></i>
<div class="pt-2" style="font-weight: bold; font-size: 14px; color:#E1E1E1">&nbsp;</div>
<div class="text-muted">&nbsp;</div>
</a>
</div>
<label id="notelabel" for="note" class="pt-4">Note (optional):</label>
<input autocomplete="off" id="kind" name="kind" value="" hidden>

View File

@ -12,7 +12,7 @@
--primary55:#{{v.themecolor}}55;
}
</style>
<link rel="stylesheet" href="/static/assets/css/main.css?v=186">
<link rel="stylesheet" href="/static/assets/css/main.css?v=187">
<link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?v=30">
{% if v.agendaposter %}
<style>
@ -37,7 +37,7 @@
{% endif %}
{% else %}
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?v=186">
<link rel="stylesheet" href="/static/assets/css/main.css?v=187">
<link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=30">
{% endif %}

View File

@ -6,7 +6,7 @@
{% block content %}
{% if v %}
<style>:root{--primary:#{{v.themecolor}}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?v=186"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?v=30">
<link rel="stylesheet" href="/static/assets/css/main.css?v=187"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?v=30">
{% if v.agendaposter %}
<style>
html {
@ -30,7 +30,7 @@
{% endif %}
{% else %}
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?v=186"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=30">
<link rel="stylesheet" href="/static/assets/css/main.css?v=187"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=30">
{% endif %}
<div class="row justify-content-around">

View File

@ -18,7 +18,7 @@
{% endblock %}
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?v=186">
<link rel="stylesheet" href="/static/assets/css/main.css?v=187">
<link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=30">
</head>

View File

@ -14,7 +14,7 @@
<title>2-Step Login - {{SITE_NAME}}</title>
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?v=186"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=30">
<link rel="stylesheet" href="/static/assets/css/main.css?v=187"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=30">
</head>

View File

@ -34,7 +34,7 @@
<style>:root{--primary:#{{v.themecolor}}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?v=186"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?v=30">
<link rel="stylesheet" href="/static/assets/css/main.css?v=187"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?v=30">
{% if v.agendaposter %}
<style>
html {

View File

@ -39,10 +39,10 @@
{% if v %}
<style>:root{--primary:#{{v.themecolor}}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?v=186"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?v=30">
<link rel="stylesheet" href="/static/assets/css/main.css?v=187"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?v=30">
{% else %}
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?v=186"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=30">
<link rel="stylesheet" href="/static/assets/css/main.css?v=187"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=30">
{% endif %}
</head>

View File

@ -31,7 +31,7 @@
<title>{% if ref_user %}{{ref_user.username}} invites you to {{SITE_NAME}}{% else %}Sign up - {{SITE_NAME}}{% endif %}</title>
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?v=186"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=30">
<link rel="stylesheet" href="/static/assets/css/main.css?v=187"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=30">
</head>

View File

@ -32,7 +32,7 @@
<title>{% if ref_user %}{{ref_user.username}} invites you to {{SITE_NAME}}{% else %}{{SITE_NAME}}{% endif %}</title>
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?v=186"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=30">
<link rel="stylesheet" href="/static/assets/css/main.css?v=187"><link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=30">
</head>

View File

@ -26,7 +26,7 @@
{% block stylesheets %}
{% if v %}
<style>:root{--primary:#{{v.themecolor}}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?v=186"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?v=30">
<link rel="stylesheet" href="/static/assets/css/main.css?v=187"><link rel="stylesheet" href="/static/assets/css/{{v.theme}}.css?v=30">
{% if v.agendaposter %}
<style>
html {
@ -50,7 +50,7 @@
{% endif %}
{% else %}
<style>:root{--primary:#{{config('DEFAULT_COLOR')}}</style>
<link rel="stylesheet" href="/static/assets/css/main.css?v=186">
<link rel="stylesheet" href="/static/assets/css/main.css?v=187">
<link rel="stylesheet" href="/static/assets/css/{{config('DEFAULT_THEME')}}.css?v=30">
{% endif %}
{% endblock %}