diff --git a/files/classes/hole.py b/files/classes/hole.py index cd9a44e37..7ad09a2cb 100644 --- a/files/classes/hole.py +++ b/files/classes/hole.py @@ -24,6 +24,10 @@ class Hole(Base): css = deferred(Column(VARCHAR(CSS_LENGTH_LIMIT))) stealth = Column(Boolean) created_utc = Column(Integer) + if SITE_NAME == 'WPD': + snappy_quotes = None + else: + snappy_quotes = deferred(Column(VARCHAR(HOLE_SNAPPY_QUOTES_LENGTH))) blocks = relationship("HoleBlock", primaryjoin="HoleBlock.hole==Hole.name") followers = relationship("HoleFollow", primaryjoin="HoleFollow.hole==Hole.name") diff --git a/files/helpers/actions.py b/files/helpers/actions.py index 11aea811b..e4bf16994 100644 --- a/files/helpers/actions.py +++ b/files/helpers/actions.py @@ -62,7 +62,10 @@ def execute_snappy(post, v): post_ping_group_count = len(list(group_mention_regex.finditer(post.body))) - if SITE_NAME == 'WPD' and ('killing myself' in post.title.lower() or (post.hole != 'suicide' and 'suicide' in post.title.lower())): + if post.hole and post.hole_obj.snappy_quotes: + quotes = post.hole_obj.snappy_quotes.split("[para]") + body = random.choice(quotes).strip() + elif SITE_NAME == 'WPD' and ('killing myself' in post.title.lower() or (post.hole != 'suicide' and 'suicide' in post.title.lower())): body = "https://i.watchpeopledie.tv/images/1697382435294321.webp" elif post_ping_group_count > 3: body = "Unnecessary and uncalled for ping :marseydownvotemad: two more strikes and you're getting blocked + megadownvoted buddy, don't test your luck" diff --git a/files/helpers/config/const.py b/files/helpers/config/const.py index 1ced9edaf..a3ab3668b 100644 --- a/files/helpers/config/const.py +++ b/files/helpers/config/const.py @@ -406,6 +406,7 @@ POST_SORTS = COMMENT_SORTS | { HOLE_NAME_COLUMN_LENGTH = 25 HOLE_SIDEBAR_COLUMN_LENGTH = 10000 HOLE_SIDEBAR_HTML_COLUMN_LENGTH = 20000 +HOLE_SNAPPY_QUOTES_LENGTH = 20000 HOLE_SIDEBAR_URL_COLUMN_LENGTH = 60 HOLE_BANNER_URL_COLUMN_LENGTH = 60 HOLE_MARSEY_URL_LENGTH = 60 diff --git a/files/helpers/config/holeaction_types.py b/files/helpers/config/holeaction_types.py index a85b04ec0..2cbe2727f 100644 --- a/files/helpers/config/holeaction_types.py +++ b/files/helpers/config/holeaction_types.py @@ -39,6 +39,11 @@ HOLEACTION_TYPES = { "icon": 'fa-columns', "color": 'bg-primary' }, + 'edit_snappy_quotes': { + "str": 'edited snappy quotes', + "icon": 'fa-robot', + "color": 'bg-primary' + }, 'edit_css': { "str": 'edited the css', "icon": 'fa-css3-alt', diff --git a/files/routes/holes.py b/files/routes/holes.py index 0e2a8a1b1..0935cd8bd 100644 --- a/files/routes/holes.py +++ b/files/routes/holes.py @@ -438,7 +438,7 @@ def kick(v, pid): def hole_settings(v, hole): hole = get_hole(hole) if not v.mods_hole(hole.name): abort(403) - return render_template('hole/settings.html', v=v, sidebar=hole.sidebar, hole=hole, css=hole.css) + return render_template('hole/settings.html', v=v, sidebar=hole.sidebar, hole=hole, css=hole.css, snappy_quotes=hole.snappy_quotes) @app.post('/h//sidebar') @@ -970,3 +970,32 @@ def hole_log_item(id, v, hole): types = HOLEACTION_TYPES return render_template("log.html", v=v, actions=[action], total=1, page=1, action=action, admins=mods, types=types, hole=hole, single_user_url='mod') + +@app.post('/h//snappy_quotes') +@limiter.limit('1/second', scope=rpath) +@limiter.limit('1/second', scope=rpath, key_func=get_ID) +@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400) +@limiter.limit(DEFAULT_RATELIMIT, deduct_when=lambda response: response.status_code < 400, key_func=get_ID) +@auth_required +def post_hole_snappy_quotes(v, hole): + hole = get_hole(hole) + snappy_quotes = request.values.get('snappy_quotes', '').strip() + + if not hole: abort(404) + if not v.mods_hole(hole.name): abort(403) + if v.shadowbanned: abort(400) + + if len(snappy_quotes) > HOLE_SNAPPY_QUOTES_LENGTH: + abort(400, f"Hole Snappy Quotes are too long (max {HOLE_SNAPPY_QUOTES_LENGTH} characters)") + + hole.snappy_quotes = snappy_quotes + g.db.add(hole) + + ma = HoleAction( + hole=hole.name, + kind='edit_snappy_quotes', + user_id=v.id + ) + g.db.add(ma) + + return {"message": "Snappy quotes edited successfully!"} diff --git a/files/routes/jinja2.py b/files/routes/jinja2.py index 2dd7af8ee..415260406 100644 --- a/files/routes/jinja2.py +++ b/files/routes/jinja2.py @@ -158,6 +158,6 @@ def inject_constants(): "MAX_IMAGE_AUDIO_SIZE_MB":MAX_IMAGE_AUDIO_SIZE_MB, "MAX_IMAGE_AUDIO_SIZE_MB_PATRON":MAX_IMAGE_AUDIO_SIZE_MB_PATRON, "MAX_VIDEO_SIZE_MB":MAX_VIDEO_SIZE_MB, "MAX_VIDEO_SIZE_MB_PATRON":MAX_VIDEO_SIZE_MB_PATRON, "CURSORMARSEY_DEFAULT":CURSORMARSEY_DEFAULT, "SNAPPY_ID":SNAPPY_ID, "get_running_orgy":get_running_orgy, - "bar_position":bar_position, "datetime":datetime, "CSS_LENGTH_LIMIT":CSS_LENGTH_LIMIT, "cache":cache, "emoji_count":emoji_count, "HOLE_SIDEBAR_COLUMN_LENGTH":HOLE_SIDEBAR_COLUMN_LENGTH, + "bar_position":bar_position, "datetime":datetime, "CSS_LENGTH_LIMIT":CSS_LENGTH_LIMIT, "cache":cache, "emoji_count":emoji_count, "HOLE_SIDEBAR_COLUMN_LENGTH":HOLE_SIDEBAR_COLUMN_LENGTH, "HOLE_SNAPPY_QUOTES_LENGTH":HOLE_SNAPPY_QUOTES_LENGTH, "SIDEBAR_REQUEST_THREAD":SIDEBAR_REQUEST_THREAD, "BANNER_REQUEST_THREAD":BANNER_REQUEST_THREAD, } diff --git a/files/templates/hole/settings.html b/files/templates/hole/settings.html index ad8d617b4..a0b05d296 100644 --- a/files/templates/hole/settings.html +++ b/files/templates/hole/settings.html @@ -85,7 +85,7 @@ {% endif %} -
+
@@ -107,7 +107,7 @@
-
+
@@ -128,4 +128,27 @@
+ +
+
+
+
+

Edit Snappy Quotes


+
+
+
+
+ + + Separate Quotes with [para] +

Limit of {{HOLE_SNAPPY_QUOTES_LENGTH}} characters

+
+ +
+
+
+
+
+
+
{% endblock %} diff --git a/migrations/20240211-add-custom-snappy-quotes-to-holessql.sql b/migrations/20240211-add-custom-snappy-quotes-to-holessql.sql new file mode 100644 index 000000000..038497f8c --- /dev/null +++ b/migrations/20240211-add-custom-snappy-quotes-to-holessql.sql @@ -0,0 +1 @@ +alter table holes add column snappy_quotes varchar(20000);