remotes/1693045480750635534/spooky-22
Aevann1 2022-01-23 17:29:13 +02:00
parent a1c6f02b21
commit 527c9da071
6 changed files with 10 additions and 19 deletions

View File

@ -16,7 +16,6 @@ import time
from sys import stdout
import faulthandler
from json import loads
import atexit
app = Flask(__name__, template_folder='templates')
app.url_map.strict_slashes = False
@ -116,12 +115,4 @@ def after_request(response):
response.headers.add("X-Frame-Options", "deny")
return response
if not cache.get("marseys"):
with open("marseys.json", 'r') as f: cache.set("marseys", loads(f.read()))
from files.routes import *
def close_running_threads():
with open('marseys.json', 'w') as f: dump(cache.get("marseys"), f)
stdout.flush()
atexit.register(close_running_threads)
from files.routes import *

View File

@ -178,7 +178,7 @@ def sanitize(sanitized, noimages=False, alert=False, comment=False, edit=False):
sanitized = re.sub('\|\|(.*?)\|\|', r'<span class="spoiler">\1</span>', sanitized)
if comment:
marsey_count = cache.get("marseys")
with open("marseys.json", 'r') as f: marsey_count = loads(f.read().replace("'",'"'))
marseys_used = set()
emojis = list(re.finditer("[^a]>\s*(:[!#]{0,2}\w+:\s*)+<\/", sanitized))
@ -263,7 +263,7 @@ def sanitize(sanitized, noimages=False, alert=False, comment=False, edit=False):
if comment:
for emoji in marseys_used:
if emoji in marsey_count: marsey_count[emoji]["count"] += 1
cache.set("marseys", marsey_count)
with open('marseys.json', 'w') as f: dump(marsey_count, f)
return sanitized

View File

@ -172,7 +172,7 @@ def api_comment(v):
marsey_body = marsey_dict[0][1]
marsey_body["count"] = 0
except: return {"error": "You didn't follow the format retard"}, 400
marseys = cache.get("marseys")
with open("marseys.json", 'r') as f: marseys = loads(f.read().replace("'",'"'))
marseys[marsey_key] = marsey_body
if v.marseyawarded:
@ -212,7 +212,7 @@ def api_comment(v):
elif v.id in (CARP_ID,AEVANN_ID) and parent_post.id == 37838:
filename = f'files/assets/images/emojis/{marsey_key}.webp'
process_image(file, filename, 200)
cache.set("marseys", marseys)
with open('marseys.json', 'w') as f: dump(marseys, f)
elif file.content_type.startswith('video/'):
file.save("video.mp4")
with open("video.mp4", 'rb') as f:

View File

@ -1008,7 +1008,7 @@ def submit_post(v):
with open(f'snappy_{SITE_NAME}.txt', "r") as f:
snappyquotes = f.read().split("{[para]}")
if request.host != 'pcmemes.net':
marseys = cache.get("marseys").keys()
with open("marseys.json", 'r') as f: marseys = loads(f.read().replace("'",'"')).keys()
snappyquotes += [f':#{x}:' for x in marseys]
body = random.choice(snappyquotes)
body += "\n\n"

View File

@ -17,7 +17,7 @@ def privacy(v):
@app.get("/marseys")
@auth_required
def marseys(v):
marsey_count = cache.get("marseys").items()
with open("marseys.json", 'r') as f: marsey_count = list(loads(f.read().replace("'",'"')).items())
marsey_count = sorted(marsey_count, key=lambda x: list(x[1].values())[2], reverse=True)
return render_template("marseys.html", v=v, marseys=marsey_count)
@ -48,7 +48,7 @@ def participation_stats(v):
day = now - 86400
marseys = cache.get("marseys")
with open("marseys.json", 'r') as f: marseys = loads(f.read().replace("'",'"'))
data = {"marseys": len(marseys),
"users": g.db.query(User.id).count(),
@ -373,7 +373,7 @@ def badges(v):
@app.get("/marsey_list")
@auth_required
def marsey_list(v):
return cache.get("marseys")
with open("marseys.json", 'r') as f: return loads(f.read().replace("'",'"'))
@app.get("/blocks")
@auth_required

View File

@ -31,7 +31,7 @@ def leaderboard_thread():
if SITE_NAME == 'Drama':
users13 = {}
authors = (x for x in cache.get("marseys").values())
with open("marseys.json", 'r') as f: authors = (x for x in loads(f.read().replace("'",'"')).values())
for x in authors:
if x["author"] in users13: users13[x["author"]] += 1
else: users13[x["author"]] = 1