make hole jannies able to add custom snappy quotes
parent
2e75ef302c
commit
0b6a3e4e86
|
@ -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")
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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/<hole>/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/<hole>/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!"}
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@
|
|||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="row my-5 pt-5">
|
||||
<div class="row mt-5">
|
||||
<div class="col col-md-8">
|
||||
<div class="settings">
|
||||
<div id="description">
|
||||
|
@ -107,7 +107,7 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="row mt-5">
|
||||
<div class="col col-md-8">
|
||||
<div class="settings">
|
||||
<div id="description">
|
||||
|
@ -128,4 +128,27 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mt-5">
|
||||
<div class="col col-md-8">
|
||||
<div class="settings">
|
||||
<div id="description">
|
||||
<h2>Edit Snappy Quotes</h2><br>
|
||||
</div>
|
||||
<div class="body d-lg-flex">
|
||||
<div class="w-lg-100">
|
||||
<form id="snappy_quotes" action="/h/{{hole}}/snappy_quotes" method="post" data-nonce="{{g.nonce}}" data-onsubmit="sendFormXHR(this)">
|
||||
<input hidden name="formkey" value="{{v|formkey}}">
|
||||
<textarea autocomplete="off" maxlength="{{HOLE_SNAPPY_QUOTES_LENGTH}}" class="form-control rounded" id="bio-text" placeholder="Enter Snappy Quotes here..." rows="10" name="snappy_quotes" form="snappy_quotes">{% if snappy_quotes %}{{snappy_quotes}}{% endif %}</textarea>
|
||||
<small>Separate Quotes with <code>[para]</code></small>
|
||||
<p><small>Limit of {{HOLE_SNAPPY_QUOTES_LENGTH}} characters</small></p>
|
||||
<div class="d-flex mt-2">
|
||||
<input autocomplete="off" class="btn btn-primary ml-auto" type="submit" value="Save">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
alter table holes add column snappy_quotes varchar(20000);
|
Loading…
Reference in New Issue