fdssfd
This commit is contained in:
parent
722201623a
commit
c0036bceef
6 changed files with 10 additions and 19 deletions
|
@ -16,7 +16,6 @@ import time
|
||||||
from sys import stdout
|
from sys import stdout
|
||||||
import faulthandler
|
import faulthandler
|
||||||
from json import loads
|
from json import loads
|
||||||
import atexit
|
|
||||||
|
|
||||||
app = Flask(__name__, template_folder='templates')
|
app = Flask(__name__, template_folder='templates')
|
||||||
app.url_map.strict_slashes = False
|
app.url_map.strict_slashes = False
|
||||||
|
@ -116,12 +115,4 @@ def after_request(response):
|
||||||
response.headers.add("X-Frame-Options", "deny")
|
response.headers.add("X-Frame-Options", "deny")
|
||||||
return response
|
return response
|
||||||
|
|
||||||
if not cache.get("marseys"):
|
|
||||||
with open("marseys.json", 'r') as f: cache.set("marseys", loads(f.read()))
|
|
||||||
|
|
||||||
from files.routes import *
|
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)
|
|
|
@ -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)
|
sanitized = re.sub('\|\|(.*?)\|\|', r'<span class="spoiler">\1</span>', sanitized)
|
||||||
|
|
||||||
if comment:
|
if comment:
|
||||||
marsey_count = cache.get("marseys")
|
with open("marseys.json", 'r') as f: marsey_count = loads(f.read().replace("'",'"'))
|
||||||
marseys_used = set()
|
marseys_used = set()
|
||||||
|
|
||||||
emojis = list(re.finditer("[^a]>\s*(:[!#]{0,2}\w+:\s*)+<\/", sanitized))
|
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:
|
if comment:
|
||||||
for emoji in marseys_used:
|
for emoji in marseys_used:
|
||||||
if emoji in marsey_count: marsey_count[emoji]["count"] += 1
|
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
|
return sanitized
|
||||||
|
|
||||||
|
|
|
@ -172,7 +172,7 @@ def api_comment(v):
|
||||||
marsey_body = marsey_dict[0][1]
|
marsey_body = marsey_dict[0][1]
|
||||||
marsey_body["count"] = 0
|
marsey_body["count"] = 0
|
||||||
except: return {"error": "You didn't follow the format retard"}, 400
|
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
|
marseys[marsey_key] = marsey_body
|
||||||
|
|
||||||
if v.marseyawarded:
|
if v.marseyawarded:
|
||||||
|
@ -212,7 +212,7 @@ def api_comment(v):
|
||||||
elif v.id in (CARP_ID,AEVANN_ID) and parent_post.id == 37838:
|
elif v.id in (CARP_ID,AEVANN_ID) and parent_post.id == 37838:
|
||||||
filename = f'files/assets/images/emojis/{marsey_key}.webp'
|
filename = f'files/assets/images/emojis/{marsey_key}.webp'
|
||||||
process_image(file, filename, 200)
|
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/'):
|
elif file.content_type.startswith('video/'):
|
||||||
file.save("video.mp4")
|
file.save("video.mp4")
|
||||||
with open("video.mp4", 'rb') as f:
|
with open("video.mp4", 'rb') as f:
|
||||||
|
|
|
@ -1008,7 +1008,7 @@ def submit_post(v):
|
||||||
with open(f'snappy_{SITE_NAME}.txt', "r") as f:
|
with open(f'snappy_{SITE_NAME}.txt', "r") as f:
|
||||||
snappyquotes = f.read().split("{[para]}")
|
snappyquotes = f.read().split("{[para]}")
|
||||||
if request.host != 'pcmemes.net':
|
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]
|
snappyquotes += [f':#{x}:' for x in marseys]
|
||||||
body = random.choice(snappyquotes)
|
body = random.choice(snappyquotes)
|
||||||
body += "\n\n"
|
body += "\n\n"
|
||||||
|
|
|
@ -17,7 +17,7 @@ def privacy(v):
|
||||||
@app.get("/marseys")
|
@app.get("/marseys")
|
||||||
@auth_required
|
@auth_required
|
||||||
def marseys(v):
|
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)
|
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)
|
return render_template("marseys.html", v=v, marseys=marsey_count)
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ def participation_stats(v):
|
||||||
|
|
||||||
day = now - 86400
|
day = now - 86400
|
||||||
|
|
||||||
marseys = cache.get("marseys")
|
with open("marseys.json", 'r') as f: marseys = loads(f.read().replace("'",'"'))
|
||||||
|
|
||||||
data = {"marseys": len(marseys),
|
data = {"marseys": len(marseys),
|
||||||
"users": g.db.query(User.id).count(),
|
"users": g.db.query(User.id).count(),
|
||||||
|
@ -373,7 +373,7 @@ def badges(v):
|
||||||
@app.get("/marsey_list")
|
@app.get("/marsey_list")
|
||||||
@auth_required
|
@auth_required
|
||||||
def marsey_list(v):
|
def marsey_list(v):
|
||||||
return cache.get("marseys")
|
with open("marseys.json", 'r') as f: return loads(f.read().replace("'",'"'))
|
||||||
|
|
||||||
@app.get("/blocks")
|
@app.get("/blocks")
|
||||||
@auth_required
|
@auth_required
|
||||||
|
|
|
@ -31,7 +31,7 @@ def leaderboard_thread():
|
||||||
|
|
||||||
if SITE_NAME == 'Drama':
|
if SITE_NAME == 'Drama':
|
||||||
users13 = {}
|
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:
|
for x in authors:
|
||||||
if x["author"] in users13: users13[x["author"]] += 1
|
if x["author"] in users13: users13[x["author"]] += 1
|
||||||
else: users13[x["author"]] = 1
|
else: users13[x["author"]] = 1
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue