Merge branch 'master' into mistletoe

remotes/1693045480750635534/spooky-22
kek7198 2021-12-02 19:16:33 -06:00
commit 6e9c7e6028
12 changed files with 64 additions and 91 deletions

View File

@ -129,9 +129,6 @@ class Comment(Base):
@lazy
def edited_string(self):
if not self.edited_utc:
return "never"
age = int(time.time()) - self.edited_utc
if age < 60:
@ -148,12 +145,15 @@ class Comment(Base):
now = time.gmtime()
ctd = time.gmtime(self.edited_utc)
months = now.tm_mon - ctd.tm_mon + 12 * (now.tm_year - ctd.tm_year)
if now.tm_mday < ctd.tm_mday:
months -= 1
if months < 12:
return f"{months}mo ago"
else:
years = now.tm_year - ctd.tm_year
years = int(months / 12)
return f"{years}yr ago"
@property
@ -305,7 +305,7 @@ class Comment(Base):
return data
def realbody(self, v):
if self.post and self.post.club and not (v and v.paid_dues) and not (v and v.id == self.author_id): return f"<p>{cc} ONLY</p>"
if self.post and self.post.club and not (v and (v.paid_dues or v.id in [self.author_id, self.post.author_id])): return f"<p>{cc} ONLY</p>"
body = self.body_html
@ -335,14 +335,14 @@ class Comment(Base):
maxupvotes = min(ti, 31)
rand = randint(0, maxupvotes)
if self.upvotes < rand:
self.upvotes += randint(0, 5)
self.upvotes += randint(0, 3)
g.db.add(self)
g.db.commit()
return body
def plainbody(self, v):
if self.post and self.post.club and not (v and v.paid_dues) and not (v and v.id == self.author_id): return f"<p>{cc} ONLY</p>"
if self.post and self.post.club and not (v and (v.paid_dues or v.id in [self.author_id, self.post.author_id])): return f"<p>{cc} ONLY</p>"
body = self.body

View File

@ -319,7 +319,7 @@ class Submission(Base):
else: return ""
def realbody(self, v):
if self.club and not (v and v.paid_dues): return f"<p>{cc} ONLY</p>"
if self.club and not (v and (v.paid_dues or v.id == self.author_id)): return f"<p>{cc} ONLY</p>"
body = self.body_html
body = censor_slurs(body, v)
@ -335,14 +335,14 @@ class Submission(Base):
maxupvotes = min(ti, 27)
rand = random.randint(0, maxupvotes)
if self.upvotes < rand:
self.upvotes += random.randint(0, 5)
self.upvotes += random.randint(0, 3)
g.db.add(self)
g.db.commit()
return body
def plainbody(self, v):
if self.club and not (v and v.paid_dues): return f"<p>{cc} ONLY</p>"
if self.club and not (v and (v.paid_dues or v.id == self.author_id)): return f"<p>{cc} ONLY</p>"
body = self.body
body = censor_slurs(body, v)
@ -357,7 +357,7 @@ class Submission(Base):
@lazy
def realtitle(self, v):
if self.club and not (v and v.paid_dues) and not (v and v.admin_level > 1):
if self.club and not (v and (v.paid_dues or v.id == self.author_id)):
if v: return random.choice(TROLLTITLES).format(username=v.username)
else: return f'{cc} MEMBERS ONLY'
elif self.title_html: title = self.title_html
@ -369,7 +369,7 @@ class Submission(Base):
@lazy
def plaintitle(self, v):
if self.club and not (v and v.paid_dues) and not (v and v.admin_level > 1):
if self.club and not (v and (v.paid_dues or v.id == self.author_id)):
if v: return random.choice(TROLLTITLES).format(username=v.username)
else: return f'{cc} MEMBERS ONLY'
else: title = self.title

View File

@ -127,3 +127,11 @@ def send_admin(vid, text):
for admin in admins:
notif = Notification(comment_id=new_comment.id, user_id=admin.id)
g.db.add(notif)
def NOTIFY_USERS(text, vid):
text = text.lower()
notify_users = set()
for word, id in NOTIFIED_USERS.items():
if id == 0: continue
if word in text and id not in notify_users and vid != id: notify_users.add(id)
return notify_users

View File

