forked from MarseyWorld/MarseyWorld
fdsfds
parent
77f92c8aee
commit
2797adc57a
|
@ -23,10 +23,10 @@ services:
|
||||||
- PUSHER_KEY=3435tdfsdudebussylmaoxxt43
|
- PUSHER_KEY=3435tdfsdudebussylmaoxxt43
|
||||||
- IMGUR_KEY=3435tdfsdudebussylmaoxxt43
|
- IMGUR_KEY=3435tdfsdudebussylmaoxxt43
|
||||||
- SPAM_SIMILARITY_THRESHOLD=0.5
|
- SPAM_SIMILARITY_THRESHOLD=0.5
|
||||||
- SPAM_SIMILAR_COUNT_THRESHOLD=5
|
|
||||||
- SPAM_URL_SIMILARITY_THRESHOLD=0.1
|
- SPAM_URL_SIMILARITY_THRESHOLD=0.1
|
||||||
|
- SPAM_SIMILAR_COUNT_THRESHOLD=10
|
||||||
- COMMENT_SPAM_SIMILAR_THRESHOLD=0.5
|
- COMMENT_SPAM_SIMILAR_THRESHOLD=0.5
|
||||||
- COMMENT_SPAM_COUNT_THRESHOLD=5
|
- COMMENT_SPAM_COUNT_THRESHOLD=10
|
||||||
- READ_ONLY=0
|
- READ_ONLY=0
|
||||||
- BOT_DISABLE=0
|
- BOT_DISABLE=0
|
||||||
- COINS_NAME=Dramacoins
|
- COINS_NAME=Dramacoins
|
||||||
|
|
4
env
4
env
|
@ -12,10 +12,10 @@ export YOUTUBE_KEY="3435tdfsdudebussylmaoxxt43"
|
||||||
export PUSHER_KEY="3435tdfsdudebussylmaoxxt43"
|
export PUSHER_KEY="3435tdfsdudebussylmaoxxt43"
|
||||||
export IMGUR_KEY="3435tdfsdudebussylmaoxxt43"
|
export IMGUR_KEY="3435tdfsdudebussylmaoxxt43"
|
||||||
export SPAM_SIMILARITY_THRESHOLD="0.5"
|
export SPAM_SIMILARITY_THRESHOLD="0.5"
|
||||||
export SPAM_SIMILAR_COUNT_THRESHOLD="5"
|
|
||||||
export SPAM_URL_SIMILARITY_THRESHOLD="0.1"
|
export SPAM_URL_SIMILARITY_THRESHOLD="0.1"
|
||||||
|
export SPAM_SIMILAR_COUNT_THRESHOLD="10"
|
||||||
export COMMENT_SPAM_SIMILAR_THRESHOLD="0.5"
|
export COMMENT_SPAM_SIMILAR_THRESHOLD="0.5"
|
||||||
export COMMENT_SPAM_COUNT_THRESHOLD="5"
|
export COMMENT_SPAM_COUNT_THRESHOLD="10"
|
||||||
export READ_ONLY="0"
|
export READ_ONLY="0"
|
||||||
export BOT_DISABLE="0"
|
export BOT_DISABLE="0"
|
||||||
export COINS_NAME="Dramacoins"
|
export COINS_NAME="Dramacoins"
|
||||||
|
|
|
@ -46,10 +46,10 @@ app.config["UserAgent"] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit
|
||||||
app.config["HCAPTCHA_SITEKEY"] = environ.get("HCAPTCHA_SITEKEY","").strip()
|
app.config["HCAPTCHA_SITEKEY"] = environ.get("HCAPTCHA_SITEKEY","").strip()
|
||||||
app.config["HCAPTCHA_SECRET"] = environ.get("HCAPTCHA_SECRET","").strip()
|
app.config["HCAPTCHA_SECRET"] = environ.get("HCAPTCHA_SECRET","").strip()
|
||||||
app.config["SPAM_SIMILARITY_THRESHOLD"] = float(environ.get("SPAM_SIMILARITY_THRESHOLD", 0.5))
|
app.config["SPAM_SIMILARITY_THRESHOLD"] = float(environ.get("SPAM_SIMILARITY_THRESHOLD", 0.5))
|
||||||
app.config["SPAM_SIMILAR_COUNT_THRESHOLD"] = int(environ.get("SPAM_SIMILAR_COUNT_THRESHOLD", 5))
|
app.config["SPAM_URL_SIMILARITY_THRESHOLD"] = float(environ.get("SPAM_URL_SIMILARITY_THRESHOLD", 0.1))
|
||||||
app.config["SPAM_URL_SIMILARITY_THRESHOLD"] = float(environ.get("SPAM_URL_SIMILARITY_THRESHOLD", 0.5))
|
app.config["SPAM_SIMILAR_COUNT_THRESHOLD"] = int(environ.get("SPAM_SIMILAR_COUNT_THRESHOLD", 10))
|
||||||
app.config["COMMENT_SPAM_SIMILAR_THRESHOLD"] = float(environ.get("COMMENT_SPAM_SIMILAR_THRESHOLD", 0.5))
|
app.config["COMMENT_SPAM_SIMILAR_THRESHOLD"] = float(environ.get("COMMENT_SPAM_SIMILAR_THRESHOLD", 0.5))
|
||||||
app.config["COMMENT_SPAM_COUNT_THRESHOLD"] = int(environ.get("COMMENT_SPAM_COUNT_THRESHOLD", 0.5))
|
app.config["COMMENT_SPAM_COUNT_THRESHOLD"] = int(environ.get("COMMENT_SPAM_COUNT_THRESHOLD", 10))
|
||||||
app.config["READ_ONLY"]=bool(int(environ.get("READ_ONLY", "0")))
|
app.config["READ_ONLY"]=bool(int(environ.get("READ_ONLY", "0")))
|
||||||
app.config["BOT_DISABLE"]=bool(int(environ.get("BOT_DISABLE", False)))
|
app.config["BOT_DISABLE"]=bool(int(environ.get("BOT_DISABLE", False)))
|
||||||
app.config["RATELIMIT_KEY_PREFIX"] = "flask_limiting_"
|
app.config["RATELIMIT_KEY_PREFIX"] = "flask_limiting_"
|
||||||
|
|
|
@ -227,8 +227,7 @@ class User(Base):
|
||||||
@cache.memoize(timeout=86400)
|
@cache.memoize(timeout=86400)
|
||||||
def userpagelisting(self, v=None, page=1, sort="new", t="all"):
|
def userpagelisting(self, v=None, page=1, sort="new", t="all"):
|
||||||
|
|
||||||
if self.shadowbanned and not (v and (v.admin_level > 1 or v.id == self.id)):
|
if self.shadowbanned and not (v and (v.admin_level > 1 or v.id == self.id)): return []
|
||||||
return []
|
|
||||||
|
|
||||||
posts = g.db.query(Submission.id).filter_by(author_id=self.id, is_pinned=False)
|
posts = g.db.query(Submission.id).filter_by(author_id=self.id, is_pinned=False)
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,6 @@ def create_comment(text, autojanny=False):
|
||||||
if autojanny: author_id = AUTOJANNY_ID
|
if autojanny: author_id = AUTOJANNY_ID
|
||||||
else: author_id = NOTIFICATIONS_ID
|
else: author_id = NOTIFICATIONS_ID
|
||||||
|
|
||||||
text = text.replace('r/', 'r\/').replace('u/', 'u\/')
|
|
||||||
text_html = sanitize(Renderer2().render(mistletoe.Document(text)))
|
text_html = sanitize(Renderer2().render(mistletoe.Document(text)))
|
||||||
new_comment = Comment(author_id=author_id,
|
new_comment = Comment(author_id=author_id,
|
||||||
parent_submission=None,
|
parent_submission=None,
|
||||||
|
@ -84,10 +83,16 @@ def send_admin(vid, text):
|
||||||
g.db.add(notif)
|
g.db.add(notif)
|
||||||
|
|
||||||
|
|
||||||
def NOTIFY_USERS(text, vid):
|
def NOTIFY_USERS(text, v):
|
||||||
text = text.lower()
|
|
||||||
notify_users = set()
|
notify_users = set()
|
||||||
for word, id in NOTIFIED_USERS.items():
|
for word, id in NOTIFIED_USERS.items():
|
||||||
if id == 0: continue
|
if id == 0: continue
|
||||||
if word in text and id not in notify_users and vid != id: notify_users.add(id)
|
if word in text.lower() and id not in notify_users and v.id != id: notify_users.add(id)
|
||||||
|
|
||||||
|
soup = BeautifulSoup(text, features="html.parser")
|
||||||
|
for mention in soup.find_all("a", href=re.compile("^/@(\w+)")):
|
||||||
|
username = mention["href"].split("@")[1]
|
||||||
|
user = g.db.query(User).filter_by(username=username).first()
|
||||||
|
if user and not v.any_block_exists(user) and user.id != v.id: notify_users.add(user.id)
|
||||||
|
|
||||||
return notify_users
|
return notify_users
|
|
@ -6,30 +6,30 @@ SITE = environ.get("DOMAIN", '').strip()
|
||||||
SITE_NAME = environ.get("SITE_NAME", '').strip()
|
SITE_NAME = environ.get("SITE_NAME", '').strip()
|
||||||
|
|
||||||
AJ_REPLACEMENTS = {
|
AJ_REPLACEMENTS = {
|
||||||
"you're": '$#3$2',
|
" you're ": ' $#3$2 ',
|
||||||
'your': "you're",
|
' your ': " you're ",
|
||||||
'$#3$2': 'your',
|
' $#3$2 ': ' your ',
|
||||||
"too": '$#3$3',
|
" too ": ' $#3$3 ',
|
||||||
'to': "too",
|
' to ': " too ",
|
||||||
'$#3$3': 'to',
|
' $#3$3 ': ' to ',
|
||||||
' my ': ' their ',
|
' my ': ' their ',
|
||||||
' mine ': ' their ',
|
' mine ': ' their ',
|
||||||
|
|
||||||
"You're": '$#3$2',
|
" You're ": ' $#3$2 ',
|
||||||
'Your': "You're",
|
' Your ': " You're ",
|
||||||
'$#3$2': 'Your',
|
' $#3$2 ': ' Your ',
|
||||||
"Too": '$#3$3',
|
" Too ": ' $#3$3 ',
|
||||||
'To': "Too",
|
' To ': " Too ",
|
||||||
'$#3$3': 'To',
|
' $#3$3 ': ' To ',
|
||||||
' My ': ' Their ',
|
' My ': ' Their ',
|
||||||
' Mine ': ' Their ',
|
' Mine ': ' Their ',
|
||||||
|
|
||||||
"YOU'RE": '$#3$2',
|
" YOU'RE ": ' $#3$2 ',
|
||||||
'YOUR': "YOU'RE",
|
' YOUR ': " YOU'RE ",
|
||||||
'$#3$2': 'YOUR',
|
' $#3$2 ': ' YOUR ',
|
||||||
"TOO": '$#3$3',
|
" TOO ": ' $#3$3 ',
|
||||||
'TO': "TOO",
|
' TO ': " TOO ",
|
||||||
'$#3$3': 'TO',
|
' $#3$3 ': ' TO ',
|
||||||
' MY ': ' THEIR ',
|
' MY ': ' THEIR ',
|
||||||
' MINE ': ' THEIR ',
|
' MINE ': ' THEIR ',
|
||||||
}
|
}
|
||||||
|
@ -107,6 +107,24 @@ SLURS = {
|
||||||
" elon ": " rocket daddy ",
|
" elon ": " rocket daddy ",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
single_words = "|".join([slur.lower() for slur in SLURS.keys()])
|
||||||
|
SLUR_REGEX = re.compile(rf"(?i)((?<=\s|>)|^)({single_words})((?=[\s<,.]|s[\s<,.])|$)")
|
||||||
|
|
||||||
|
def sub_matcher(match: re.Match) -> str:
|
||||||
|
return SLURS[match.group(0).lower()]
|
||||||
|
|
||||||
|
def censor_slurs(body: str, logged_user) -> str:
|
||||||
|
if not logged_user or logged_user.slurreplacer: body = SLUR_REGEX.sub(sub_matcher, body)
|
||||||
|
return body
|
||||||
|
|
||||||
|
def torture_ap(body, username):
|
||||||
|
body = SLUR_REGEX.sub(sub_matcher, body)
|
||||||
|
for k, l in AJ_REPLACEMENTS.items(): body = body.replace(k, l)
|
||||||
|
body = re.sub('(^| )(i|me) ', rf'\1@{username} ', body, flags=re.I)
|
||||||
|
body = re.sub("(^| )i'm ", rf'\1@{username} is ', body, flags=re.I)
|
||||||
|
return body
|
||||||
|
|
||||||
|
|
||||||
LONGPOST_REPLIES = ['Wow, you must be a JP fan.', 'This is one of the worst posts I have EVER seen. Delete it.', "No, don't reply like this, please do another wall of unhinged rant please.", '# 😴😴😴', "Ma'am we've been over this before. You need to stop.", "I've known more coherent downies.", "Your pulitzer's in the mail", "That's great and all, but I asked for my burger without cheese.", 'That degree finally paying off', "That's nice sweaty. Why don't you have a seat in the time out corner with Pizzashill until you calm down, then you can have your Capri Sun.", "All them words won't bring your pa back.", "You had a chance to not be completely worthless, but it looks like you threw it away. At least you're consistent.", 'Some people are able to display their intelligence by going on at length on a subject and never actually saying anything. This ability is most common in trades such as politics, public relations, and law. You have impressed me by being able to best them all, while still coming off as an absolute idiot.', "You can type 10,000 characters and you decided that these were the one's that you wanted.", 'Have you owned the libs yet?', "I don't know what you said, because I've seen another human naked.", 'Impressive. Normally people with such severe developmental disabilities struggle to write much more than a sentence or two. He really has exceded our expectations for the writing portion. Sadly the coherency of his writing, along with his abilities in the social skills and reading portions, are far behind his peers with similar disabilities.', "This is a really long way of saying you don't fuck.", "Sorry ma'am, looks like his delusions have gotten worse. We'll have to admit him.", ':#marseywoah:', 'If only you could put that energy into your relationships', 'Posts like this is why I do Heroine.', 'still unemployed then?', 'K', 'look im gunna have 2 ask u 2 keep ur giant dumps in the toilet not in my replys 😷😷😷', "Mommy is soooo proud of you, sweaty. Let's put this sperg out up on the fridge with all your other failures.", "Good job bobby, here's a star", "That was a mistake. You're about to find out the hard way why.", 'You sat down and wrote all this shit. You could have done so many other things with your life. What happened to your life that made you decide writing novels of bullshit on rdrama.net was the best option?', "I don't have enough spoons to read this shit", "All those words won't bring daddy back.", 'OUT!']
|
LONGPOST_REPLIES = ['Wow, you must be a JP fan.', 'This is one of the worst posts I have EVER seen. Delete it.', "No, don't reply like this, please do another wall of unhinged rant please.", '# 😴😴😴', "Ma'am we've been over this before. You need to stop.", "I've known more coherent downies.", "Your pulitzer's in the mail", "That's great and all, but I asked for my burger without cheese.", 'That degree finally paying off', "That's nice sweaty. Why don't you have a seat in the time out corner with Pizzashill until you calm down, then you can have your Capri Sun.", "All them words won't bring your pa back.", "You had a chance to not be completely worthless, but it looks like you threw it away. At least you're consistent.", 'Some people are able to display their intelligence by going on at length on a subject and never actually saying anything. This ability is most common in trades such as politics, public relations, and law. You have impressed me by being able to best them all, while still coming off as an absolute idiot.', "You can type 10,000 characters and you decided that these were the one's that you wanted.", 'Have you owned the libs yet?', "I don't know what you said, because I've seen another human naked.", 'Impressive. Normally people with such severe developmental disabilities struggle to write much more than a sentence or two. He really has exceded our expectations for the writing portion. Sadly the coherency of his writing, along with his abilities in the social skills and reading portions, are far behind his peers with similar disabilities.', "This is a really long way of saying you don't fuck.", "Sorry ma'am, looks like his delusions have gotten worse. We'll have to admit him.", ':#marseywoah:', 'If only you could put that energy into your relationships', 'Posts like this is why I do Heroine.', 'still unemployed then?', 'K', 'look im gunna have 2 ask u 2 keep ur giant dumps in the toilet not in my replys 😷😷😷', "Mommy is soooo proud of you, sweaty. Let's put this sperg out up on the fridge with all your other failures.", "Good job bobby, here's a star", "That was a mistake. You're about to find out the hard way why.", 'You sat down and wrote all this shit. You could have done so many other things with your life. What happened to your life that made you decide writing novels of bullshit on rdrama.net was the best option?', "I don't have enough spoons to read this shit", "All those words won't bring daddy back.", 'OUT!']
|
||||||
|
|
||||||
AGENDAPOSTER_MSG = """Hi @{username},\n\nYour comment has been automatically removed because you forgot
|
AGENDAPOSTER_MSG = """Hi @{username},\n\nYour comment has been automatically removed because you forgot
|
||||||
|
@ -205,19 +223,6 @@ else:
|
||||||
PUSHER_INSTANCE_ID = '02ddcc80-b8db-42be-9022-44c546b4dce6'
|
PUSHER_INSTANCE_ID = '02ddcc80-b8db-42be-9022-44c546b4dce6'
|
||||||
PUSHER_KEY = environ.get("PUSHER_KEY", "").strip()
|
PUSHER_KEY = environ.get("PUSHER_KEY", "").strip()
|
||||||
|
|
||||||
single_words = "|".join([slur.lower() for slur in SLURS.keys()])
|
|
||||||
SLUR_REGEX = re.compile(rf"(?i)((?<=\s|>)|^)({single_words})((?=[\s<,.]|s[\s<,.])|$)")
|
|
||||||
|
|
||||||
def sub_matcher(match: re.Match) -> str:
|
|
||||||
return SLURS[match.group(0).lower()]
|
|
||||||
|
|
||||||
def censor_slurs(body: str, logged_user) -> str:
|
|
||||||
if not logged_user or logged_user.slurreplacer: body = SLUR_REGEX.sub(sub_matcher, body)
|
|
||||||
return body
|
|
||||||
|
|
||||||
def censor_slurs2(body: str) -> str:
|
|
||||||
return SLUR_REGEX.sub(sub_matcher, body)
|
|
||||||
|
|
||||||
BADGES = {
|
BADGES = {
|
||||||
1: {
|
1: {
|
||||||
'name': 'Alpha User',
|
'name': 'Alpha User',
|
||||||
|
@ -718,5 +723,6 @@ NOTIFIED_USERS = {
|
||||||
' llm ': LLM_ID,
|
' llm ': LLM_ID,
|
||||||
'landlet': LLM_ID,
|
'landlet': LLM_ID,
|
||||||
'dong': DONGER_ID,
|
'dong': DONGER_ID,
|
||||||
'dong': FARTBINN_ID
|
'dong': FARTBINN_ID,
|
||||||
}
|
'kippy': KIPPY_ID,
|
||||||
|
}
|
|
@ -3,55 +3,48 @@ from .get import *
|
||||||
from mistletoe.span_token import SpanToken
|
from mistletoe.span_token import SpanToken
|
||||||
from mistletoe.html_renderer import HTMLRenderer
|
from mistletoe.html_renderer import HTMLRenderer
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from flask import g
|
from flask import g
|
||||||
|
|
||||||
|
|
||||||
# add token/rendering for @username mentions
|
|
||||||
|
|
||||||
|
|
||||||
class UserMention(SpanToken):
|
class UserMention(SpanToken):
|
||||||
|
|
||||||
pattern = re.compile("(^|\s|\n)@((\w|-){1,25})")
|
pattern = re.compile("(^|\s|\n)@((\w|-){1,25})")
|
||||||
parse_inner = False
|
parse_inner = False
|
||||||
|
|
||||||
def __init__(self, match_obj):
|
def __init__(self, match_obj):
|
||||||
self.target = (match_obj.group(1), match_obj.group(2))
|
self.target = (match_obj.group(1), match_obj.group(2))
|
||||||
|
|
||||||
|
class UserMention2(SpanToken):
|
||||||
|
pattern = re.compile("^@((\w|-){1,25})")
|
||||||
|
parse_inner = False
|
||||||
|
def __init__(self, match_obj):
|
||||||
|
self.target = (match_obj.group(1))
|
||||||
|
|
||||||
class SubMention(SpanToken):
|
class SubMention(SpanToken):
|
||||||
|
|
||||||
pattern = re.compile("(^|\s|\n)r/(\w{3,25})")
|
pattern = re.compile("(^|\s|\n)r/(\w{3,25})")
|
||||||
parse_inner = False
|
parse_inner = False
|
||||||
|
|
||||||
def __init__(self, match_obj):
|
def __init__(self, match_obj):
|
||||||
|
|
||||||
self.target = (match_obj.group(1), match_obj.group(2))
|
self.target = (match_obj.group(1), match_obj.group(2))
|
||||||
|
|
||||||
class RedditorMention(SpanToken):
|
class RedditorMention(SpanToken):
|
||||||
|
|
||||||
pattern = re.compile("(^|\s|\n)u/((\w|-){3,25})")
|
pattern = re.compile("(^|\s|\n)u/((\w|-){3,25})")
|
||||||
parse_inner = False
|
parse_inner = False
|
||||||
|
|
||||||
def __init__(self, match_obj):
|
def __init__(self, match_obj):
|
||||||
|
|
||||||
self.target = (match_obj.group(1), match_obj.group(2))
|
self.target = (match_obj.group(1), match_obj.group(2))
|
||||||
|
|
||||||
class SubMention2(SpanToken):
|
class SubMention2(SpanToken):
|
||||||
|
|
||||||
pattern = re.compile("(^|\s|\n)/r/(\w{3,25})")
|
pattern = re.compile("(^|\s|\n)/r/(\w{3,25})")
|
||||||
parse_inner = False
|
parse_inner = False
|
||||||
|
|
||||||
def __init__(self, match_obj):
|
def __init__(self, match_obj):
|
||||||
|
|
||||||
self.target = (match_obj.group(1), match_obj.group(2))
|
self.target = (match_obj.group(1), match_obj.group(2))
|
||||||
|
|
||||||
class RedditorMention2(SpanToken):
|
class RedditorMention2(SpanToken):
|
||||||
|
|
||||||
pattern = re.compile("(^|\s|\n)/u/((\w|-){3,25})")
|
pattern = re.compile("(^|\s|\n)/u/((\w|-){3,25})")
|
||||||
parse_inner = False
|
parse_inner = False
|
||||||
|
|
||||||
def __init__(self, match_obj):
|
def __init__(self, match_obj):
|
||||||
|
|
||||||
self.target = (match_obj.group(1), match_obj.group(2))
|
self.target = (match_obj.group(1), match_obj.group(2))
|
||||||
|
|
||||||
class CustomRenderer(HTMLRenderer):
|
class CustomRenderer(HTMLRenderer):
|
||||||
|
@ -125,27 +118,8 @@ class Renderer(HTMLRenderer):
|
||||||
class Renderer2(HTMLRenderer):
|
class Renderer2(HTMLRenderer):
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
super().__init__(UserMention,
|
super().__init__(UserMention2)
|
||||||
SubMention,
|
for i in kwargs: self.__dict__[i] = kwargs[i]
|
||||||
RedditorMention,
|
|
||||||
SubMention2,
|
|
||||||
RedditorMention2,
|
|
||||||
)
|
|
||||||
|
|
||||||
for i in kwargs:
|
|
||||||
self.__dict__[i] = kwargs[i]
|
|
||||||
|
|
||||||
def render_user_mention(self, token):
|
def render_user_mention(self, token):
|
||||||
space = token.target[0]
|
return f'<a href="/@{token.target}"><img loading="lazy" src="/@{token.target}/pic" class="pp20">@{token.target}</a>'
|
||||||
target = token.target[1]
|
|
||||||
return f"{space}@{target}"
|
|
||||||
|
|
||||||
def render_sub_mention(self, token):
|
|
||||||
space = token.target[0]
|
|
||||||
target = token.target[1]
|
|
||||||
return f"{space}r/{target}"
|
|
||||||
|
|
||||||
def render_redditor_mention(self, token):
|
|
||||||
space = token.target[0]
|
|
||||||
target = token.target[1]
|
|
||||||
return f"{space}u/{target}"
|
|
|
@ -151,19 +151,6 @@ def club_ban(v, username):
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
return {"message": f"@{username} has been kicked from the {cc}. Deserved."}
|
return {"message": f"@{username} has been kicked from the {cc}. Deserved."}
|
||||||
|
|
||||||
@app.post("/@<username>/remove_admin")
|
|
||||||
@limiter.limit("1/second")
|
|
||||||
@admin_level_required(2)
|
|
||||||
@validate_formkey
|
|
||||||
def remove_admin(v, username):
|
|
||||||
if 'pcm' in request.host or (SITE_NAME == 'Drama' and v.admin_level > 2) or ('rama' not in request.host and 'pcm' not in request.host):
|
|
||||||
user = get_user(username)
|
|
||||||
if not user: abort(404)
|
|
||||||
user.admin_level = 0
|
|
||||||
g.db.add(user)
|
|
||||||
g.db.commit()
|
|
||||||
return {"message": "Admin removed!"}
|
|
||||||
|
|
||||||
|
|
||||||
@app.post("/@<username>/make_meme_admin")
|
@app.post("/@<username>/make_meme_admin")
|
||||||
@limiter.limit("1/second")
|
@limiter.limit("1/second")
|
||||||
|
|
|
@ -206,10 +206,7 @@ def api_comment(v):
|
||||||
body += f"\n\n{url}"
|
body += f"\n\n{url}"
|
||||||
else: return {"error": f"Image/Video files only"}, 400
|
else: return {"error": f"Image/Video files only"}, 400
|
||||||
|
|
||||||
if v.agendaposter and not v.marseyawarded:
|
if v.agendaposter and not v.marseyawarded: body = torture_ap(body, v.username)
|
||||||
for k, l in AJ_REPLACEMENTS.items(): body = body.replace(k, l)
|
|
||||||
body = body.replace(' I ', f' @{v.username} ').replace(' i ', f' @{v.username} ')
|
|
||||||
body = censor_slurs2(body).replace(' ME ', f' @{v.username} ').replace(' me ', f' @{v.username} ')
|
|
||||||
|
|
||||||
body_html = sanitize(CustomRenderer().render(mistletoe.Document(body)))
|
body_html = sanitize(CustomRenderer().render(mistletoe.Document(body)))
|
||||||
|
|
||||||
|
@ -240,7 +237,7 @@ def api_comment(v):
|
||||||
|
|
||||||
is_bot = bool(request.headers.get("Authorization"))
|
is_bot = bool(request.headers.get("Authorization"))
|
||||||
|
|
||||||
if not is_bot and not v.marseyawarded and 'trans lives matters' not in body.lower():
|
if not is_bot and not v.marseyawarded and 'trans lives matters' not in body.lower() and len(body) > 10:
|
||||||
now = int(time.time())
|
now = int(time.time())
|
||||||
cutoff = now - 60 * 60 * 24
|
cutoff = now - 60 * 60 * 24
|
||||||
|
|
||||||
|
@ -520,24 +517,12 @@ def api_comment(v):
|
||||||
|
|
||||||
|
|
||||||
if not v.shadowbanned:
|
if not v.shadowbanned:
|
||||||
notify_users = NOTIFY_USERS(body_html, v.id)
|
notify_users = NOTIFY_USERS(body_html, v)
|
||||||
|
|
||||||
for x in g.db.query(Subscription.user_id).filter_by(submission_id=c.parent_submission).all(): notify_users.add(x[0])
|
for x in g.db.query(Subscription.user_id).filter_by(submission_id=c.parent_submission).all(): notify_users.add(x[0])
|
||||||
|
|
||||||
if parent.author.id not in [v.id, BASEDBOT_ID, AUTOJANNY_ID, SNAPPY_ID, LONGPOSTBOT_ID, ZOZBOT_ID, AUTOPOLLER_ID]: notify_users.add(parent.author.id)
|
if parent.author.id not in [v.id, BASEDBOT_ID, AUTOJANNY_ID, SNAPPY_ID, LONGPOSTBOT_ID, ZOZBOT_ID, AUTOPOLLER_ID]: notify_users.add(parent.author.id)
|
||||||
|
|
||||||
soup = BeautifulSoup(body_html, features="html.parser")
|
|
||||||
mentions = soup.find_all("a", href=re.compile("^/@(\w+)"))
|
|
||||||
|
|
||||||
for mention in mentions:
|
|
||||||
username = mention["href"].split("@")[1]
|
|
||||||
|
|
||||||
user = g.db.query(User).filter_by(username=username).first()
|
|
||||||
|
|
||||||
if user:
|
|
||||||
if v.any_block_exists(user): continue
|
|
||||||
if user.id != v.id: notify_users.add(user.id)
|
|
||||||
|
|
||||||
for x in notify_users:
|
for x in notify_users:
|
||||||
n = Notification(comment_id=c.id, user_id=x)
|
n = Notification(comment_id=c.id, user_id=x)
|
||||||
g.db.add(n)
|
g.db.add(n)
|
||||||
|
@ -628,10 +613,7 @@ def edit_comment(cid, v):
|
||||||
for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|webp|PNG|JPG|JPEG|GIF|WEBP|9999))', body, re.MULTILINE):
|
for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|webp|PNG|JPG|JPEG|GIF|WEBP|9999))', body, re.MULTILINE):
|
||||||
if "wikipedia" not in i.group(1): body = body.replace(i.group(1), f'![]({i.group(1)})')
|
if "wikipedia" not in i.group(1): body = body.replace(i.group(1), f'![]({i.group(1)})')
|
||||||
|
|
||||||
if v.agendaposter and not v.marseyawarded:
|
if v.agendaposter and not v.marseyawarded: body = torture_ap(body, v.username)
|
||||||
for k, l in AJ_REPLACEMENTS.items(): body = body.replace(k, l)
|
|
||||||
body = body.replace(' I ', f' @{v.username} ').replace(' i ', f' @{v.username} ')
|
|
||||||
body = censor_slurs2(body).replace(' ME ', f' @{v.username} ').replace(' me ', f' @{v.username} ')
|
|
||||||
|
|
||||||
if not c.options:
|
if not c.options:
|
||||||
for i in re.finditer('\s*\$\$([^\$\n]+)\$\$\s*', body):
|
for i in re.finditer('\s*\$\$([^\$\n]+)\$\$\s*', body):
|
||||||
|
@ -798,22 +780,7 @@ def edit_comment(cid, v):
|
||||||
|
|
||||||
g.db.add(c)
|
g.db.add(c)
|
||||||
|
|
||||||
notify_users = NOTIFY_USERS(body_html, v.id)
|
notify_users = NOTIFY_USERS(body_html, v)
|
||||||
soup = BeautifulSoup(body_html, features="html.parser")
|
|
||||||
mentions = soup.find_all("a", href=re.compile("^/@(\w+)"))
|
|
||||||
|
|
||||||
if len(mentions) > 0:
|
|
||||||
for mention in mentions:
|
|
||||||
username = mention["href"].split("@")[1]
|
|
||||||
|
|
||||||
user = g.db.query(User).filter_by(username=username).first()
|
|
||||||
|
|
||||||
if user:
|
|
||||||
if v.any_block_exists(user): continue
|
|
||||||
if user.id != v.id: notify_users.add(user.id)
|
|
||||||
|
|
||||||
|
|
||||||
g.db.flush()
|
|
||||||
|
|
||||||
for x in notify_users:
|
for x in notify_users:
|
||||||
notif = g.db.query(Notification).filter_by(comment_id=c.id, user_id=x).first()
|
notif = g.db.query(Notification).filter_by(comment_id=c.id, user_id=x).first()
|
||||||
|
|
|
@ -58,11 +58,6 @@ def publish(pid, v):
|
||||||
g.db.add(post)
|
g.db.add(post)
|
||||||
|
|
||||||
notify_users = NOTIFY_USERS(f'{post.body_html}{post.title}', v.id)
|
notify_users = NOTIFY_USERS(f'{post.body_html}{post.title}', v.id)
|
||||||
soup = BeautifulSoup(post.body_html, features="html.parser")
|
|
||||||
for mention in soup.find_all("a", href=re.compile("^/@(\w+)")):
|
|
||||||
username = mention["href"].split("@")[1]
|
|
||||||
user = g.db.query(User).filter_by(username=username).first()
|
|
||||||
if user and not v.any_block_exists(user) and user.id != v.id: notify_users.add(user.id)
|
|
||||||
|
|
||||||
cid = notif_comment(f"@{v.username} has mentioned you: [{post.title}]({post.permalink})")
|
cid = notif_comment(f"@{v.username} has mentioned you: [{post.title}]({post.permalink})")
|
||||||
for x in notify_users:
|
for x in notify_users:
|
||||||
|
@ -429,10 +424,7 @@ def edit_post(pid, v):
|
||||||
elif len(body) > 140: return {"error":"You have to type less than 140 characters!"}, 403
|
elif len(body) > 140: return {"error":"You have to type less than 140 characters!"}, 403
|
||||||
|
|
||||||
if title != p.title:
|
if title != p.title:
|
||||||
if v.agendaposter and not v.marseyawarded:
|
if v.agendaposter and not v.marseyawarded: title = torture_ap(title, v.username)
|
||||||
for k, l in AJ_REPLACEMENTS.items(): title = title.replace(k, l)
|
|
||||||
title = title.replace(' I ', f' @{v.username} ').replace(' i ', f' @{v.username} ')
|
|
||||||
title = censor_slurs2(title).replace(' ME ', f' @{v.username} ').replace(' me ', f' @{v.username} ')
|
|
||||||
|
|
||||||
title_html = filter_emojis_only(title)
|
title_html = filter_emojis_only(title)
|
||||||
if v.marseyawarded and len(list(re.finditer('>[^<\s+]|[^>\s+]<', title_html))) > 0: return {"error":"You can only type marseys!"}, 403
|
if v.marseyawarded and len(list(re.finditer('>[^<\s+]|[^>\s+]<', title_html))) > 0: return {"error":"You can only type marseys!"}, 403
|
||||||
|
@ -457,10 +449,7 @@ def edit_post(pid, v):
|
||||||
for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|webp|PNG|JPG|JPEG|GIF|WEBP|9999))', body, re.MULTILINE):
|
for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|webp|PNG|JPG|JPEG|GIF|WEBP|9999))', body, re.MULTILINE):
|
||||||
if "wikipedia" not in i.group(1): body = body.replace(i.group(1), f'![]({i.group(1)})')
|
if "wikipedia" not in i.group(1): body = body.replace(i.group(1), f'![]({i.group(1)})')
|
||||||
|
|
||||||
if v.agendaposter and not v.marseyawarded:
|
if v.agendaposter and not v.marseyawarded: body = torture_ap(body, v.username)
|
||||||
for k, l in AJ_REPLACEMENTS.items(): body = body.replace(k, l)
|
|
||||||
body = body.replace(' I ', f' @{v.username} ').replace(' i ', f' @{v.username} ')
|
|
||||||
body = censor_slurs2(body).replace(' ME ', f' @{v.username} ').replace(' me ', f' @{v.username} ')
|
|
||||||
|
|
||||||
if not p.options.count():
|
if not p.options.count():
|
||||||
for i in re.finditer('\s*\$\$([^\$\n]+)\$\$\s*', body):
|
for i in re.finditer('\s*\$\$([^\$\n]+)\$\$\s*', body):
|
||||||
|
@ -561,10 +550,6 @@ def edit_post(pid, v):
|
||||||
notify_users = NOTIFY_USERS(f'{body_html}{title}', v.id)
|
notify_users = NOTIFY_USERS(f'{body_html}{title}', v.id)
|
||||||
|
|
||||||
soup = BeautifulSoup(body_html, features="html.parser")
|
soup = BeautifulSoup(body_html, features="html.parser")
|
||||||
for mention in soup.find_all("a", href=re.compile("^/@(\w+)")):
|
|
||||||
username = mention["href"].split("@")[1]
|
|
||||||
user = g.db.query(User).filter_by(username=username).first()
|
|
||||||
if user and not v.any_block_exists(user) and user.id != v.id: notify_users.add(user.id)
|
|
||||||
|
|
||||||
cid = notif_comment(f"@{v.username} has mentioned you: [{p.title}]({p.permalink})")
|
cid = notif_comment(f"@{v.username} has mentioned you: [{p.title}]({p.permalink})")
|
||||||
for x in notify_users:
|
for x in notify_users:
|
||||||
|
@ -727,10 +712,7 @@ def submit_post(v):
|
||||||
|
|
||||||
url = request.values.get("url", "").strip()
|
url = request.values.get("url", "").strip()
|
||||||
|
|
||||||
if v.agendaposter and not v.marseyawarded:
|
if v.agendaposter and not v.marseyawarded: title = torture_ap(title, v.username)
|
||||||
for k, l in AJ_REPLACEMENTS.items(): title = title.replace(k, l)
|
|
||||||
title = title.replace(' I ', f' @{v.username} ').replace(' i ', f' @{v.username} ')
|
|
||||||
title = censor_slurs2(title).replace(' ME ', f' @{v.username} ').replace(' me ', f' @{v.username} ')
|
|
||||||
|
|
||||||
title_html = filter_emojis_only(title)
|
title_html = filter_emojis_only(title)
|
||||||
body = request.values.get("body", "").strip()
|
body = request.values.get("body", "").strip()
|
||||||
|
@ -934,10 +916,7 @@ def submit_post(v):
|
||||||
options.append(i.group(1))
|
options.append(i.group(1))
|
||||||
body = body.replace(i.group(0), "")
|
body = body.replace(i.group(0), "")
|
||||||
|
|
||||||
if v.agendaposter and not v.marseyawarded:
|
if v.agendaposter and not v.marseyawarded: body = torture_ap(body, v.username)
|
||||||
for k, l in AJ_REPLACEMENTS.items(): body = body.replace(k, l)
|
|
||||||
body = body.replace(' I ', f' @{v.username} ').replace(' i ', f' @{v.username} ')
|
|
||||||
body = censor_slurs2(body).replace(' ME ', f' @{v.username} ').replace(' me ', f' @{v.username} ')
|
|
||||||
|
|
||||||
if request.files.get("file2") and request.headers.get("cf-ipcountry") != "T1":
|
if request.files.get("file2") and request.headers.get("cf-ipcountry") != "T1":
|
||||||
file=request.files["file2"]
|
file=request.files["file2"]
|
||||||
|
@ -1058,12 +1037,7 @@ def submit_post(v):
|
||||||
|
|
||||||
if not new_post.private:
|
if not new_post.private:
|
||||||
|
|
||||||
notify_users = NOTIFY_USERS(f'{body_html}{title}', v.id)
|
notify_users = NOTIFY_USERS(f'{body_html}{title}', v)
|
||||||
soup = BeautifulSoup(body_html, features="html.parser")
|
|
||||||
for mention in soup.find_all("a", href=re.compile("^/@(\w+)")):
|
|
||||||
username = mention["href"].split("@")[1]
|
|
||||||
user = g.db.query(User).filter_by(username=username).first()
|
|
||||||
if user and not v.any_block_exists(user) and user.id != v.id: notify_users.add(user.id)
|
|
||||||
|
|
||||||
cid = notif_comment(f"@{v.username} has mentioned you: [{title}]({new_post.permalink})")
|
cid = notif_comment(f"@{v.username} has mentioned you: [{title}]({new_post.permalink})")
|
||||||
for x in notify_users:
|
for x in notify_users:
|
||||||
|
@ -1338,7 +1312,9 @@ def api_pin_post(post_id, v):
|
||||||
if v.id != post.author_id: return {"error": "Only the post author's can do that!"}
|
if v.id != post.author_id: return {"error": "Only the post author's can do that!"}
|
||||||
post.is_pinned = not post.is_pinned
|
post.is_pinned = not post.is_pinned
|
||||||
g.db.add(post)
|
g.db.add(post)
|
||||||
g.db.commit()
|
|
||||||
|
|
||||||
|
cache.delete_memoized(User.userpagelisting)
|
||||||
|
|
||||||
|
g.db.commit()
|
||||||
if post.is_pinned: return {"message": "Post pinned!"}
|
if post.is_pinned: return {"message": "Post pinned!"}
|
||||||
else: return {"message": "Post unpinned!"}
|
else: return {"message": "Post unpinned!"}
|
|
@ -217,12 +217,7 @@ def settings_profile_post(v):
|
||||||
error="Your friends list is too long")
|
error="Your friends list is too long")
|
||||||
|
|
||||||
|
|
||||||
notify_users = NOTIFY_USERS(friends_html, v.id)
|
notify_users = NOTIFY_USERS(friends_html, v)
|
||||||
soup = BeautifulSoup(friends_html, features="html.parser")
|
|
||||||
for mention in soup.find_all("a", href=re.compile("^/@(\w+)")):
|
|
||||||
username = mention["href"].split("@")[1]
|
|
||||||
user = g.db.query(User).filter_by(username=username).first()
|
|
||||||
if user and not v.any_block_exists(user) and user.id != v.id: notify_users.add(user.id)
|
|
||||||
|
|
||||||
cid = notif_comment(f"@{v.username} has added you to their friends list!")
|
cid = notif_comment(f"@{v.username} has added you to their friends list!")
|
||||||
|
|
||||||
|
@ -264,12 +259,7 @@ def settings_profile_post(v):
|
||||||
error="Your enemies list is too long")
|
error="Your enemies list is too long")
|
||||||
|
|
||||||
|
|
||||||
notify_users = NOTIFY_USERS(enemies_html, v.id)
|
notify_users = NOTIFY_USERS(enemies_html, v)
|
||||||
soup = BeautifulSoup(enemies_html, features="html.parser")
|
|
||||||
for mention in soup.find_all("a", href=re.compile("^/@(\w+)")):
|
|
||||||
username = mention["href"].split("@")[1]
|
|
||||||
user = g.db.query(User).filter_by(username=username).first()
|
|
||||||
if user and not v.any_block_exists(user) and user.id != v.id: notify_users.add(user.id)
|
|
||||||
|
|
||||||
cid = notif_comment(f"@{v.username} has added you to their enemies list!")
|
cid = notif_comment(f"@{v.username} has added you to their enemies list!")
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<div class="modal fade" id="gifModal" tabindex="-1" role="dialog" aria-labelledby="gifModalTitle" aria-hidden="true">
|
<div class="modal fade" id="gifModal" tabindex="-1" role="dialog" aria-labelledby="gifModalTitle" aria-hidden="true">
|
||||||
<div class="modal-dialog modal-dialog-scrollable modal-dialog-centered p-5" role="document">
|
<div class="modal-dialog modal-dialog-scrollable modal-dialog-centered p-5" style="max-width:100% !important" role="document">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="modal-header border-bottom-0 shadow-md p-3">
|
<div class="modal-header border-bottom-0 shadow-md p-3">
|
||||||
<div class="form-group d-flex align-items-center w-100 mb-0">
|
<div class="form-group d-flex align-items-center w-100 mb-0">
|
||||||
|
|
|
@ -124,7 +124,7 @@
|
||||||
<ul class="pagination pagination-sm mb-0">
|
<ul class="pagination pagination-sm mb-0">
|
||||||
{% if page>1 %}
|
{% if page>1 %}
|
||||||
<li class="page-item">
|
<li class="page-item">
|
||||||
<small><a class="page-link" href="/log?page={{page+1}}{% if admin %}&admin={{admin}}{% endif %}{% if type %}&kind={{type}}{% endif %}" tabindex="-1">Prev</a></small>
|
<small><a class="page-link" href="/log?page={{page-1}}{% if admin %}&admin={{admin}}{% endif %}{% if type %}&kind={{type}}{% endif %}" tabindex="-1">Prev</a></small>
|
||||||
</li>
|
</li>
|
||||||
{% else %}
|
{% else %}
|
||||||
<li class="page-item disabled"><span class="page-link">Prev</span></li>
|
<li class="page-item disabled"><span class="page-link">Prev</span></li>
|
||||||
|
|
|
@ -156,8 +156,6 @@
|
||||||
<a class="btn btn-primary" href="javascript:void(0)" onclick="toggleElement('profile-toggleable', 'bux-transfer')">Gift Marseybux</a>
|
<a class="btn btn-primary" href="javascript:void(0)" onclick="toggleElement('profile-toggleable', 'bux-transfer')">Gift Marseybux</a>
|
||||||
|
|
||||||
{% if v.admin_level > 2 %}
|
{% if v.admin_level > 2 %}
|
||||||
<a id="unadmin" class="{% if u.admin_level < 2 %}d-none{% endif %} btn btn-primary" href="javascript:void(0)" onclick="post_toast('/@{{u.username}}/remove_admin')">Remove admin</a>
|
|
||||||
|
|
||||||
<a id="memeadmin" class="{% if u.admin_level == 1%}d-none{% endif %} btn btn-primary" href="javascript:void(0)" onclick="post_toast2('/@{{u.username}}/make_meme_admin','memeadmin','unmemeadmin')">Make meme admin</a>
|
<a id="memeadmin" class="{% if u.admin_level == 1%}d-none{% endif %} btn btn-primary" href="javascript:void(0)" onclick="post_toast2('/@{{u.username}}/make_meme_admin','memeadmin','unmemeadmin')">Make meme admin</a>
|
||||||
<a id="unmemeadmin" class="{% if u.admin_level != 1 %}d-none{% endif %} btn btn-primary" href="javascript:void(0)" onclick="post_toast2('/@{{u.username}}/remove_meme_admin','memeadmin','unmemeadmin')">Remove meme admin</a>
|
<a id="unmemeadmin" class="{% if u.admin_level != 1 %}d-none{% endif %} btn btn-primary" href="javascript:void(0)" onclick="post_toast2('/@{{u.username}}/remove_meme_admin','memeadmin','unmemeadmin')">Remove meme admin</a>
|
||||||
|
|
||||||
|
@ -441,8 +439,6 @@
|
||||||
<a class="btn btn-primary" href="javascript:void(0)" onclick="toggleElement('profile-toggleable', 'bux-transfer-mobile')">Gift Marseybux</a>
|
<a class="btn btn-primary" href="javascript:void(0)" onclick="toggleElement('profile-toggleable', 'bux-transfer-mobile')">Gift Marseybux</a>
|
||||||
|
|
||||||
{% if v.admin_level > 2 %}
|
{% if v.admin_level > 2 %}
|
||||||
<a id="unadmin2" class="{% if u.admin_level < 2 %}d-none{% endif %} btn btn-primary" href="javascript:void(0)" onclick="post_toast('/@{{u.username}}/remove_admin')">Remove admin</a>
|
|
||||||
|
|
||||||
<a id="memeadmin2" class="{% if u.admin_level == 1%}d-none{% endif %} btn btn-primary" href="javascript:void(0)" onclick="post_toast2('/@{{u.username}}/make_meme_admin','memeadmin2','unmemeadmin2')">Make meme admin</a>
|
<a id="memeadmin2" class="{% if u.admin_level == 1%}d-none{% endif %} btn btn-primary" href="javascript:void(0)" onclick="post_toast2('/@{{u.username}}/make_meme_admin','memeadmin2','unmemeadmin2')">Make meme admin</a>
|
||||||
<a id="unmemeadmin2" class="{% if u.admin_level != 1 %}d-none{% endif %} btn btn-primary" href="javascript:void(0)" onclick="post_toast2('/@{{u.username}}/remove_meme_admin','memeadmin2','unmemeadmin2')">Remove meme admin</a>
|
<a id="unmemeadmin2" class="{% if u.admin_level != 1 %}d-none{% endif %} btn btn-primary" href="javascript:void(0)" onclick="post_toast2('/@{{u.username}}/remove_meme_admin','memeadmin2','unmemeadmin2')">Remove meme admin</a>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue