sfd
This commit is contained in:
parent
27e51ac01d
commit
9cf8ceec01
9 changed files with 174 additions and 12 deletions
BIN
files/assets/images/Drama/houses/Femboy.webp
Normal file
BIN
files/assets/images/Drama/houses/Femboy.webp
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.8 KiB |
BIN
files/assets/images/Drama/houses/Furry.webp
Normal file
BIN
files/assets/images/Drama/houses/Furry.webp
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.6 KiB |
BIN
files/assets/images/Drama/houses/Racist.webp
Normal file
BIN
files/assets/images/Drama/houses/Racist.webp
Normal file
Binary file not shown.
After Width: | Height: | Size: 18 KiB |
BIN
files/assets/images/Drama/houses/Vampire.webp
Normal file
BIN
files/assets/images/Drama/houses/Vampire.webp
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.2 KiB |
File diff suppressed because one or more lines are too long
|
@ -100,16 +100,24 @@ SLURS = {
|
||||||
}
|
}
|
||||||
|
|
||||||
single_words = "|".join([slur.lower() for slur in SLURS.keys()])
|
single_words = "|".join([slur.lower() for slur in SLURS.keys()])
|
||||||
SLUR_REGEX = re.compile(rf"(?i)((?<=\s|>)|^)({single_words})((?=[\s<,.]|s[\s<,.])|$)", re.A)
|
|
||||||
|
|
||||||
def sub_matcher(match: re.Match):
|
SLUR_REGEX = re.compile(rf"(?i)((?<=\s|>)|^)({single_words})((?=[\s<,.]|s[\s<,.])|$)", re.A)
|
||||||
|
SLUR_REGEX_UPPER = re.compile(rf"((?<=\s|>)|^)({single_words.upper()})((?=[\s<,.]|s[\s<,.])|$)", re.A)
|
||||||
|
|
||||||
|
def sub_matcher(match):
|
||||||
return SLURS[match.group(0).lower()]
|
return SLURS[match.group(0).lower()]
|
||||||
|
|
||||||
def censor_slurs(body: str, logged_user):
|
def sub_matcher_upper(match):
|
||||||
if not logged_user or logged_user.slurreplacer: body = SLUR_REGEX.sub(sub_matcher, body)
|
return SLURS[match.group(0).lower()].upper()
|
||||||
|
|
||||||
|
def censor_slurs(body, logged_user):
|
||||||
|
if not logged_user or logged_user.slurreplacer:
|
||||||
|
body = SLUR_REGEX_UPPER.sub(sub_matcher_upper, body)
|
||||||
|
body = SLUR_REGEX.sub(sub_matcher, body)
|
||||||
return body
|
return body
|
||||||
|
|
||||||
def torture_ap(body, username):
|
def torture_ap(body, username):
|
||||||
|
body = SLUR_REGEX_UPPER.sub(sub_matcher_upper, body)
|
||||||
body = SLUR_REGEX.sub(sub_matcher, body)
|
body = SLUR_REGEX.sub(sub_matcher, body)
|
||||||
for k, l in AJ_REPLACEMENTS.items(): body = body.replace(k, l)
|
for k, l in AJ_REPLACEMENTS.items(): body = body.replace(k, l)
|
||||||
body = re.sub('(^|\s|\n)(i|me) ', rf'\1@{username} ', body, re.I|re.A)
|
body = re.sub('(^|\s|\n)(i|me) ', rf'\1@{username} ', body, re.I|re.A)
|
||||||
|
|
|
@ -35,6 +35,14 @@ def make_admin(v, username):
|
||||||
if not user: abort(404)
|
if not user: abort(404)
|
||||||
user.admin_level = 2
|
user.admin_level = 2
|
||||||
g.db.add(user)
|
g.db.add(user)
|
||||||
|
|
||||||
|
ma = ModAction(
|
||||||
|
kind="make_admin",
|
||||||
|
user_id=v.id,
|
||||||
|
target_user_id=user.id
|
||||||
|
)
|
||||||
|
g.db.add(ma)
|
||||||
|
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
return {"message": "User has been made admin!"}
|
return {"message": "User has been made admin!"}
|
||||||
|
|
||||||
|
@ -47,6 +55,14 @@ def remove_admin(v, username):
|
||||||
if not user: abort(404)
|
if not user: abort(404)
|
||||||
user.admin_level = 0
|
user.admin_level = 0
|
||||||
g.db.add(user)
|
g.db.add(user)
|
||||||
|
|
||||||
|
ma = ModAction(
|
||||||
|
kind="remove_admin",
|
||||||
|
user_id=v.id,
|
||||||
|
target_user_id=user.id
|
||||||
|
)
|
||||||
|
g.db.add(ma)
|
||||||
|
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
return {"message": "Admin removed!"}
|
return {"message": "Admin removed!"}
|
||||||
|
|
||||||
|
@ -88,6 +104,13 @@ def distribute(v, comment):
|
||||||
post.body += '\n\nclosed'
|
post.body += '\n\nclosed'
|
||||||
g.db.add(post)
|
g.db.add(post)
|
||||||
|
|
||||||
|
ma = ModAction(
|
||||||
|
kind="distribute",
|
||||||
|
user_id=v.id,
|
||||||
|
target_comment_id=cid
|
||||||
|
)
|
||||||
|
g.db.add(ma)
|
||||||
|
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
return {"message": f"Each winner has received {coinsperperson} coins!"}
|
return {"message": f"Each winner has received {coinsperperson} coins!"}
|
||||||
|
|
||||||
|
@ -98,6 +121,13 @@ def revert_actions(v, username):
|
||||||
user = get_user(username)
|
user = get_user(username)
|
||||||
if not user: abort(404)
|
if not user: abort(404)
|
||||||
|
|
||||||
|
ma = ModAction(
|
||||||
|
kind="revert",
|
||||||
|
user_id=v.id,
|
||||||
|
target_user_id=user.id
|
||||||
|
)
|
||||||
|
g.db.add(ma)
|
||||||
|
|
||||||
cutoff = int(time.time()) - 86400
|
cutoff = int(time.time()) - 86400
|
||||||
|
|
||||||
posts = [x[0] for x in g.db.query(ModAction.target_submission_id).filter(ModAction.user_id == user.id, ModAction.created_utc > cutoff, ModAction.kind == 'ban_post').all()]
|
posts = [x[0] for x in g.db.query(ModAction.target_submission_id).filter(ModAction.user_id == user.id, ModAction.created_utc > cutoff, ModAction.kind == 'ban_post').all()]
|
||||||
|
@ -149,6 +179,13 @@ def club_allow(v, username):
|
||||||
x.club_allowed = True
|
x.club_allowed = True
|
||||||
g.db.add(x)
|
g.db.add(x)
|
||||||
|
|
||||||
|
ma = ModAction(
|
||||||
|
kind="club_allow",
|
||||||
|
user_id=v.id,
|
||||||
|
target_user_id=u.id
|
||||||
|
)
|
||||||
|
g.db.add(ma)
|
||||||
|
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
return {"message": f"@{username} has been allowed into the {CC_TITLE}!"}
|
return {"message": f"@{username} has been allowed into the {CC_TITLE}!"}
|
||||||
|
|
||||||
|
@ -169,6 +206,13 @@ def club_ban(v, username):
|
||||||
u.club_allowed = False
|
u.club_allowed = False
|
||||||
g.db.add(x)
|
g.db.add(x)
|
||||||
|
|
||||||
|
ma = ModAction(
|
||||||
|
kind="club_ban",
|
||||||
|
user_id=v.id,
|
||||||
|
target_user_id=u.id
|
||||||
|
)
|
||||||
|
g.db.add(ma)
|
||||||
|
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
return {"message": f"@{username} has been kicked from the {CC_TITLE}. Deserved."}
|
return {"message": f"@{username} has been kicked from the {CC_TITLE}. Deserved."}
|
||||||
|
|
||||||
|
@ -182,6 +226,14 @@ def make_meme_admin(v, username):
|
||||||
if not user: abort(404)
|
if not user: abort(404)
|
||||||
user.admin_level = 1
|
user.admin_level = 1
|
||||||
g.db.add(user)
|
g.db.add(user)
|
||||||
|
|
||||||
|
ma = ModAction(
|
||||||
|
kind="make_meme_admin",
|
||||||
|
user_id=v.id,
|
||||||
|
target_user_id=user.id
|
||||||
|
)
|
||||||
|
g.db.add(ma)
|
||||||
|
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
return {"message": "User has been made meme admin!"}
|
return {"message": "User has been made meme admin!"}
|
||||||
|
|
||||||
|
@ -195,6 +247,14 @@ def remove_meme_admin(v, username):
|
||||||
if not user: abort(404)
|
if not user: abort(404)
|
||||||
user.admin_level = 0
|
user.admin_level = 0
|
||||||
g.db.add(user)
|
g.db.add(user)
|
||||||
|
|
||||||
|
ma = ModAction(
|
||||||
|
kind="remove_meme_admin",
|
||||||
|
user_id=v.id,
|
||||||
|
target_user_id=user.id
|
||||||
|
)
|
||||||
|
g.db.add(ma)
|
||||||
|
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
return {"message": "Meme admin removed!"}
|
return {"message": "Meme admin removed!"}
|
||||||
|
|
||||||
|
@ -238,6 +298,12 @@ def monthly(v):
|
||||||
u.procoins += 50000
|
u.procoins += 50000
|
||||||
g.db.add(u)
|
g.db.add(u)
|
||||||
|
|
||||||
|
ma = ModAction(
|
||||||
|
kind="monthly",
|
||||||
|
user_id=v.id
|
||||||
|
)
|
||||||
|
g.db.add(ma)
|
||||||
|
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
|
|
||||||
return {"message": "Monthly coins granted"}
|
return {"message": "Monthly coins granted"}
|
||||||
|
@ -382,6 +448,13 @@ def disable_signups(v):
|
||||||
def purge_cache(v):
|
def purge_cache(v):
|
||||||
cache.clear()
|
cache.clear()
|
||||||
response = str(requests.post(f'https://api.cloudflare.com/client/v4/zones/{CF_ZONE}/purge_cache', headers=CF_HEADERS, data='{"purge_everything":true}'))
|
response = str(requests.post(f'https://api.cloudflare.com/client/v4/zones/{CF_ZONE}/purge_cache', headers=CF_HEADERS, data='{"purge_everything":true}'))
|
||||||
|
|
||||||
|
ma = ModAction(
|
||||||
|
kind="purge_cache",
|
||||||
|
user_id=v.id
|
||||||
|
)
|
||||||
|
g.db.add(ma)
|
||||||
|
|
||||||
if response == "<Response [200]>": return {"message": "Cache purged!"}
|
if response == "<Response [200]>": return {"message": "Cache purged!"}
|
||||||
return {"error": "Failed to purge cache."}
|
return {"error": "Failed to purge cache."}
|
||||||
|
|
||||||
|
@ -454,6 +527,14 @@ def badge_grant_post(v):
|
||||||
text = f"@{v.username} has given you the following profile badge:\n\n\n\n{new_badge.name}"
|
text = f"@{v.username} has given you the following profile badge:\n\n\n\n{new_badge.name}"
|
||||||
send_notification(user.id, text)
|
send_notification(user.id, text)
|
||||||
|
|
||||||
|
ma = ModAction(
|
||||||
|
kind="badge_grant",
|
||||||
|
user_id=v.id,
|
||||||
|
target_user_id=user.id,
|
||||||
|
_note=new_badge.name
|
||||||
|
)
|
||||||
|
g.db.add(ma)
|
||||||
|
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
return render_template("admin/badge_grant.html", v=v, badge_types=badges, msg="Badge granted!")
|
return render_template("admin/badge_grant.html", v=v, badge_types=badges, msg="Badge granted!")
|
||||||
|
|
||||||
|
@ -483,6 +564,15 @@ def badge_remove_post(v):
|
||||||
badge = user.has_badge(badge_id)
|
badge = user.has_badge(badge_id)
|
||||||
if badge:
|
if badge:
|
||||||
g.db.delete(badge)
|
g.db.delete(badge)
|
||||||
|
|
||||||
|
ma = ModAction(
|
||||||
|
kind="badge_remove",
|
||||||
|
user_id=v.id,
|
||||||
|
target_user_id=user.id,
|
||||||
|
_note=badge.name
|
||||||
|
)
|
||||||
|
g.db.add(ma)
|
||||||
|
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
|
|
||||||
return render_template("admin/badge_remove.html", v=v, badge_types=badges, msg="Badge removed!")
|
return render_template("admin/badge_remove.html", v=v, badge_types=badges, msg="Badge removed!")
|
||||||
|
@ -632,6 +722,14 @@ def admin_link_accounts(v):
|
||||||
|
|
||||||
g.db.add(new_alt)
|
g.db.add(new_alt)
|
||||||
|
|
||||||
|
ma = ModAction(
|
||||||
|
kind="link_accounts",
|
||||||
|
user_id=v.id,
|
||||||
|
target_user_id=u1,
|
||||||
|
_note=f'with {u2}'
|
||||||
|
)
|
||||||
|
g.db.add(ma)
|
||||||
|
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
return redirect(f"{SITE_FULL}/admin/alt_votes?u1={g.db.query(User).get(u1).username}&u2={g.db.query(User).get(u2).username}")
|
return redirect(f"{SITE_FULL}/admin/alt_votes?u1={g.db.query(User).get(u1).username}&u2={g.db.query(User).get(u2).username}")
|
||||||
|
|
||||||
|
@ -1056,11 +1154,22 @@ def api_distinguish_post(post_id, v):
|
||||||
|
|
||||||
if post.author_id != v.id and v.admin_level < 2 : abort(403)
|
if post.author_id != v.id and v.admin_level < 2 : abort(403)
|
||||||
|
|
||||||
if post.distinguish_level: post.distinguish_level = 0
|
if post.distinguish_level:
|
||||||
else: post.distinguish_level = v.admin_level
|
post.distinguish_level = 0
|
||||||
|
kind = 'undistinguish_post'
|
||||||
|
else:
|
||||||
|
post.distinguish_level = v.admin_level
|
||||||
|
kind = 'distinguish_post'
|
||||||
|
|
||||||
g.db.add(post)
|
g.db.add(post)
|
||||||
|
|
||||||
|
ma = ModAction(
|
||||||
|
kind=kind,
|
||||||
|
user_id=v.id,
|
||||||
|
target_submission_id=post.id
|
||||||
|
)
|
||||||
|
g.db.add(ma)
|
||||||
|
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
|
|
||||||
if post.distinguish_level: return {"message": "Post distinguished!"}
|
if post.distinguish_level: return {"message": "Post distinguished!"}
|
||||||
|
@ -1082,6 +1191,13 @@ def sticky_post(post_id, v):
|
||||||
else: post.stickied = v.username
|
else: post.stickied = v.username
|
||||||
g.db.add(post)
|
g.db.add(post)
|
||||||
|
|
||||||
|
ma=ModAction(
|
||||||
|
kind="pin_post",
|
||||||
|
user_id=v.id,
|
||||||
|
target_submission_id=post.id
|
||||||
|
)
|
||||||
|
g.db.add(ma)
|
||||||
|
|
||||||
if v.id != post.author_id:
|
if v.id != post.author_id:
|
||||||
send_repeatable_notification(post.author_id, f"@{v.username} has pinned your [post](/post/{post_id})!")
|
send_repeatable_notification(post.author_id, f"@{v.username} has pinned your [post](/post/{post_id})!")
|
||||||
|
|
||||||
|
@ -1123,6 +1239,13 @@ def sticky_comment(cid, v):
|
||||||
comment.is_pinned = v.username
|
comment.is_pinned = v.username
|
||||||
g.db.add(comment)
|
g.db.add(comment)
|
||||||
|
|
||||||
|
ma=ModAction(
|
||||||
|
kind="pin_comment",
|
||||||
|
user_id=v.id,
|
||||||
|
target_comment_id=comment.id
|
||||||
|
)
|
||||||
|
g.db.add(ma)
|
||||||
|
|
||||||
if v.id != comment.author_id:
|
if v.id != comment.author_id:
|
||||||
message = f"@{v.username} has pinned your [comment]({comment.permalink})!"
|
message = f"@{v.username} has pinned your [comment]({comment.permalink})!"
|
||||||
send_repeatable_notification(comment.author_id, message)
|
send_repeatable_notification(comment.author_id, message)
|
||||||
|
@ -1218,9 +1341,22 @@ def admin_distinguish_comment(c_id, v):
|
||||||
|
|
||||||
if comment.author_id != v.id: abort(403)
|
if comment.author_id != v.id: abort(403)
|
||||||
|
|
||||||
comment.distinguish_level = 0 if comment.distinguish_level else v.admin_level
|
if comment.distinguish_level:
|
||||||
|
comment.distinguish_level = 0
|
||||||
|
kind = 'distinguish_comment'
|
||||||
|
else:
|
||||||
|
comment.distinguish_level = v.admin_level
|
||||||
|
kind = 'undistinguish_comment'
|
||||||
|
|
||||||
g.db.add(comment)
|
g.db.add(comment)
|
||||||
|
|
||||||
|
ma = ModAction(
|
||||||
|
kind=kind,
|
||||||
|
user_id=v.id,
|
||||||
|
target_comment_id=comment.id
|
||||||
|
)
|
||||||
|
g.db.add(ma)
|
||||||
|
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
|
|
||||||
if comment.distinguish_level: return {"message": "Comment distinguished!"}
|
if comment.distinguish_level: return {"message": "Comment distinguished!"}
|
||||||
|
@ -1230,6 +1366,13 @@ def admin_distinguish_comment(c_id, v):
|
||||||
@admin_level_required(2)
|
@admin_level_required(2)
|
||||||
def admin_dump_cache(v):
|
def admin_dump_cache(v):
|
||||||
cache.clear()
|
cache.clear()
|
||||||
|
|
||||||
|
ma = ModAction(
|
||||||
|
kind="dump_cache",
|
||||||
|
user_id=v.id
|
||||||
|
)
|
||||||
|
g.db.add(ma)
|
||||||
|
|
||||||
return {"message": "Internal cache cleared."}
|
return {"message": "Internal cache cleared."}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -66,13 +66,24 @@ def remove_report(report_fn, v):
|
||||||
|
|
||||||
if report_fn.startswith('c'):
|
if report_fn.startswith('c'):
|
||||||
report = g.db.query(CommentFlag).filter_by(id=int(report_fn.lstrip('c'))).one_or_none()
|
report = g.db.query(CommentFlag).filter_by(id=int(report_fn.lstrip('c'))).one_or_none()
|
||||||
|
ma=ModAction(
|
||||||
|
kind="delete_report_comment",
|
||||||
|
user_id=v.id,
|
||||||
|
target_comment_id=report.comment_id
|
||||||
|
)
|
||||||
elif report_fn.startswith('p'):
|
elif report_fn.startswith('p'):
|
||||||
report = g.db.query(Flag).filter_by(id=int(report_fn.lstrip('p'))).one_or_none()
|
report = g.db.query(Flag).filter_by(id=int(report_fn.lstrip('p'))).one_or_none()
|
||||||
else:
|
ma=ModAction(
|
||||||
return {"error": "Invalid report ID"}, 400
|
kind="delete_report_post",
|
||||||
|
user_id=v.id,
|
||||||
|
target_submission_id=report.post_id
|
||||||
|
)
|
||||||
|
else: return {"error": "Invalid report ID"}, 400
|
||||||
|
|
||||||
g.db.delete(report)
|
g.db.delete(report)
|
||||||
|
|
||||||
|
g.db.add(ma)
|
||||||
|
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
|
|
||||||
return {"message": "Removed report"}
|
return {"message": "Removed report"}
|
|
@ -502,9 +502,9 @@
|
||||||
{% if p.domain == "twitter.com" %}
|
{% if p.domain == "twitter.com" %}
|
||||||
{{p.embed_url | safe}}
|
{{p.embed_url | safe}}
|
||||||
{% if v and v.theme.split("_")[0] in ["light", "coffee", "4chan"] %}
|
{% if v and v.theme.split("_")[0] in ["light", "coffee", "4chan"] %}
|
||||||
<script src="/static/assets/js/twitterlight.js?a=241"></script>
|
<script src="/static/assets/js/twitterlight.js?a=242"></script>
|
||||||
{% else %}
|
{% else %}
|
||||||
<script src="/static/assets/js/twitter.js?a=241"></script>
|
<script src="/static/assets/js/twitter.js?a=242"></script>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% elif p.domain in ['youtu.be','youtube.com'] and p.embed_url and p.embed_url.startswith('<lite-youtube') %}
|
{% elif p.domain in ['youtu.be','youtube.com'] and p.embed_url and p.embed_url.startswith('<lite-youtube') %}
|
||||||
{{p.embed_url | safe}}
|
{{p.embed_url | safe}}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue