diff --git a/.gitignore b/.gitignore index ab8486374..62f93df61 100644 --- a/.gitignore +++ b/.gitignore @@ -11,5 +11,4 @@ venv/ .vscode/ .sass-cache/ flask_session/ -marsey_count.json .DS_Store \ No newline at end of file diff --git a/files/helpers/const.py b/files/helpers/const.py index f5c05d2b5..5766e499c 100644 --- a/files/helpers/const.py +++ b/files/helpers/const.py @@ -10,12 +10,6 @@ else: SITE_FULL = 'https://' + SITE if SITE == 'pcmemes.net': CC = "SPLASH MOUNTAIN" else: CC = "COUNTRY CLUB" CC_TITLE = CC.title() - -with open("marsey_list.json", 'r') as f: result = loads(f.read()) -marseys = {} -for k, val in result.items(): - marseys[k] = val['author'] -del result AJ_REPLACEMENTS = { ' your ': " you're ", diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index 0cc2cc094..ac617b2e2 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -178,7 +178,7 @@ def sanitize(sanitized, noimages=False, alert=False, comment=False, edit=False): sanitized = re.sub('\|\|(.*?)\|\|', r'\1', sanitized) if comment: - with open("marsey_count.json", 'r') as f: marsey_count = loads(f.read()) + with open("marseys.json", 'r') as f: marsey_count = loads(f.read()) marseys_used = set() emojis = list(re.finditer("[^a]>\s*(:[!#]{0,2}\w+:\s*)+<\/", sanitized)) @@ -262,8 +262,8 @@ 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] += 1 - with open('marsey_count.json', 'w') as f: dump(marsey_count, f) + if emoji in marsey_count: marsey_count[emoji]["count"] += 1 + with open('marseys.json', 'w') as f: dump(marsey_count, f) return sanitized diff --git a/files/routes/comments.py b/files/routes/comments.py index 9207d3ef4..91326526d 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -170,9 +170,10 @@ def api_comment(v): marsey_dict = list(loads(body.lower()).items()) marsey_key = marsey_dict[0][0] marsey_body = marsey_dict[0][1] - except Exception as e: return {"error": "You didn't follow the format retard"}, 400 - with open("marsey_list.json", 'r') as f: marsey_list = loads(f.read()) - marsey_list[marsey_key] = marsey_body + marseys_body["count"] = 0 + except: return {"error": "You didn't follow the format retard"}, 400 + with open("marseys.json", 'r') as f: marseys = loads(f.read()) + marseys[marsey_key] = marsey_body if v.marseyawarded: marregex = list(re.finditer("^(:[!#]{0,2}m\w+:\s*)+$", body)) @@ -209,7 +210,7 @@ def api_comment(v): elif parent_post.id == 37838: filename = f'files/assets/images/emojis/{marsey_key}.webp' process_image(file, filename, 200) - with open('marsey_list.json', 'w') as f: dump(marsey_list, f) + 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: diff --git a/files/routes/posts.py b/files/routes/posts.py index 1374d5d31..a18c6c7c8 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -1004,8 +1004,10 @@ def submit_post(v): else: body = "wow, a good lawlzpost for once!" elif path.exists(f'snappy_{SITE_NAME}.txt'): with open(f'snappy_{SITE_NAME}.txt', "r") as f: - if request.host == 'pcmemes.net': snappyquotes = f.read().split("{[para]}") - else: snappyquotes = f.read().split("{[para]}") + [f':#{x}:' for x in marseys] + snappyquotes = f.read().split("{[para]}") + if request.host != 'pcmemes.net': + with open("marseys.json", 'r') as f: marseys = loads(f.read()).keys() + snappyquotes += [f':#{x}:' for x in marseys] body = random.choice(snappyquotes) body += "\n\n" diff --git a/files/routes/settings.py b/files/routes/settings.py index 04ac3f6b4..1a965b217 100644 --- a/files/routes/settings.py +++ b/files/routes/settings.py @@ -718,14 +718,14 @@ def settings_css(v): @auth_required def settings_profilecss_get(v): - if v.truecoins < 1000 and not v.patron and v.admin_level == 0 : return f"You must have +1000 truescore or be a paypig to set profile css." + if not v.patron : return f"You must be a paypig to set profile css." return render_template("settings_profilecss.html", v=v) @app.post("/settings/profilecss") @limiter.limit("1/second;30/minute;200/hour;1000/day") @auth_required def settings_profilecss(v): - if v.truecoins < 1000 and not v.patron: return f"You must have +1000 truescore or be a paypig to set profile css." + if not v.patron: return f"You must be a paypig to set profile css." profilecss = request.values.get("profilecss").strip().replace('\\', '').strip()[:4000] v.profilecss = profilecss g.db.add(v) diff --git a/files/routes/static.py b/files/routes/static.py index 96e60efc6..6045dffdd 100644 --- a/files/routes/static.py +++ b/files/routes/static.py @@ -16,14 +16,10 @@ def privacy(v): @app.get("/marseys") @auth_required -def emojis(v): - with open("marsey_count.json", 'r') as f: - marsey_count = loads(f.read()) - marsey_counted = [] - for k, val in marseys.items(): - marsey_counted.append((k, val, marsey_count[k])) - marsey_counted = sorted(marsey_counted, key=lambda x: x[2], reverse=True) - return render_template("marseys.html", v=v, marseys=marsey_counted) +def marseys(v): + with open("marseys.json", 'r') as f: marsey_count = list(loads(f.read()).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) @app.get("/terms") @app.get("/logged_out/terms") @@ -372,7 +368,7 @@ def badges(v): @app.get("/marsey_list") @auth_required def marsey_list(v): - with open("marsey_list.json", 'r') as f: return loads(f.read()) + with open("marseys.json", 'r') as f: return loads(f.read()) @app.get("/blocks") @auth_required diff --git a/files/routes/users.py b/files/routes/users.py index 15af102a1..7de98588c 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -31,9 +31,10 @@ def leaderboard_thread(): if SITE_NAME == 'Drama': users13 = {} - for k, val in marseys.items(): - if val in users13: users13[val] += 1 - else: users13[val] = 1 + with open("marseys.json", 'r') as f: authors = (x for x in loads(f.read()).values()) + for x in authors: + if x["author"] in users13: users13[x["author"]] += 1 + else: users13[x["author"]] = 1 users13.pop('unknown','anton-d') users132 = db.query(User).filter(func.lower(User.username).in_(users13.keys())).all() diff --git a/files/templates/emoji_modal.html b/files/templates/emoji_modal.html index 353f1b777..519b9e6f1 100644 --- a/files/templates/emoji_modal.html +++ b/files/templates/emoji_modal.html @@ -86,7 +86,7 @@ - +