From 508a8f2e854f8902c56326bf108ed644e882129a Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sat, 22 Jan 2022 12:41:37 +0200 Subject: [PATCH] devrama --- badges.json | 262 ++++++++++++++++++++++++++++++++++++++ files/classes/badges.py | 14 +- files/helpers/const.py | 268 +-------------------------------------- files/routes/comments.py | 20 ++- files/routes/static.py | 4 +- 5 files changed, 290 insertions(+), 278 deletions(-) create mode 100644 badges.json diff --git a/badges.json b/badges.json new file mode 100644 index 000000000..76cd1555a --- /dev/null +++ b/badges.json @@ -0,0 +1,262 @@ +{ + "1": { + "name": "Alpha User", + "description": "Joined during open alpha" + }, + "2": { + "name": "Verified Email", + "description": "Verified Email" + }, + "3": { + "name": "Code Contributor", + "description": "Contributed to the site's source code" + }, + "4": { + "name": "White Hat", + "description": "Responsibly reported a security issue" + }, + "6": { + "name": "Beta User", + "description": "Joined during open beta" + }, + "7": { + "name": "Bug Chaser", + "description": "Found a bug" + }, + "10": { + "name": "Bronze Recruiter", + "description": "Recruited 1 friend to join the site" + }, + "11": { + "name": "Silver Recruiter", + "description": "Recruited 10 friends to join the site" + }, + "12": { + "name": "Gold Recruiter", + "description": "Recruited 100 friends to join the site" + }, + "15": { + "name": "Idea Maker", + "description": "Had a good idea for the site which was implemented by the developers" + }, + "16": { + "name": "Marsey Master", + "description": "Contributed 10 (or more!!!!) Marsey emojis ✨" + }, + "17": { + "name": "Marsey Artisan", + "description": "Contributed a Marsey emoji ✨" + }, + "18": { + "name": "Artisan", + "description": "Contributed to site artwork" + }, + "21": { + "name": "Paypig", + "description": "Contributed at least $5" + }, + "22": { + "name": "Renthog", + "description": "Contributed at least $10" + }, + "23": { + "name": "Landchad", + "description": "Contributed at least $20" + }, + "24": { + "name": "Terminally online turboautist", + "description": "Contributed at least $50" + }, + "25": { + "name": "Rich Bich", + "description": "Contributed at least $100" + }, + "26": { + "name": "Rightoid", + "description": "Forced to use the rightoid theme" + }, + "27": { + "name": "Lolcow", + "description": "Beautiful and valid milk provider" + }, + "60": { + "name": "Unironically Retarded", + "description": "Demonstrated a wholesale inability to read the room" + }, + "61": { + "name": "Lab Rat", + "description": "Helped test features in development" + }, + "62": { + "name": "Master Baiter", + "description": "For outstanding achievement in the field of catching fish" + }, + "63": { + "name": "Balls", + "description": "I wrote carp on my balls as a sign of submission" + }, + "64": { + "name": "The Other Kind Of Good Journalist", + "description": "Contributed positive media attention to the site" + }, + "65": { + "name": "2021 Spooooooky Marsey Artist", + "description": "Contributed a VERY SCARY Marsey for Halloween 2021!" + }, + "66": { + "name": "Sk8r Boi", + "description": "Certifies that this user is NOT a poser" + }, + "67": { + "name": "Unpausable", + "description": "Spent 40,000 coins on an unpausable profile anthem" + }, + "68": { + "name": "Pause Button", + "description": "Spent 20,000 coins on a profile anthem pause button" + }, + "69": { + "name": "Little Big Spender", + "description": "Dropped 10,000 coins at the shop" + }, + "70": { + "name": "Big Spender", + "description": "Dropped 100,000 coins at the shop" + }, + "71": { + "name": "Big Big Spender", + "description": "Dropped 250,000 coins at the shop" + }, + "72": { + "name": "Big Big Big Spender", + "description": "Dropped 500,000 coins at the shop" + }, + "73": { + "name": "Le Rich Gentlesir", + "description": "Spent a fucking million coins at the shop" + }, + "74": { + "name": "Grass Toucher", + "description": "Awarded for molesting plant life" + }, + "75": { + "name": "Halloween 21", + "description": "Awarded for surviving Homoween 2021" + }, + "76": { + "name": "Low Roller", + "description": "Bought 10 lootboxes" + }, + "77": { + "name": "Middle Roller", + "description": "Bought 50 lootboxes" + }, + "78": { + "name": "High Roller", + "description": "Bought 150 lootboxes" + }, + "79": { + "name": "Merchant", + "description": "Contributed a new line of product to Marsey's Coin Emporium" + }, + "80": { + "name": "Artist Laureate", + "description": "" + }, + "81": { + "name": "Patron of the Arts", + "description": "Sponsored the creation of an approved Marsey" + }, + "83": { + "name": "All-Seeing Eye", + "description": "Can view private profiles" + }, + "84": { + "name": "Alt-Seeing Eye", + "description": "Can see alts" + }, + "85": { + "name": "Sigma User", + "description": "" + }, + "86": { + "name": "Holly Jolly Marsey Artist", + "description": "Contributed a VERY JOLLY Marsey for Christmas 2021!" + }, + "87": { + "name": "Unblockable", + "description": "This user is unblockable" + }, + "88": { + "name": "Provider", + "description": "This user provided a bountiful feast for Thanksgiving" + }, + "89": { + "name": "Dinner", + "description": "Yes, it is edible" + }, + "90": { + "name": "Fish", + "description": "This user cannot be unfollowed" + }, + "91": { + "name": "Grinch", + "description": "This user is a joyless grinch who pays money to avoid having fun" + }, + "92": { + "name": "NFT Artist", + "description": "Drew a marsey that was used as an NFT" + }, + "93": { + "name": "NFT Owner", + "description": "Bought a marsey NFT" + }, + "94": { + "name": "Progressive Stack Award", + "description": "Upvotes/downvotes on this user's posts and comments have double the ranking effect" + }, + "95": { + "name": "Bird Site Award", + "description": "This user is limited to 140 characters" + }, + "96": { + "name": "Flairlock Award", + "description": "This user's flair has been locked by someone else" + }, + "97": { + "name": "Pizzashill Award", + "description": "This user has to make their posts and comments more than 280 characters" + }, + "98": { + "name": "Marsey Award", + "description": "This user is limited to posting marseys" + }, + "99": { + "name": "Sidebar Artist", + "description": "Contributed artwork featured on the sidebar" + }, + "100": { + "name": "True Believer", + "description": "This user sees through communist lies" + }, + "101": { + "name": "Banner Artist", + "description": "Contributed a banner image to the site" + }, + "102": { + "name": "Christmas 21", + "description": "Awarded for surviving Fistmas 2021" + }, + "103": { + "name": "Benefactor", + "description": "Gave the Benefactor award to someone" + }, + "104": { + "name": "BADASS OUTLAW", + "description": "Bad boy who does not play by the rules" + }, + "105": { + "name": "SCAM", + "description": "lmao get fucked retard" + } +} \ No newline at end of file diff --git a/files/classes/badges.py b/files/classes/badges.py index 8c2d41456..c741241f7 100644 --- a/files/classes/badges.py +++ b/files/classes/badges.py @@ -5,6 +5,7 @@ from os import environ from files.helpers.lazy import lazy from files.helpers.const import * from datetime import datetime +from json import loads class Badge(Base): @@ -24,31 +25,32 @@ class Badge(Base): @property @lazy def badge(self): - return BADGES[self.badge_id] + with open("badges.json", 'r') as f: + return loads(f.read())[str(self.badge_id)] @property @lazy def text(self): if self.name == "Agendaposter": ti = self.user.agendaposter_expires_utc - if ti: text = self.badge['description'] + " until " + datetime.utcfromtimestamp(ti).strftime('%Y-%m-%d %H:%M:%S') - else: text = self.badge['description'] + " permanently" + if ti: text = self.badge["description"] + " until " + datetime.utcfromtimestamp(ti).strftime('%Y-%m-%d %H:%M:%S') + else: text = self.badge["description"] + " permanently" elif self.badge_id in (94,95,96,97,98): if self.badge_id == 94: ti = self.user.progressivestack elif self.badge_id == 95: ti = self.user.bird elif self.badge_id == 96: ti = self.user.flairchanged elif self.badge_id == 97: ti = self.user.longpost else: ti = self.user.marseyawarded - text = self.badge['description'] + " until " + datetime.utcfromtimestamp(ti).strftime('%Y-%m-%d %H:%M:%S') + text = self.badge["description"] + " until " + datetime.utcfromtimestamp(ti).strftime('%Y-%m-%d %H:%M:%S') elif self.description: text = self.description - elif self.badge['description']: text = self.badge['description'] + elif self.badge["description"]: text = self.badge["description"] else: return '' return f' - {text}' @property @lazy def name(self): - return self.badge['name'] + return self.badge["name"] @property @lazy diff --git a/files/helpers/const.py b/files/helpers/const.py index c0559af31..b7fae68ab 100644 --- a/files/helpers/const.py +++ b/files/helpers/const.py @@ -11,8 +11,8 @@ if SITE == 'pcmemes.net': CC = "SPLASH MOUNTAIN" else: CC = "COUNTRY CLUB" CC_TITLE = CC.title() -with open("files/assets/js/emoji_modal.js", 'r') as file: - marseytext = file.read().split('emojis: ')[1].split('cops police"},')[0] + '"}}' +with open("files/assets/js/emoji_modal.js", 'r') as f: + marseytext = f.read().split('emojis: ')[1].split('cops police"},')[0] + '"}}' result = loads(marseytext) marseys = {} @@ -224,269 +224,6 @@ else: PUSHER_ID = environ.get("PUSHER_ID", "").strip() PUSHER_KEY = environ.get("PUSHER_KEY", "").strip() -BADGES = { - 1: { - 'name': 'Alpha User', - 'description': 'Joined during open alpha' - }, - 2: { - 'name': 'Verified Email', - 'description': 'Verified Email' - }, - 3: { - 'name': 'Code Contributor', - 'description': "Contributed to the site's source code" - }, - 4: { - 'name': 'White Hat', - 'description': 'Responsibly reported a security issue' - }, - 6: { - 'name': 'Beta User', - 'description': 'Joined during open beta' - }, - 7: { - 'name': 'Bug Chaser', - 'description': 'Found a bug' - }, - 10: { - 'name': 'Bronze Recruiter', - 'description': 'Recruited 1 friend to join the site' - }, - 11: { - 'name': 'Silver Recruiter', - 'description': 'Recruited 10 friends to join the site' - }, - 12: { - 'name': 'Gold Recruiter', - 'description': 'Recruited 100 friends to join the site' - }, - 15: { - 'name': 'Idea Maker', - 'description': 'Had a good idea for the site which was implemented by the developers' - }, - 16: { - 'name': 'Marsey Master', - 'description': 'Contributed 10 (or more!!!!) Marsey emojis ✨' - }, - 17: { - 'name': 'Marsey Artisan', - 'description': 'Contributed a Marsey emoji ✨' - }, - 18: { - 'name': 'Artisan', - 'description': 'Contributed to site artwork' - }, - 21: { - 'name': 'Paypig', - 'description': 'Contributed at least $5' - }, - 22: { - 'name': 'Renthog', - 'description': 'Contributed at least $10' - }, - 23: { - 'name': 'Landchad', - 'description': 'Contributed at least $20' - }, - 24: { - 'name': 'Terminally online turboautist', - 'description': 'Contributed at least $50' - }, - 25: { - 'name': 'Rich Bich', - 'description': 'Contributed at least $100' - }, - 26: { - 'name': 'Rightoid', - 'description': 'Forced to use the rightoid theme' - }, - 27: { - 'name': 'Lolcow', - 'description': 'Beautiful and valid milk provider' - }, - 60: { - 'name': 'Unironically Retarded', - 'description': 'Demonstrated a wholesale inability to read the room' - }, - 61: { - 'name': 'Lab Rat', - 'description': 'Helped test features in development' - }, - 62: { - 'name': 'Master Baiter', - 'description': 'For outstanding achievement in the field of catching fish' - }, - 63: { - 'name': 'Balls', - 'description': 'I wrote carp on my balls as a sign of submission' - }, - 64: { - 'name': 'The Other Kind Of Good Journalist', - 'description': 'Contributed positive media attention to the site' - }, - 65: { - 'name': '2021 Spooooooky Marsey Artist', - 'description': 'Contributed a VERY SCARY Marsey for Halloween 2021!' - }, - 66: { - 'name': 'Sk8r Boi', - 'description': 'Certifies that this user is NOT a poser' - }, - 67: { - 'name': 'Unpausable', - 'description': 'Spent 40,000 coins on an unpausable profile anthem' - }, - 68: { - 'name': 'Pause Button', - 'description': 'Spent 20,000 coins on a profile anthem pause button' - }, - 69: { - 'name': 'Little Big Spender', - 'description': 'Dropped 10,000 coins at the shop' - }, - 70: { - 'name': 'Big Spender', - 'description': 'Dropped 100,000 coins at the shop' - }, - 71: { - 'name': 'Big Big Spender', - 'description': 'Dropped 250,000 coins at the shop' - }, - 72: { - 'name': 'Big Big Big Spender', - 'description': 'Dropped 500,000 coins at the shop' - }, - 73: { - 'name': 'Le Rich Gentlesir', - 'description': 'Spent a fucking million coins at the shop' - }, - 74: { - 'name': 'Grass Toucher', - 'description': 'Awarded for molesting plant life' - }, - 75: { - 'name': 'Halloween 21', - 'description': 'Awarded for surviving Homoween 2021' - }, - 76: { - 'name': 'Low Roller', - 'description': 'Bought 10 lootboxes' - }, - 77: { - 'name': 'Middle Roller', - 'description': 'Bought 50 lootboxes' - }, - 78: { - 'name': 'High Roller', - 'description': 'Bought 150 lootboxes' - }, - 79: { - 'name': 'Merchant', - 'description': "Contributed a new line of product to Marsey's Coin Emporium" - }, - 80: { - 'name': 'Artist Laureate', - 'description': '' - }, - 81: { - 'name': 'Patron of the Arts', - 'description': 'Sponsored the creation of an approved Marsey' - }, - 83: { - 'name': 'All-Seeing Eye', - 'description': 'Can view private profiles' - }, - 84: { - 'name': 'Alt-Seeing Eye', - 'description': 'Can see alts' - }, - 85: { - 'name': 'Sigma User', - 'description': '' - }, - 86: { - 'name': 'Holly Jolly Marsey Artist', - 'description': 'Contributed a VERY JOLLY Marsey for Christmas 2021!' - }, - 87: { - 'name': 'Unblockable', - 'description': 'This user is unblockable' - }, - 88: { - 'name': 'Provider', - 'description': 'This user provided a bountiful feast for Thanksgiving' - }, - 89: { - 'name': 'Dinner', - 'description': 'Yes, it is edible' - }, - 90: { - 'name': 'Fish', - 'description': 'This user cannot be unfollowed' - }, - 91: { - 'name': 'Grinch', - 'description': 'This user is a joyless grinch who pays money to avoid having fun' - }, - 92: { - 'name': 'NFT Artist', - 'description': 'Drew a marsey that was used as an NFT' - }, - 93: { - 'name': 'NFT Owner', - 'description': 'Bought a marsey NFT' - }, - 94: { - 'name': 'Progressive Stack Award', - 'description': "Upvotes/downvotes on this user's posts and comments have double the ranking effect" - }, - 95: { - 'name': 'Bird Site Award', - 'description': 'This user is limited to 140 characters' - }, - 96: { - 'name': 'Flairlock Award', - 'description': "This user's flair has been locked by someone else" - }, - 97: { - 'name': 'Pizzashill Award', - 'description': 'This user has to make their posts and comments more than 280 characters' - }, - 98: { - 'name': 'Marsey Award', - 'description': 'This user is limited to posting marseys' - }, - 99: { - 'name': 'Sidebar Artist', - 'description': 'Contributed artwork featured on the sidebar' - }, - 100: { - 'name': 'True Believer', - 'description': 'This user sees through communist lies' - }, - 101: { - 'name': 'Banner Artist', - 'description': 'Contributed a banner image to the site' - }, - 102: { - 'name': 'Christmas 21', - 'description': 'Awarded for surviving Fistmas 2021' - }, - 103: { - 'name': 'Benefactor', - 'description': 'Gave the Benefactor award to someone' - }, - 104: { - 'name': 'BADASS OUTLAW', - 'description': 'Bad boy who does not play by the rules' - }, - 105: { - 'name': 'SCAM', - 'description': 'lmao get fucked retard' - }, -} - AWARDS = { "snow": { "kind": "snow", @@ -768,7 +505,6 @@ AWARDS = { "color": "text-gold", "price": 50000 }, - } AWARDS2 = deepcopy(AWARDS) diff --git a/files/routes/comments.py b/files/routes/comments.py index 1025dc1d2..52aff4034 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -10,6 +10,7 @@ from flask import * from files.__main__ import app, limiter from files.helpers.sanitize import filter_emojis_only import requests +from json import loads IMGUR_KEY = environ.get("IMGUR_KEY").strip() @@ -153,10 +154,17 @@ def api_comment(v): else: abort(400) body = request.values.get("body", "").strip()[:10000] - - if v.admin_level == 3 and parent_post.id == 37749: - with open(f"snappy_{SITE_NAME}.txt", "a") as f: - f.write('\n{[para]}\n' + body) + + if v.admin_level == 3: + if parent_post.id == 37749: + with open(f"snappy_{SITE_NAME}.txt", "a") as f: + f.write('\n{[para]}\n' + body) + elif parent_post.id == 56 and request.files["file"]: + try: badge_body = loads(body) + except: return {"error": "You didn't follow the format, retard"} + badge_number = str(len(listdir('files/assets/images/badges'))+1) + with open("badges.json", 'r') as f: badges = loads(f.read()) + badges[badge_number] = badge_body if v.marseyawarded: marregex = list(re.finditer("^(:[!#]{0,2}m\w+:\s*)+$", body)) @@ -186,6 +194,10 @@ def api_comment(v): elif parent_post.id == 37697: filename = 'files/assets/images/Drama/banners/' + str(len(listdir('files/assets/images/Drama/banners'))+1) + '.webp' process_image(file, filename) + elif parent_post.id == 56: + filename = f'files/assets/images/badges/{badge_number}.webp' + process_image(file, filename, 200) + with open('badges.json', 'w') as f: dump(badges, f) elif file.content_type.startswith('video/'): file.save("video.mp4") with open("video.mp4", 'rb') as f: diff --git a/files/routes/static.py b/files/routes/static.py index 879a1a7f8..197ef4689 100644 --- a/files/routes/static.py +++ b/files/routes/static.py @@ -17,8 +17,8 @@ def privacy(v): @app.get("/marseys") @auth_required def emojis(v): - with open("marsey_count.json", 'r') as file: - marsey_count = loads(file.read()) + 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]))