@ -130,6 +130,7 @@ WELCOME_MSG = "Hi there! It's me, your soon-to-be favorite rDrama user @carpathi
if SITE == 'rdrama.net':
BASEDBOT_ID = 0
KIPPY_ID = 7150
NOTIFICATIONS_ID = 1046
AUTOJANNY_ID = 2360
SNAPPY_ID = 261
@ -140,6 +141,8 @@ if SITE == 'rdrama.net':
PIZZA_SHILL_ID = 2424
IDIO_ID = 30
CARP_ID = 995
JOAN_ID = 28
AEVANN_ID = 1
LAWLZ_ID = 3833
LLM_ID = 253
DAD_ID = 2513
@ -148,6 +151,7 @@ if SITE == 'rdrama.net':
EMOJI_THREAD = 22479
elif SITE == "pcmemes.net":
BASEDBOT_ID = 800
KIPPY_ID = 1592
NOTIFICATIONS_ID = 1046
AUTOJANNY_ID = 1050
SNAPPY_ID = 261
@ -158,6 +162,8 @@ elif SITE == "pcmemes.net":
PIZZA_SHILL_ID = 0
IDIO_ID = 0
CARP_ID = 0
JOAN_ID = 0
AEVANN_ID = 1
LAWLZ_ID = 0
LLM_ID = 0
DAD_ID = 0
@ -166,6 +172,7 @@ elif SITE == "pcmemes.net":
EMOJI_THREAD = 0
else:
BASEDBOT_ID = 0
KIPPY_ID = 0
NOTIFICATIONS_ID = 1
AUTOJANNY_ID = 2
SNAPPY_ID = 3
@ -176,6 +183,8 @@ else:
PIZZA_SHILL_ID = 0
IDIO_ID = 0
CARP_ID = 0
JOAN_ID = 0
AEVANN_ID = 0
LAWLZ_ID = 0
LLM_ID = 0
DAD_ID = 0
@ -763,4 +772,18 @@ TROLLTITLES = [
"[META] Getting really sick of @{username}s shit",
"Pretty sure this is @{username}'s Reddit account",
"Hey jannies can you please ban @{username}",
]
]
NOTIFIED_USERS = {
'aevan': AEVANN_ID,
'avean': AEVANN_ID,
'joan': JOAN_ID,
'pewkie': JOAN_ID,
'carp': CARP_ID,
'idio3': IDIO_ID,
'idio ': IDIO_ID,
'landlord_messiah': LLM_ID,
'landlordmessiah': LLM_ID,
' llm ': LLM_ID,
'landlet': LLM_ID,
}

View File

@ -182,7 +182,7 @@ def monthly(v):
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):
thing = g.db.query(AwardRelationship).order_by(AwardRelationship.id.desc()).first().id
for u in g.db.query(User).filter(User.patron > 0).all():
if u.patron == 1: procoins = 2000
if u.patron == 1: procoins = 2500
elif u.patron == 2: procoins = 5000
elif u.patron == 3: procoins = 10000
elif u.patron == 4: procoins = 25000

View File

@ -45,7 +45,7 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None):
g.db.add(notif)
g.db.commit()
if comment.post and comment.post.club and not (v and v.paid_dues): abort(403)
if comment.post and comment.post.club and not (v and (v.paid_dues or v.id in [post.author_id, comment.post.author_id])): abort(403)
if not comment.parent_submission and not (v and (comment.author.id == v.id or comment.sentto == v.id)) and not (v and v.admin_level > 1) : abort(403)
@ -142,7 +142,7 @@ def api_comment(v):
parent_fullname = request.values.get("parent_fullname").strip()
parent_post = get_post(parent_submission, v=v)
if parent_post.club and not (v and v.paid_dues): abort(403)
if parent_post.club and not (v and (v.paid_dues or v.id == parent_post.author_id)): abort(403)
if parent_fullname.startswith("t2_"):
parent = parent_post
@ -529,7 +529,7 @@ def api_comment(v):
if not v.shadowbanned:
notify_users = set()
notify_users = NOTIFY_USERS(body_html, v.id)
for x in g.db.query(Subscription.user_id).filter_by(submission_id=c.parent_submission).all(): notify_users.add(x[0])
@ -547,17 +547,6 @@ def api_comment(v):
if v.any_block_exists(user): continue
if user.id != v.id: notify_users.add(user.id)
if request.host == 'pcmemes.net':
if 'kippy' in body_html.lower() and 1592 not in notify_users: notify_users.add(1592)
if request.host in ['rdrama.net','pcmemes.net']:
if ('aevan' in body_html.lower() or 'avean' in body_html.lower()) and 1 not in notify_users: notify_users.add(1)
if request.host == 'rdrama.net':
if ('joan' in body_html.lower() or 'pewkie' in body_html.lower()) and 28 not in notify_users: notify_users.add(28)
if 'carp' in body_html.lower() and 995 not in notify_users:
notify_users.add(995)
notify_users.add(541)
if ('idio3' in body_html.lower() or 'idio ' in body_html.lower()) and 30 not in notify_users: notify_users.add(30)
for x in notify_users:
n = Notification(comment_id=c.id, user_id=x)
g.db.add(n)
@ -805,7 +794,7 @@ def edit_comment(cid, v):
g.db.flush()
notify_users = set()
notify_users = NOTIFY_USERS(body_html, v.id)
soup = BeautifulSoup(body_html, features="html.parser")
mentions = soup.find_all("a", href=re.compile("^/@(\w+)"))
@ -819,17 +808,6 @@ def edit_comment(cid, v):
if v.any_block_exists(user): continue
if user.id != v.id: notify_users.add(user.id)
if request.host == 'pcmemes.net':
if 'kippy' in body_html.lower() and 1592 not in notify_users: notify_users.add(1592)
if request.host in ['rdrama.net','pcmemes.net']:
if ('aevan' in body_html.lower() or 'avean' in body_html.lower()) and 1 not in notify_users: notify_users.add(1)
if request.host == 'rdrama.net':
if ('joan' in body_html.lower() or 'pewkie' in body_html.lower()) and 28 not in notify_users: notify_users.add(28)
if 'carp' in body_html.lower() and 995 not in notify_users:
notify_users.add(995)
notify_users.add(541)
if ('idio3' in body_html.lower() or 'idio ' in body_html.lower()) and 30 not in notify_users: notify_users.add(30)
for x in notify_users:
notif = g.db.query(Notification).filter_by(comment_id=c.id, user_id=x).first()
if not notif:

View File

@ -25,7 +25,7 @@ def feeds_user(sort='hot', t='all'):
doc, tag, text = Doc().tagtext()
with tag("feed", ("xmlns:media","https://search.yahoo.com/mrss/"), xmlns="https://www.w3.org/2005/Atom",):
with tag("feed", ("xmlns:media","http://search.yahoo.com/mrss/"), xmlns="http://www.w3.org/2005/Atom",):
with tag("title", type="text"):
text(f"{sort} posts from {domain}")

View File

@ -7,7 +7,7 @@ from files.helpers.sanitize import *
from files.helpers.filters import *
from files.helpers.markdown import *
from files.helpers.session import *
from files.helpers.alerts import send_notification
from files.helpers.alerts import send_notification, NOTIFY_USERS
from files.helpers.discord import send_message
from files.helpers.const import *
from files.classes import *
@ -55,24 +55,13 @@ def publish(pid, v):
post.private = False
g.db.add(post)
notify_users = set()
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)
if request.host == 'pcmemes.net':
if 'kippy' in f'{post.body_html}{post.title}'.lower() and 1592 not in notify_users: notify_users.add(1592)
if request.host in ['rdrama.net','pcmemes.net']:
if ('aevan' in f'{post.body_html}{post.title}'.lower() or 'avean' in f'{post.body_html}{post.title}'.lower()) and 1 not in notify_users: notify_users.add(1)
if request.host == 'rdrama.net':
if ('joan' in f'{post.body_html}{post.title}'.lower() or 'pewkie' in f'{post.body_html}{post.title}'.lower()) and 28 not in notify_users: notify_users.add(28)
if 'carp' in f'{post.body_html}{post.title}'.lower() and 995 not in notify_users:
notify_users.add(995)
notify_users.add(541)
if ('idio3' in f'{post.body_html}{post.title}'.lower() or 'idio ' in f'{post.body_html}{post.title}'.lower()) and 30 not in notify_users: notify_users.add(30)
for x in notify_users: send_notification(x, f"@{v.username} has mentioned you: http://{site}{post.permalink}")
for follow in v.followers:
@ -125,7 +114,7 @@ def post_id(pid, anything=None, v=None):
post = get_post(pid, v=v)
if post.club and not (v and v.paid_dues) or post.private and not (v and (v.id == post.author_id or v.admin_level > 1)): abort(403)
if post.club and not (v and (v.paid_dues or v.id == post.author_id)) or post.private and not (v and v.id == post.author_id): abort(403)
if v:
@ -371,7 +360,7 @@ def edit_post(pid, v):
g.db.add(n)
notify_users = set()
notify_users = NOTIFY_USERS(f'{body_html}{title}', v.id)
soup = BeautifulSoup(body_html, features="html.parser")
for mention in soup.find_all("a", href=re.compile("^/@(\w+)")):
@ -381,17 +370,6 @@ def edit_post(pid, v):
message = f"@{v.username} has mentioned you: http://{site}{p.permalink}"
if request.host == 'pcmemes.net':
if 'kippy' in f'{body_html}{title}'.lower() and 1592 not in notify_users: notify_users.add(1592)
if request.host in ['rdrama.net','pcmemes.net']:
if ('aevan' in f'{body_html}{title}'.lower() or 'avean' in f'{body_html}{title}'.lower()) and 1 not in notify_users: notify_users.add(1)
if request.host == 'rdrama.net':
if ('joan' in f'{body_html}{title}'.lower() or 'pewkie' in f'{body_html}{title}'.lower()) and 28 not in notify_users: notify_users.add(28)
if 'carp' in f'{body_html}{title}'.lower() and 995 not in notify_users:
notify_users.add(995)
notify_users.add(541)
if ('idio3' in f'{body_html}{title}'.lower() or 'idio ' in f'{body_html}{title}'.lower()) and 30 not in notify_users: notify_users.add(30)
for x in notify_users: send_notification(x, message)
@ -868,24 +846,13 @@ def submit_post(v):
if not new_post.private:
notify_users = set()
notify_users = NOTIFY_USERS(f'{body_html}{title}', v.id)
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)
if request.host == 'pcmemes.net':
if 'kippy' in f'{body_html}{title}'.lower() and 1592 not in notify_users: notify_users.add(1592)
if request.host in ['rdrama.net','pcmemes.net']:
if ('aevan' in f'{body_html}{title}'.lower() or 'avean' in f'{body_html}{title}'.lower()) and 1 not in notify_users: notify_users.add(1)
if request.host == 'rdrama.net':
if ('joan' in f'{body_html}{title}'.lower() or 'pewkie' in f'{body_html}{title}'.lower()) and 28 not in notify_users: notify_users.add(28)
if 'carp' in f'{body_html}{title}'.lower() and 995 not in notify_users:
notify_users.add(995)
notify_users.add(541)
if ('idio3' in f'{body_html}{title}'.lower() or 'idio ' in f'{body_html}{title}'.lower()) and 30 not in notify_users: notify_users.add(30)
for x in notify_users: send_notification(x, f"@{v.username} has mentioned you: http://{site}{new_post.permalink}")
for follow in v.followers:

View File

@ -240,15 +240,12 @@ def settings_profile_post(v):
error="Your friends list is too long")
notify_users = set()
notify_users = NOTIFY_USERS(friends_html, v.id)
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)
if request.host == 'rdrama.net' and ('aevan' in friends_html.lower() or 'avean' in friends_html.lower()) and 1 not in notify_users: notify_users.add(1)
for x in notify_users:
message = f"@{v.username} has added you to their friends list!"
send_notification(x, message)
@ -284,15 +281,13 @@ def settings_profile_post(v):
error="Your enemies list is too long")
notify_users = set()
notify_users = NOTIFY_USERS(enemies_html, v.id)
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)
if request.host == 'rdrama.net' and ('aevan' in enemies_html.lower() or 'avean' in enemies_html.lower()) and 1 not in notify_users: notify_users.add(1)
for x in notify_users:
message = f"@{v.username} has added you to their enemies list!"
send_notification(x, message)
@ -511,7 +506,7 @@ def gumroad(v):
v.patron = tier
if v.discord_id: add_role(v, f"{tier}")
if v.patron == 1: procoins = 2000
if v.patron == 1: procoins = 2500
elif v.patron == 2: procoins = 5000
elif v.patron == 3: procoins = 10000
elif v.patron == 4: procoins = 25000

View File

@ -870,7 +870,7 @@ def fp(v, fp):
v.fp = fp
users = g.db.query(User).filter(User.fp == fp, User.id != v.id).all()
if v.email and v.is_activated:
users += g.db.query(User).filter(User.email == email, User.is_activated, User.id != v.id).all()
users += g.db.query(User).filter(User.email == v.email, User.is_activated, User.id != v.id).all()
for u in users:
li = [v.id, u.id]
existing = g.db.query(Alt).filter(Alt.user1.in_(li), Alt.user2.in_(li)).first()

View File

@ -746,6 +746,7 @@
</div>
</div>
{% endblock %}
{% block pagenav %}
@ -776,13 +777,12 @@
}
</style>
<script defer src="/assets/js/userpage.js?v=72"></script>
{% if v %}
{% include "emoji_modal.html" %}
{% endif %}
<script defer src="/assets/js/userpage.js?v=72"></script>
{% endblock %}
{% block GIFpicker %}

View File

@ -32,4 +32,6 @@
</div>
{% endblock %}
{% block pagenav %}{% endblock %}
{% block pagenav %}
<script defer src="/assets/js/userpage.js?v=72"></script>
{% endblock %}