remotes/1693045480750635534/spooky-22
Aevann1 2021-09-08 10:53:57 +02:00
parent d55e9e4557
commit 29e99f7ebc
7 changed files with 264 additions and 223 deletions

View File

@ -1,7 +1,7 @@
for theme in ['transparent', 'win98', 'midnight', 'dark', 'light', 'coffee', 'tron', '4chan']:
with open(f"./files/assets/style/{theme}_ff66ac.css", encoding='utf-8') as t:
text = t.read()
for color in ['ff66ac','805ad5','62ca56','38a169','80ffff','2a96f3','62ca56','eb4963','ff0000','f39731','30409f','3e98a7','e4432d','7b9ae4','ec72de','7f8fa6', 'f8db58']:
newtext = text.replace("ff66ac", color).replace("ff4097", color).replace("ff1a83", color).replace("ff3390", color).replace("rgba(255, 102, 172, 0.25)", color)
with open(f"./files/assets/style/{theme}_{color}.css", encoding='utf-8', mode='w') as nt:
nt.write(newtext)
with open(f"./files/assets/style/{theme}_ff66ac.css", encoding='utf-8') as t:
text = t.read()
for color in ['ff66ac','805ad5','62ca56','38a169','80ffff','2a96f3','62ca56','eb4963','ff0000','f39731','30409f','3e98a7','e4432d','7b9ae4','ec72de','7f8fa6', 'f8db58']:
newtext = text.replace("ff66ac", color).replace("ff4097", color).replace("ff1a83", color).replace("ff3390", color).replace("rgba(255, 102, 172, 0.25)", color)
with open(f"./files/assets/style/{theme}_{color}.css", encoding='utf-8', mode='w') as nt:
nt.write(newtext)

View File

