From 3813c0b4cfe483c778ff5e5cf23139695a00f0f2 Mon Sep 17 00:00:00 2001 From: Chuck Sneed Date: Sun, 25 Jun 2023 17:59:36 -0500 Subject: [PATCH] Add the sharpen award --- files/classes/user.py | 1 + files/helpers/config/awards.py | 13 ++++++++++- files/helpers/config/const.py | 1 + files/helpers/cron.py | 1 + files/helpers/regex.py | 7 ++++++ files/helpers/sharpen.py | 8 +++++++ files/routes/awards.py | 27 ++++++++++++++++++++++- files/routes/comments.py | 4 ++++ migrations/20230625-add-sharpen-award.sql | 1 + schema.sql | 7 ++++++ 10 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 files/helpers/sharpen.py create mode 100644 migrations/20230625-add-sharpen-award.sql diff --git a/files/classes/user.py b/files/classes/user.py index af6bd95d4..b8d41608f 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -155,6 +155,7 @@ class User(Base): bite = Column(Integer, default=0) earlylife = Column(Integer, default=0) owoify = Column(Integer, default=0) + sharpen = Column(Integer, default=0) marsify = Column(Integer, default=0) rainbow = Column(Integer, default=0) spider = Column(Integer, default=0) diff --git a/files/helpers/config/awards.py b/files/helpers/config/awards.py index cb19a11b3..72a6523b9 100644 --- a/files/helpers/config/awards.py +++ b/files/helpers/config/awards.py @@ -494,7 +494,6 @@ AWARDS = { "ghost": False, "enabled": SITE_NAME != 'rDrama', }, - "rehab": { "kind": "rehab", "title": "Rehab", @@ -507,6 +506,18 @@ AWARDS = { "ghost": False, "enabled": True, }, + "sharpen": { + "kind": "sharpen", + "title": "Sharpen", + "description": "Adds a badass edge to all user's comments", + "icon": "fas fa-fire", + "color": "text-danger", + "price": 500, + "deflectable": True, + "cosmetic": False, + "ghost": False, + "enabled": True, + }, "flairlock": { "kind": "flairlock", "title": "1-Day Flairlock", diff --git a/files/helpers/config/const.py b/files/helpers/config/const.py index 4c6423b6d..ac6d60eb5 100644 --- a/files/helpers/config/const.py +++ b/files/helpers/config/const.py @@ -1112,6 +1112,7 @@ forced_hats = { "bite": ("Vampire Mask", "When other little girls wanted to be ballet dancers I kind of wanted to be a vampire."), "rainbow": ("Globohomo", "Homosexuality is no longer optional!"), "owoify": ("Cat Ears (wiggly)", "Nuzzles, pounces on you, UwU, you're so warm!.."), + "sharpen": ("Bane Mask", "No one understands..."), "earlylife": ("The Merchant", "SHUT IT DOWN, the goys know!"), "marsify": ("Marsified", "I can't pick my own Marseys, help!"), "is_suspended": ("Behind Bars", "This user is banned and needs to do better!"), diff --git a/files/helpers/cron.py b/files/helpers/cron.py index 3e39b02d4..a060800b5 100644 --- a/files/helpers/cron.py +++ b/files/helpers/cron.py @@ -202,6 +202,7 @@ def _award_timers_task(): _process_timer(User.marseyawarded, [98], "The marsey award you received has expired!") _process_timer(User.rehab, [109], "The rehab award you received has expired!") _process_timer(User.owoify, [167], "The OwOify award you received has expired!") + _process_timer(User.sharpen, [], "The Sharpen award you received has expired!") #TODO: badge _process_timer(User.bite, [168], "The bite award you received has expired! You're now back in your original house!", { User.house: User.old_house, User.old_house: '', diff --git a/files/helpers/regex.py b/files/helpers/regex.py index daa96b50f..452434f77 100644 --- a/files/helpers/regex.py +++ b/files/helpers/regex.py @@ -98,6 +98,13 @@ xmaxed_regex = re.compile('(?<=^|(?<=\s))(([a-zA-Z]+?)(s)?max*ed)(?=$|\n|\s|[.?! xmaxing_regex = re.compile('(?<=^|(?<=\s))(([a-zA-Z]+?)(s)?max*ing)(?=$|\n|\s|[.?!,])', flags=re.I|re.A) initial_part_regex = re.compile('(?<=^)(>+)', flags=re.I|re.A) +#matches "the" or is, but only if it is not followed by "fucking" +the_fucking_regex = re.compile('(?<=^|(?<=\s))(the|is)(?! fucking)(?=$|\n|\s|[.?!,])', flags=re.I|re.A) +#matches a single question mark but only if it isn't preceded by ", bitch" +bitch_question_mark_regex = re.compile('(? fucking", string) + string = bitch_question_mark_regex.sub(", bitch?", string) + string = exclamation_point_regex.sub(", motherfucker!", string) + return string diff --git a/files/routes/awards.py b/files/routes/awards.py index 9b58e0dcd..79f37b3f1 100644 --- a/files/routes/awards.py +++ b/files/routes/awards.py @@ -13,6 +13,7 @@ from files.helpers.config.awards import AWARDS_ENABLED, HOUSE_AWARDS, LOOTBOX_IT from files.helpers.get import * from files.helpers.marsify import marsify from files.helpers.owoify import owoify +from files.helpers.sharpen import sharpen from files.helpers.regex import * from files.helpers.sanitize import filter_emojis_only from files.helpers.useractions import * @@ -330,6 +331,9 @@ def award_thing(v, thing_type, id): if author.owoify: abort(409, f"{safe_username} is under the effect of a conflicting award: OwOify award!") + if author.sharpen: + abort(409, f"{safe_username} is under the effect of a conflicting award: Sharpen!") + if not author.queen: characters = list(filter(str.isalpha, author.username)) if characters: @@ -376,6 +380,9 @@ def award_thing(v, thing_type, id): if author.owoify: abort(409, f"{safe_username} is under the effect of a conflicting award: OwOify award!") + if author.sharpen: + abort(409, f"{safe_username} is under the effect of a conflicting award: Sharpen!") + if author.chud == 1: abort(409, f"{safe_username} is already chudded permanently!") @@ -495,7 +502,8 @@ def award_thing(v, thing_type, id): abort(409, f"{safe_username} is under the effect of a conflicting award: Chud award!") if author.queen: abort(409, f"{safe_username} is under the effect of a conflicting award: Queen award!") - + if author.sharpen: + abort(409, f"{safe_username} is under the effect of a conflicting award: Sharpen!") if not author.marsify or author.marsify != 1: if author.marsify: author.marsify += 86400 else: author.marsify = int(time.time()) + 86400 @@ -527,6 +535,8 @@ def award_thing(v, thing_type, id): abort(409, f"{safe_username} is under the effect of a conflicting award: Chud award!") if author.queen: abort(409, f"{safe_username} is under the effect of a conflicting award: Queen award!") + if author.sharpen: + abort(409, f"{safe_username} is under the effect of a conflicting award: Sharpen!") if author.owoify: author.owoify += 21600 else: author.owoify = int(time.time()) + 21600 @@ -538,6 +548,21 @@ def award_thing(v, thing_type, id): if author.marsify: body = marsify(body) thing.body_html = sanitize(body, limit_pings=5, showmore=True) g.db.add(thing) + elif kind == 'sharpen': + if author.chud: + abort(409, f"{safe_username} is under the effect of a conflicting award: Chud award!") + if author.queen: + abort(409, f"{safe_username} is under the effect of a conflicting award: Queen award!") + + if author.sharpen: author.sharpen += 21600 + else: author.sharpen = int(time.time()) + 21600 + # badge_grant(user=author, badge_id=167) #TODO: badge + + if thing_type == 'comment' and not thing.author.deflector: + body = thing.body + body = sharpen(body) + thing.body_html = sanitize(body, limit_pings=5, showmore=True) + g.db.add(thing) elif ("Femboy" in kind and kind == v.house) or kind == 'rainbow': if author.rainbow: author.rainbow += 86400 else: author.rainbow = int(time.time()) + 86400 diff --git a/files/routes/comments.py b/files/routes/comments.py index ee84d8b3b..96f531c7c 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -14,6 +14,7 @@ from files.helpers.get import * from files.helpers.marsify import marsify from files.helpers.media import * from files.helpers.owoify import owoify +from files.helpers.sharpen import sharpen from files.helpers.regex import * from files.helpers.slots import * from files.helpers.treasure import * @@ -239,6 +240,7 @@ def comment(v:User): body_for_sanitize = body if v.owoify: body_for_sanitize = owoify(body_for_sanitize) if v.marsify: body_for_sanitize = marsify(body_for_sanitize) + if v.sharpen: body_for_sanitize = sharpen(body_for_sanitize) body_html = sanitize(body_for_sanitize, limit_pings=5, showmore=True, count_emojis=not v.marsify) @@ -634,6 +636,8 @@ def edit_comment(cid, v): body_for_sanitize = owoify(body_for_sanitize) if v.marsify: body_for_sanitize = marsify(body_for_sanitize) + if v.sharpen: + body_for_sanitize = sharpen(body_for_sanitize) body_html = sanitize(body_for_sanitize, golden=False, limit_pings=5, showmore=True) diff --git a/migrations/20230625-add-sharpen-award.sql b/migrations/20230625-add-sharpen-award.sql new file mode 100644 index 000000000..5081da601 --- /dev/null +++ b/migrations/20230625-add-sharpen-award.sql @@ -0,0 +1 @@ +alter table users add column sharpen integer; \ No newline at end of file diff --git a/schema.sql b/schema.sql index 4603ca0e9..90a25b3d7 100644 --- a/schema.sql +++ b/schema.sql @@ -236,6 +236,7 @@ CREATE TABLE public.users ( bite integer, old_house character varying(16), owoify integer, + sharpen integer, marsify integer, is_muted boolean DEFAULT false NOT NULL, coins_spent_on_hats integer DEFAULT 0 NOT NULL, @@ -2280,6 +2281,12 @@ CREATE INDEX users_original_username_trgm_idx ON public.users USING gin (origina CREATE INDEX users_owoify_idx ON public.users USING btree (owoify); +-- +-- Name: users_edgified_idx; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX users_edgified_idx ON public.users USING btree (sharpen); + -- -- Name: users_patron_utc_idx; Type: INDEX; Schema: public; Owner: -