From 36779a7ad1269d038a2580c8677a327d6ddba6ae Mon Sep 17 00:00:00 2001 From: HeyMoon Date: Mon, 26 Jun 2023 14:38:48 +0000 Subject: [PATCH] Add the edgy award (and some other goodies) (#157) # The Edgy Award * Makes text bold, italic, and red, symbolizing the fire that burns within. * Adds "fucking" to various places, after articles and prepositional phrases (I think) (tbh I just eyeballed it). EX: He is the fucking best * Adds "motherfucker" and "bitch" to exclamations and questions, respectively. # Goodies * For the queen award: * based => comfy * Xpilled => x vibes * Xmaxxing => normalizing X Co-authored-by: Chuck Sneed Reviewed-on: https://fsdfsd.net/rDrama/rDrama/pulls/157 Co-authored-by: HeyMoon Co-committed-by: HeyMoon --- files/assets/css/main.css | 6 +++++ 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 | 21 ++++++++++++++++++ files/helpers/sanitize.py | 8 +++++++ files/helpers/sharpen.py | 8 +++++++ files/routes/awards.py | 27 ++++++++++++++++++++++- files/routes/comments.py | 4 ++++ files/templates/comments.html | 2 +- files/templates/post.html | 6 ++--- files/templates/post_listing.html | 2 +- migrations/20230625-add-sharpen-award.sql | 1 + schema.sql | 7 ++++++ 15 files changed, 101 insertions(+), 7 deletions(-) create mode 100644 files/helpers/sharpen.py create mode 100644 migrations/20230625-add-sharpen-award.sql diff --git a/files/assets/css/main.css b/files/assets/css/main.css index 4ea54e4c9..32d39f539 100644 --- a/files/assets/css/main.css +++ b/files/assets/css/main.css @@ -6676,6 +6676,12 @@ g { text-transform: lowercase !important; } +.sharpen:not(a) { + color: red !important; + font-weight: bold !important; + font-style: italic !important; +} + .rainbow-text:not(a) > p { color: transparent !important; } 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..2705fcec4 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, [289], "The Sharpen award you received has expired!") _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 878f53700..dfc911e6d 100644 --- a/files/helpers/regex.py +++ b/files/helpers/regex.py @@ -82,8 +82,29 @@ like_before_regex = re.compile('(?<=^|(?<=\s))(?+)', flags=re.I|re.A) +#matches "the" or is, but only if it is not followed by "fucking". https://regex101.com/r/yxuYsQ/2 +the_fucking_regex = re.compile('(?<=^|(?<=\s))((?:the|a)( (?:only))?|((that )?(?:is|are|was|were|will be|would be)( (?:your|her|his|their|no|a|not|to|too|so|this|the|our|what))?( (a|the))?)|is)(?=\s)(?! fucking)', 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('(? like", string) string = like_before_regex.sub(r"like \g<1>", string) + string = redpilled_regex.sub(r"goodpill\g<2>", string) + string = based_and_x_pilled_regex.sub(r"comfy \g<2> vibes", string) + string = based_regex.sub(r"comfy", string) + string = x_pilled_regex.sub(r"\g<2> vibes", string) + string = xmax_regex.sub(r"normalize good \g<2>s", string) + string = xmaxing_regex.sub(r"normalizing good \g<2>s", string) + string = xmaxed_regex.sub(r"normalized good \g<2>s", string) + string = normal_punctuation_regex.sub("", string) string = more_than_one_comma_regex.sub(",", string) if string[-5:] == ', and': diff --git a/files/helpers/sharpen.py b/files/helpers/sharpen.py new file mode 100644 index 000000000..42789b016 --- /dev/null +++ b/files/helpers/sharpen.py @@ -0,0 +1,8 @@ +import re +from files.helpers.regex import * + +def sharpen(string): + string = the_fucking_regex.sub("\g<1> 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..75bad66e5 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=289) + + 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/files/templates/comments.html b/files/templates/comments.html index 3fba23e36..809db9ebb 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -246,7 +246,7 @@ {% endif %} {% set realbody = c.realbody(v) %} -
+
{{realbody | safe}}
{% if c.parent_post or c.wall_user_id %} diff --git a/files/templates/post.html b/files/templates/post.html index 3ca79ad79..8ea6e3213 100644 --- a/files/templates/post.html +++ b/files/templates/post.html @@ -81,13 +81,13 @@ {% if p.realurl(v) and not v_forbid_deleted %}

- + {% if p.flair %}{{p.flair | safe}}{% endif %} {{p.realtitle(v) | safe}}

{% else %} -

+

{% if p.flair %}{{p.flair | safe}}{% endif %} {{p.realtitle(v) | safe}}

@@ -117,7 +117,7 @@ {% endif %} -
+
{% if p.is_image %}
diff --git a/files/templates/post_listing.html b/files/templates/post_listing.html index fcb33d38b..80214ee47 100644 --- a/files/templates/post_listing.html +++ b/files/templates/post_listing.html @@ -208,7 +208,7 @@ {% if not v_forbid_deleted %} {% if p.realbody(v, listing=True) %} -
+
{{p.realbody(v, listing=True) | safe}}
{% endif %} 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: -