@ -3,70 +3,70 @@ from os import environ
site = environ.get("DOMAIN").strip()
SLURS = {
" faggot":" cute twink",
" Faggot":" Cute twink",
" FAGGOT":" CUTE TWINK",
" fag":" cute twink",
" Fag":" Cute twink",
" FAG":" CUTE TWINK",
" kill yourself":" keep yourself safe",
" KILL YOURSELF":" KEEP YOURSELF SAFE",
" nigger":" 🏀",
" Nigger":" 🏀",
" NIGGER":" 🏀",
" pedo":" libertarian",
" Pedo":" Libertarian ",
" PEDO":" LIBERTARIAN ",
" rapist":" male feminist",
" Rapist":" Male feminist",
" RAPIST":" MALE FEMINIST",
" RETARD":" RSLUR",
" steve akins":" penny verity oaken",
" Steve Akins":" Penny Verity Oaken",
" STEVE AKINS":" PENNY VERITY OAKEN",
" trannie":" 🚂🚃🚃",
" Trannie":" 🚂🚃🚃",
" TRANNIE":" 🚂🚃🚃",
" tranny":" 🚂🚃🚃",
" Tranny":" 🚂🚃🚃",
" TRANNY":" 🚂🚃🚃",
" troon":" 🚂🚃🚃",
" Troon":" 🚂🚃🚃",
" TROON":" 🚂🚃🚃",
" NoNewNormal": "HorseDewormerAddicts",
" nonewnormal": "horsedewormeraddicts",
"faggot ":"cute twink ",
"Faggot ":"Cute twink ",
"FAGGOT ":"CUTE TWINK ",
"fag ":"cute twink ",
"Fag ":"Cute twink ",
"FAG ":"CUTE TWINK ",
"kill yourself ":"keep yourself safe ",
"KILL YOURSELF ":"KEEP YOURSELF SAFE ",
"nigger ":"🏀 ",
"Nigger ":"🏀 ",
"NIGGER ":"🏀 ",
"pedo ":"libertarian ",
"Pedo ":"Libertarian ",
"PEDO ":"LIBERTARIAN ",
"rapist ":"male feminist ",
"Rapist ":"Male feminist ",
"RAPIST ":"MALE FEMINIST ",
"RETARD ":"RSLUR ",
"steve akins ":"penny verity oaken ",
"Steve Akins ":"Penny Verity Oaken ",
"STEVE AKINS ":"PENNY VERITY OAKEN ",
"trannie ":"🚂🚃🚃 ",
"Trannie ":"🚂🚃🚃 ",
"TRANNIE ":"🚂🚃🚃 ",
"tranny ":"🚂🚃🚃 ",
"Tranny ":"🚂🚃🚃 ",
"TRANNY ":"🚂🚃🚃 ",
"troon ":"🚂🚃🚃 ",
"Troon ":"🚂🚃🚃 ",
"TROON ":"🚂🚃🚃 ",
"NoNewNormal ": "HorseDewormerAddicts ",
"nonewnormal ": "horsedewormeraddicts "
" faggot":" cute twink",
" Faggot":" Cute twink",
" FAGGOT":" CUTE TWINK",
" fag":" cute twink",
" Fag":" Cute twink",
" FAG":" CUTE TWINK",
" kill yourself":" keep yourself safe",
" KILL YOURSELF":" KEEP YOURSELF SAFE",
" nigger":" 🏀",
" Nigger":" 🏀",
" NIGGER":" 🏀",
" pedo":" libertarian",
" Pedo":" Libertarian ",
" PEDO":" LIBERTARIAN ",
" rapist":" male feminist",
" Rapist":" Male feminist",
" RAPIST":" MALE FEMINIST",
" RETARD":" RSLUR",
" steve akins":" penny verity oaken",
" Steve Akins":" Penny Verity Oaken",
" STEVE AKINS":" PENNY VERITY OAKEN",
" trannie":" 🚂🚃🚃",
" Trannie":" 🚂🚃🚃",
" TRANNIE":" 🚂🚃🚃",
" tranny":" 🚂🚃🚃",
" Tranny":" 🚂🚃🚃",
" TRANNY":" 🚂🚃🚃",
" troon":" 🚂🚃🚃",
" Troon":" 🚂🚃🚃",
" TROON":" 🚂🚃🚃",
" NoNewNormal": "HorseDewormerAddicts",
" nonewnormal": "horsedewormeraddicts",
"faggot ":"cute twink ",
"Faggot ":"Cute twink ",
"FAGGOT ":"CUTE TWINK ",
"fag ":"cute twink ",
"Fag ":"Cute twink ",
"FAG ":"CUTE TWINK ",
"kill yourself ":"keep yourself safe ",
"KILL YOURSELF ":"KEEP YOURSELF SAFE ",
"nigger ":"🏀 ",
"Nigger ":"🏀 ",
"NIGGER ":"🏀 ",
"pedo ":"libertarian ",
"Pedo ":"Libertarian ",
"PEDO ":"LIBERTARIAN ",
"rapist ":"male feminist ",
"Rapist ":"Male feminist ",
"RAPIST ":"MALE FEMINIST ",
"RETARD ":"RSLUR ",
"steve akins ":"penny verity oaken ",
"Steve Akins ":"Penny Verity Oaken ",
"STEVE AKINS ":"PENNY VERITY OAKEN ",
"trannie ":"🚂🚃🚃 ",
"Trannie ":"🚂🚃🚃 ",
"TRANNIE ":"🚂🚃🚃 ",
"tranny ":"🚂🚃🚃 ",
"Tranny ":"🚂🚃🚃 ",
"TRANNY ":"🚂🚃🚃 ",
"troon ":"🚂🚃🚃 ",
"Troon ":"🚂🚃🚃 ",
"TROON ":"🚂🚃🚃 ",
"NoNewNormal ": "HorseDewormerAddicts ",
"nonewnormal ": "horsedewormeraddicts "
}
LONGPOST_REPLIES = ['Wow, you must be a JP fan.', 'This is one of the worst posts I have EVER seen. Delete it.', "No, don't reply like this, please do another wall of unhinged rant please.", '# 😴😴😴', "Ma'am we've been over this before. You need to stop.", "I've known more coherent downies.", "Your pulitzer's in the mail", "That's great and all, but I asked for my burger without cheese.", 'That degree finally paying off', "That's nice sweaty. Why don't you have a seat in the time out corner with Pizzashill until you calm down, then you can have your Capri Sun.", "All them words won't bring your pa back.", "You had a chance to not be completely worthless, but it looks like you threw it away. At least you're consistent.", 'Some people are able to display their intelligence by going on at length on a subject and never actually saying anything. This ability is most common in trades such as politics, public relations, and law. You have impressed me by being able to best them all, while still coming off as an absolute idiot.', "You can type 10,000 characters and you decided that these were the one's that you wanted.", 'Have you owned the libs yet?', "I don't know what you said, because I've seen another human naked.", 'Impressive. Normally people with such severe developmental disabilities struggle to write much more than a sentence or two. He really has exceded our expectations for the writing portion. Sadly the coherency of his writing, along with his abilities in the social skills and reading portions, are far behind his peers with similar disabilities.', "This is a really long way of saying you don't fuck.", "Sorry ma'am, looks like his delusions have gotten worse. We'll have to admit him,", '![](https://i.kym-cdn.com/photos/images/newsfeed/001/038/094/0a1.jpg)', 'If only you could put that energy into your relationships', 'Posts like this is why I do Heroine.', 'still unemployed then?', 'K', 'look im gunna have 2 ask u 2 keep ur giant dumps in the toilet not in my replys 😷😷😷', "Mommy is soooo proud of you, sweaty. Let's put this sperg out up on the fridge with all your other failures.", "Good job bobby, here's a star", "That was a mistake. You're about to find out the hard way why.", 'You sat down and wrote all this shit. You could have done so many other things with your life. What happened to your life that made you decide writing novels of bullshit on rdrama.net was the best option?', "I don't have enough spoons to read this shit", "All those words won't bring daddy back.", 'OUT!']

