remotes/1693045480750635534/spooky-22
Aevann1 2022-02-26 15:46:53 +02:00
parent c8543c80d2
commit 0ee3c2b5c8
1 changed files with 76 additions and 76 deletions

View File

@ -1291,92 +1291,93 @@ def submit_post(v, sub=None):
n = Notification(comment_id=c_jannied.id, user_id=v.id) n = Notification(comment_id=c_jannied.id, user_id=v.id)
g.db.add(n) g.db.add(n)
if post.sub == 'dankchristianmemes': if not (post.sub and g.db.query(Exile.user_id).filter_by(user_id=SNAPPY_ID, sub=post.sub)):
body = random.choice(christian_emojis) if post.sub == 'dankchristianmemes':
elif v.id == CARP_ID: body = random.choice(christian_emojis)
if random.random() < 0.02: body = "i love you carp" elif v.id == CARP_ID:
else: body = ":#marseyfuckoffcarp:" if random.random() < 0.02: body = "i love you carp"
elif v.id == LAWLZ_ID: else: body = ":#marseyfuckoffcarp:"
if random.random() < 0.5: body = "wow, this lawlzpost sucks!" elif v.id == LAWLZ_ID:
else: body = "wow, a good lawlzpost for once!" if random.random() < 0.5: body = "wow, this lawlzpost sucks!"
else: else: body = "wow, a good lawlzpost for once!"
body = random.choice(snappyquotes) else:
if body.startswith(''): body = random.choice(snappyquotes)
body = body[1:] if body.startswith(''):
vote = Vote(user_id=SNAPPY_ID, body = body[1:]
vote_type=-1, vote = Vote(user_id=SNAPPY_ID,
submission_id=post.id, vote_type=-1,
real = True submission_id=post.id,
) real = True
g.db.add(vote) )
post.downvotes += 1 g.db.add(vote)
if body.startswith('OP is a Trump supporter'): post.downvotes += 1
flag = Flag(post_id=post.id, user_id=SNAPPY_ID, reason='Trump supporter') if body.startswith('OP is a Trump supporter'):
g.db.add(flag) flag = Flag(post_id=post.id, user_id=SNAPPY_ID, reason='Trump supporter')
elif body.startswith(''): g.db.add(flag)
body = body[1:] elif body.startswith(''):
vote = Vote(user_id=SNAPPY_ID, body = body[1:]
vote_type=1, vote = Vote(user_id=SNAPPY_ID,
submission_id=post.id, vote_type=1,
real = True submission_id=post.id,
) real = True
g.db.add(vote) )
post.upvotes += 1 g.db.add(vote)
post.upvotes += 1
body += "\n\n" body += "\n\n"
if post.url: if post.url:
if post.url.startswith('https://old.reddit.com/r/'): if post.url.startswith('https://old.reddit.com/r/'):
rev = post.url.replace('https://old.reddit.com/', '') rev = post.url.replace('https://old.reddit.com/', '')
rev = f"* [unddit.com](https://unddit.com/{rev})\n" rev = f"* [unddit.com](https://unddit.com/{rev})\n"
else: rev = '' else: rev = ''
newposturl = post.url newposturl = post.url
if newposturl.startswith('/'): newposturl = f"{SITE_FULL}{newposturl}" if newposturl.startswith('/'): newposturl = f"{SITE_FULL}{newposturl}"
body += f"Snapshots:\n\n{rev}* [archive.org](https://web.archive.org/{newposturl})\n* [archive.ph](https://archive.ph/?url={quote(newposturl)}&run=1) (click to archive)\n\n" body += f"Snapshots:\n\n{rev}* [archive.org](https://web.archive.org/{newposturl})\n* [archive.ph](https://archive.ph/?url={quote(newposturl)}&run=1) (click to archive)\n\n"
gevent.spawn(archiveorg, newposturl) gevent.spawn(archiveorg, newposturl)
url_regex = '<a href=\"(https?:\/\/[a-z]{1,20}\.[^\"]+)\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">(.*?)<\/a>' url_regex = '<a href=\"(https?:\/\/[a-z]{1,20}\.[^\"]+)\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">(.*?)<\/a>'
for url_match in list(re.finditer(url_regex, post.body_html))[:20]: for url_match in list(re.finditer(url_regex, post.body_html))[:20]:
href = url_match.group(1) href = url_match.group(1)
if not href: continue if not href: continue
title = url_match.group(2) title = url_match.group(2)
if "Snapshots:\n\n" not in body: body += "Snapshots:\n\n" if "Snapshots:\n\n" not in body: body += "Snapshots:\n\n"
if f'**[{title}]({href})**:\n\n' not in body: if f'**[{title}]({href})**:\n\n' not in body:
body += f'**[{title}]({href})**:\n\n' body += f'**[{title}]({href})**:\n\n'
if href.startswith('https://old.reddit.com/'): if href.startswith('https://old.reddit.com/'):
body += f'* [unddit.com](https://unddit.com/{href.replace("https://old.reddit.com/", "")})\n' body += f'* [unddit.com](https://unddit.com/{href.replace("https://old.reddit.com/", "")})\n'
body += f'* [archive.org](https://web.archive.org/{href})\n' body += f'* [archive.org](https://web.archive.org/{href})\n'
body += f'* [archive.ph](https://archive.ph/?url={quote(href)}&run=1) (click to archive)\n\n' body += f'* [archive.ph](https://archive.ph/?url={quote(href)}&run=1) (click to archive)\n\n'
gevent.spawn(archiveorg, href) gevent.spawn(archiveorg, href)
body_html = sanitize(body) body_html = sanitize(body)
if len(body_html) < 40000: if len(body_html) < 40000:
c = Comment(author_id=SNAPPY_ID, c = Comment(author_id=SNAPPY_ID,
distinguish_level=6, distinguish_level=6,
parent_submission=post.id, parent_submission=post.id,
level=1, level=1,
over_18=False, over_18=False,
is_bot=True, is_bot=True,
app_id=None, app_id=None,
body_html=body_html body_html=body_html
) )
g.db.add(c) g.db.add(c)
snappy = g.db.query(User).filter_by(id = SNAPPY_ID).one_or_none() snappy.comment_count += 1
snappy.comment_count += 1 snappy.coins += 1
snappy.coins += 1 g.db.add(snappy)
g.db.add(snappy)
if body.startswith('!slots1000'):
if body.startswith('!slots1000'): check_for_slots_command(body, snappy, c)
check_for_slots_command(body, snappy, c)
post.comment_count += 1 post.comment_count += 1
if len(body_html) < 40000: post.replies = [c]
v.post_count = g.db.query(Submission.id).filter_by(author_id=v.id, is_banned=False, deleted_utc=0).count() v.post_count = g.db.query(Submission.id).filter_by(author_id=v.id, is_banned=False, deleted_utc=0).count()
g.db.add(v) g.db.add(v)
@ -1407,7 +1408,6 @@ def submit_post(v, sub=None):
post.voted = 1 post.voted = 1
if 'megathread' in post.title.lower(): sort = 'new' if 'megathread' in post.title.lower(): sort = 'new'
else: sort = v.defaultsortingcomments else: sort = v.defaultsortingcomments
if len(body_html) < 40000: post.replies = [c]
return render_template('submission.html', v=v, p=post, sort=sort, render_replies=True, offset=0, success=True, sub=post.subr) return render_template('submission.html', v=v, p=post, sort=sort, render_replies=True, offset=0, success=True, sub=post.subr)