View File

@ -757,7 +757,7 @@ def ban_user(user_id, v):
kind="exile_user",
user_id=v.id,
target_user_id=user.id,
note=f'reason: "{reason}", duration: {duration}'
note=f'reason: "{reason}", duration: {duration}'
)
g.db.add(ma)

View File

@ -56,51 +56,66 @@ else:
@app.get("/shop")
@auth_required
def shop(v):
return render_template("shop.html", awards=list(AWARDS.values()), v=v)
query = g.db.query(
User.id, User.username, User.patron, User.namecolor,
AwardRelationship.kind.label('last_award_kind'), func.count(AwardRelationship.id).label('last_award_count')
).filter(AwardRelationship.submission_id==None, AwardRelationship.comment_id==None, User.patron > 0) \
.group_by(User.username, User.patron, User.id, User.namecolor, AwardRelationship.kind) \
.order_by(User.patron.desc(), AwardRelationship.kind.desc()) \
.join(User).filter(User.id == v.id).all()
owned = {}
for row in (r._asdict() for r in query):
kind = row['last_award_kind']
if kind in AWARDS.keys():
owned[kind] = (AWARDS[kind], row['last_award_count'])
print(owned.values())
return render_template("shop.html", owned=owned.values(), awards=list(AWARDS.values()), v=v)
@app.post("/buy/<award>")
@auth_required
def buy(v, award):
if award not in AWARDS: abort(400)
price = AWARDS[award]["price"]
print(price)
if v.coins < price: return render_template("shop.html", v=v, error="You don't have enough coins to buy this item.")
v.coins -= price
g.db.add(v)
if award not in AWARDS: abort(400)
price = AWARDS[award]["price"]
print(price)
if v.coins < price: return render_template("shop.html", v=v, error="You don't have enough coins to buy this item.")
v.coins -= price
g.db.add(v)
thing = g.db.query(AwardRelationship).order_by(AwardRelationship.id.desc()).first().id
thing += 1
thing = g.db.query(AwardRelationship).order_by(AwardRelationship.id.desc()).first().id
thing += 1
award = AwardRelationship(id=thing, user_id=v.id, kind=award)
g.db.add(award)
award = AwardRelationship(id=thing, user_id=v.id, kind=award)
g.db.add(award)
return "", 204
return "", 204
def banaward_trigger(post=None, comment=None):
author = post.author if post else comment.author
link = f"[this post]({post.permalink})" if post else f"[this comment]({comment.permalink})"
author = post.author if post else comment.author
link = f"[this post]({post.permalink})" if post else f"[this comment]({comment.permalink})"
if not author.is_suspended:
author.ban(reason="one-day ban award used", days=1)
if not author.is_suspended:
author.ban(reason="one-day ban award used", days=1)
send_notification(NOTIFICATIONS_ACCOUNT, author, f"Your account has been suspended for a day for {link}. It sucked and you should feel bad.")
elif author.unban_utc > 0:
author.unban_utc += 24*60*60
g.db.add(author)
send_notification(NOTIFICATIONS_ACCOUNT, author, f"Your account has been suspended for a day for {link}. It sucked and you should feel bad.")
elif author.unban_utc > 0:
author.unban_utc += 24*60*60
g.db.add(author)
send_notification(NOTIFICATIONS_ACCOUNT, author, f"Your account has been suspended for yet another day for {link}. Seriously man?")
send_notification(NOTIFICATIONS_ACCOUNT, author, f"Your account has been suspended for yet another day for {link}. Seriously man?")
ACTIONS = {
"ban": banaward_trigger
"ban": banaward_trigger
}
ALLOW_MULTIPLE = (
"ban",
"shit",
"stars"
"ban",
"shit",
"stars"
)
@ -108,13 +123,13 @@ ALLOW_MULTIPLE = (
@auth_required
def get_awards(v):
return_value = list(AWARDS.values())
return_value = list(AWARDS.values())
user_awards = v.awards
for val in return_value:
val['owned'] = len([x for x in user_awards if x.kind == val['kind'] and not x.given])
user_awards = v.awards
for val in return_value:
val['owned'] = len([x for x in user_awards if x.kind == val['kind'] and not x.given])
return jsonify(return_value)
return jsonify(return_value)
@app.put("/post/<pid>/awards")
@ -122,64 +137,64 @@ def get_awards(v):
@validate_formkey
def award_post(pid, v):
if v.is_suspended and v.unban_utc == 0:
return {"error": "forbidden"}, 403
if v.is_suspended and v.unban_utc == 0:
return {"error": "forbidden"}, 403
kind = request.form.get("kind", "")
kind = request.form.get("kind", "")
if kind not in AWARDS:
return {"error": "That award doesn't exist."}, 404
if kind not in AWARDS:
return {"error": "That award doesn't exist."}, 404
post_award = g.db.query(AwardRelationship).filter(
and_(
AwardRelationship.kind == kind,
AwardRelationship.user_id == v.id,
AwardRelationship.submission_id == None,
AwardRelationship.comment_id == None
)
).first()
post_award = g.db.query(AwardRelationship).filter(
and_(
AwardRelationship.kind == kind,
AwardRelationship.user_id == v.id,
AwardRelationship.submission_id == None,
AwardRelationship.comment_id == None
)
).first()
if not post_award:
return {"error": "You don't have that award."}, 404
if not post_award:
return {"error": "You don't have that award."}, 404
post = g.db.query(Submission).filter_by(id=pid).first()
post = g.db.query(Submission).filter_by(id=pid).first()
if not post or post.is_banned or post.deleted_utc > 0:
return {"error": "That post doesn't exist or has been deleted or removed."}, 404
if not post or post.is_banned or post.deleted_utc > 0:
return {"error": "That post doesn't exist or has been deleted or removed."}, 404
if post.author_id == v.id:
return {"error": "You can't award yourself."}, 403
if post.author_id == v.id:
return {"error": "You can't award yourself."}, 403
existing_award = g.db.query(AwardRelationship).filter(
and_(
AwardRelationship.submission_id == post.id,
AwardRelationship.user_id == v.id,
AwardRelationship.kind == kind
)
).first()
existing_award = g.db.query(AwardRelationship).filter(
and_(
AwardRelationship.submission_id == post.id,
AwardRelationship.user_id == v.id,
AwardRelationship.kind == kind
)
).first()
if existing_award and kind not in ALLOW_MULTIPLE:
return {"error": "You can't give that award multiple times to the same post."}, 409
if existing_award and kind not in ALLOW_MULTIPLE:
return {"error": "You can't give that award multiple times to the same post."}, 409
post_award.submission_id = post.id
#print(f"give award to pid {post_award.submission_id} ({post.id})")
g.db.add(post_award)
post_award.submission_id = post.id
#print(f"give award to pid {post_award.submission_id} ({post.id})")
g.db.add(post_award)
msg = f"@{v.username} has given your [post]({post.permalink}) the {AWARDS[kind]['title']} Award!"
msg = f"@{v.username} has given your [post]({post.permalink}) the {AWARDS[kind]['title']} Award!"
note = request.form.get("note", "")
if note:
msg += f"\n\n> {note}"
note = request.form.get("note", "")
if note:
msg += f"\n\n> {note}"
send_notification(NOTIFICATIONS_ACCOUNT, post.author, msg)
send_notification(NOTIFICATIONS_ACCOUNT, post.author, msg)
if kind in ACTIONS:
ACTIONS[kind](post=post)
if kind in ACTIONS:
ACTIONS[kind](post=post)
post.author.received_award_count += 1
g.db.add(post.author)
post.author.received_award_count += 1
g.db.add(post.author)
return "", 204
return "", 204
@app.put("/comment/<cid>/awards")
@ -187,113 +202,113 @@ def award_post(pid, v):
@validate_formkey
def award_comment(cid, v):
if v.is_suspended and v.unban_utc == 0:
return {"error": "forbidden"}, 403
if v.is_suspended and v.unban_utc == 0:
return {"error": "forbidden"}, 403
kind = request.form.get("kind", "")
kind = request.form.get("kind", "")
if kind not in AWARDS:
return {"error": "That award doesn't exist."}, 404
if kind not in AWARDS:
return {"error": "That award doesn't exist."}, 404
comment_award = g.db.query(AwardRelationship).filter(
and_(
AwardRelationship.kind == kind,
AwardRelationship.user_id == v.id,
AwardRelationship.submission_id == None,
AwardRelationship.comment_id == None
)
).first()
comment_award = g.db.query(AwardRelationship).filter(
and_(
AwardRelationship.kind == kind,
AwardRelationship.user_id == v.id,
AwardRelationship.submission_id == None,
AwardRelationship.comment_id == None
)
).first()
if not comment_award:
return {"error": "You don't have that award."}, 404
if not comment_award:
return {"error": "You don't have that award."}, 404
c = g.db.query(Comment).filter_by(id=cid).first()
c = g.db.query(Comment).filter_by(id=cid).first()
if not c or c.is_banned or c.deleted_utc > 0:
return {"error": "That comment doesn't exist or has been deleted or removed."}, 404
if not c or c.is_banned or c.deleted_utc > 0:
return {"error": "That comment doesn't exist or has been deleted or removed."}, 404
if c.author_id == v.id:
return {"error": "You can't award yourself."}, 403
if c.author_id == v.id:
return {"error": "You can't award yourself."}, 403
existing_award = g.db.query(AwardRelationship).filter(
and_(
AwardRelationship.comment_id == c.id,
AwardRelationship.user_id == v.id,
AwardRelationship.kind == kind
)
).first()
existing_award = g.db.query(AwardRelationship).filter(
and_(
AwardRelationship.comment_id == c.id,
AwardRelationship.user_id == v.id,
AwardRelationship.kind == kind
)
).first()
if existing_award and kind not in ALLOW_MULTIPLE:
return {"error": "You can't give that award multiple times to the same comment."}, 409
if existing_award and kind not in ALLOW_MULTIPLE:
return {"error": "You can't give that award multiple times to the same comment."}, 409
comment_award.comment_id = c.id
g.db.add(comment_award)
comment_award.comment_id = c.id
g.db.add(comment_award)
msg = f"@{v.username} has given your [comment]({c.permalink}) the {AWARDS[kind]['title']} Award!"
msg = f"@{v.username} has given your [comment]({c.permalink}) the {AWARDS[kind]['title']} Award!"
note = request.form.get("note", "")
if note:
msg += f"\n\n> {note}"
note = request.form.get("note", "")
if note:
msg += f"\n\n> {note}"
send_notification(NOTIFICATIONS_ACCOUNT, c.author, msg)
send_notification(NOTIFICATIONS_ACCOUNT, c.author, msg)
if kind in ACTIONS:
ACTIONS[kind](comment=c)
if kind in ACTIONS:
ACTIONS[kind](comment=c)
c.author.received_award_count += 1
g.db.add(c.author)
c.author.received_award_count += 1
g.db.add(c.author)
return "", 204
return "", 204
@app.get("/admin/user_award")
@auth_required
def admin_userawards_get(v):
if v.admin_level < 6:
abort(403)
if v.admin_level < 6:
abort(403)
return render_template("admin/user_award.html", awards=list(AWARDS.values()), v=v)
return render_template("admin/user_award.html", awards=list(AWARDS.values()), v=v)
@app.post("/admin/user_award")
@auth_required
@validate_formkey
def admin_userawards_post(v):
if v.admin_level < 6:
abort(403)
if v.admin_level < 6:
abort(403)
u = get_user(request.form.get("username", '1'), graceful=False, v=v)
u = get_user(request.form.get("username", '1'), graceful=False, v=v)
awards = []
notify_awards = {}
awards = []
notify_awards = {}
latest = g.db.query(AwardRelationship).order_by(AwardRelationship.id.desc()).first()
thing = latest.id
latest = g.db.query(AwardRelationship).order_by(AwardRelationship.id.desc()).first()
thing = latest.id
for key, value in request.form.items():
if key not in AWARDS:
continue
for key, value in request.form.items():
if key not in AWARDS:
continue
if value:
if value:
if int(value) > 0:
notify_awards[key] = int(value)
if int(value) > 0:
notify_awards[key] = int(value)
for x in range(int(value)):
thing += 1
for x in range(int(value)):
thing += 1
awards.append(AwardRelationship(
id=thing,
user_id=u.id,
kind=key
))
awards.append(AwardRelationship(
id=thing,
user_id=u.id,
kind=key
))
g.db.bulk_save_objects(awards)
text = "You were given the following awards:\n\n"
g.db.bulk_save_objects(awards)
text = "You were given the following awards:\n\n"
for key, value in notify_awards.items():
text += f" - **{value}** {AWARDS[key]['title']} {'Awards' if value != 1 else 'Award'}\n"
for key, value in notify_awards.items():
text += f" - **{value}** {AWARDS[key]['title']} {'Awards' if value != 1 else 'Award'}\n"
send_notification(NOTIFICATIONS_ACCOUNT, u, text)
send_notification(NOTIFICATIONS_ACCOUNT, u, text)
return render_template("admin/user_award.html", awards=list(AWARDS.values()), v=v)
return render_template("admin/user_award.html", awards=list(AWARDS.values()), v=v)

View File

@ -11,12 +11,12 @@ GIPHY_KEY = environ.get('GIPHY_KEY').rstrip()
@app.route("/giphy<path>", methods=["GET"])
def giphy():
searchTerm = request.args.get("searchTerm", "")
limit = int(request.args.get("limit", 48))
if searchTerm and limit:
url = f"https://api.giphy.com/v1/gifs/search?q={searchTerm}&api_key={GIPHY_KEY}&limit={limit}"
elif searchTerm and not limit:
url = f"https://api.giphy.com/v1/gifs/search?q={searchTerm}&api_key={GIPHY_KEY}&limit=48"
else:
url = f"https://api.giphy.com/v1/gifs?api_key={GIPHY_KEY}&limit=48"
return jsonify(requests.get(url).json())
searchTerm = request.args.get("searchTerm", "")
limit = int(request.args.get("limit", 48))
if searchTerm and limit:
url = f"https://api.giphy.com/v1/gifs/search?q={searchTerm}&api_key={GIPHY_KEY}&limit={limit}"
elif searchTerm and not limit:
url = f"https://api.giphy.com/v1/gifs/search?q={searchTerm}&api_key={GIPHY_KEY}&limit=48"
else:
url = f"https://api.giphy.com/v1/gifs?api_key={GIPHY_KEY}&limit=48"
return jsonify(requests.get(url).json())

View File

@ -114,7 +114,7 @@ def log_item(id, v):
@app.route("/sex")
def index():
return render_template("index.html", **{"greeting": "Hello from Flask!"})
return render_template("index.html", **{"greeting": "Hello from Flask!"})
@app.get("/assets/favicon.ico")
def favicon():

View File

@ -33,6 +33,32 @@
<pre></pre>
<pre></pre>
<h5>Owned</h5>
<table class="table table-striped">
<thead class="bg-primary text-white">
<tr>
<th scope="col">Icon</th>
<th scope="col">Title</th>
<th scope="col">Number</th>
</tr>
</thead>
<tbody>
{% for a in awards %}
<tr>
<td><i class="{{a['icon']}} {{a['color']}}" style="font-size: 30px"></i></td>
<td style="font-weight: bold">{{a['title']}}</td>
<td style="font-weight: bold">{{a['price']}}</td>
{% set kind = a['kind'] %}
</tr>
{% endfor %}
</table>
<pre>
</pre>
<h5>Shop</h5>
<table class="table table-striped">