master
Aevann1 2022-01-17 13:47:30 +02:00
parent b617163a1c
commit 7a9a78c027
7 changed files with 29 additions and 19 deletions

View File

@ -68,7 +68,7 @@ class Submission(Base):
@property
@lazy
def comments(self):
return g.db.query(Comment.author_id, Comment.created_utc, Comment.id).filter_by(parent_submission=self.id)
return g.db.query(Comment.author_id, Comment.created_utc, Comment.id).filter(Submission.parent_submission == self.id, Submission.author_id.notin_((AUTOPOLLER_ID,AUTOBETTER_ID)))
@property
@lazy

View File

@ -141,7 +141,8 @@ if SITE == 'rdrama.net':
AUTOPOLLER_ID = 6176
AUTOBETTER_ID = 7668
TAX_RECEIVER_ID = 995
AUTO_UPVOTE_IDS = (2424,4245)
PIZZASHILL_ID = 2424
HIL_ID = 4245
CRAT_ID = 747
IDIO_ID = 30
CARP_ID = 995
@ -167,7 +168,8 @@ elif SITE == "pcmemes.net":
AUTOPOLLER_ID = 3369
AUTOBETTER_ID = 1867
TAX_RECEIVER_ID = 1592
AUTO_UPVOTE_IDS = ()
PIZZASHILL_ID = 0
HIL_ID = 0
CRAT_ID = 0
IDIO_ID = 0
CARP_ID = 0
@ -193,7 +195,8 @@ else:
AUTOPOLLER_ID = 6
AUTOBETTER_ID = 7
TAX_RECEIVER_ID = 8
AUTO_UPVOTE_IDS = ()
PIZZASHILL_ID = 0
HIL_ID = 0
CRAT_ID = 0
IDIO_ID = 0
CARP_ID = 0

View File

@ -113,14 +113,14 @@ def sanitize(sanitized, noimages=False, alert=False, comment=False):
else:
sanitized = re.sub('(^|\s|\n|<p>)\/?((r|u)\/\w{3,25})', r'\1<a href="https://old.reddit.com/\2" rel="nofollow noopener noreferrer">\2</a>', sanitized)
for i in re.finditer('(^|\s|\n|<p>)@((\w|-){1,25})', sanitized):
for i in re.finditer('(^|\s|\n|<p>)@((\w|-){1,25})($|\s|\n|<\p>)', sanitized):
u = get_user(i.group(2), graceful=True)
if u and (not g.v.any_block_exists(u) or g.v.admin_level > 1):
if noimages:
sanitized = sanitized.replace(i.group(0), f'{i.group(1)}<a href="/id/{u.id}">@{u.username}</a>')
sanitized = sanitized.replace(i.group(0), f'{i.group(1)}<a href="/id/{u.id}">@{u.username}</a>{i.group(4)}')
else:
sanitized = sanitized.replace(i.group(0), f'''{i.group(1)}<a href="/id/{u.id}"><img alt="@{u.username}'s profile picture" loading="lazy" src="/uid/{u.id}/pic" class="pp20">@{u.username}</a>''')
sanitized = sanitized.replace(i.group(0), f'''{i.group(1)}<a href="/id/{u.id}"><img alt="@{u.username}'s profile picture" loading="lazy" src="/uid/{u.id}/pic" class="pp20">@{u.username}</a>{i.group(4)}''')
for i in re.finditer('https://i\.imgur\.com/(([^_]*?)\.(jpg|png|jpeg))', sanitized):

View File

@ -67,6 +67,11 @@ def distribute(v, comment):
for option in post.bet_options: pool += option.upvotes
pool *= 200
autobetter = g.db.query(User).filter_by(id=AUTOBETTER_ID).one_or_none()
autobetter.coins -= pool
if autobetter.coins < 0: autobetter.coins = 0
g.db.add(autobetter)
votes = g.db.query(CommentVote).filter_by(comment_id=comment)
coinsperperson = int(pool / votes.count())
@ -76,11 +81,6 @@ def distribute(v, comment):
u.coins += coinsperperson
add_notif(cid, u.id)
autobetter = g.db.query(User).filter_by(id=AUTOBETTER_ID).one_or_none()
autobetter.coins -= pool
if autobetter.coins < 0: return {"error": "Not enough coins in bool"}, 400
g.db.add(autobetter)
cid = notif_comment(f"You lost the 200 coins you bet on [{post.permalink}]({post.permalink}) :marseylaugh:")
cids = [x.id for x in post.bet_options]
cids.remove(comment)

View File

@ -513,7 +513,7 @@ def api_comment(v):
c.voted = 1
if v.id in AUTO_UPVOTE_IDS:
if v.id == PIZZASHILL_ID:
autovote = CommentVote(user_id=CARP_ID, comment_id=c.id, vote_type=1)
g.db.add(autovote)
autovote = CommentVote(user_id=AEVANN_ID, comment_id=c.id, vote_type=1)
@ -525,6 +525,14 @@ def api_comment(v):
g.db.add(v)
c.upvotes += 3
g.db.add(c)
elif v.id == HIL_ID:
autovote = CommentVote(user_id=CARP_ID, comment_id=c.id, vote_type=1)
g.db.add(autovote)
v.coins += 1
v.truecoins += 1
g.db.add(v)
c.upvotes += 1
g.db.add(c)
g.db.commit()

View File

@ -1065,6 +1065,7 @@ def submit_post(v):
title = url_match.group(5)
if "Snapshots:\n\n" not in body: body += "Snapshots:\n\n"
if f'**[{title}]({href})**:\n\n' in body: continue
body += f'**[{title}]({href})**:\n\n'
if href.startswith('https://old.reddit.com/'):
body += f'* [unddit.com](https://unddit.com/{href.replace("https://old.reddit.com/", "")})\n'
@ -1107,7 +1108,7 @@ def submit_post(v):
send_discord_message(f"https://{site}{new_post.permalink}")
cache.delete_memoized(changeloglist)
if v.id in AUTO_UPVOTE_IDS:
if v.id in (PIZZASHILL_ID, HIL_ID):
autovote = Vote(user_id=CARP_ID, submission_id=new_post.id, vote_type=1)
g.db.add(autovote)
autovote = Vote(user_id=AEVANN_ID, submission_id=new_post.id, vote_type=1)

View File

@ -63,11 +63,9 @@
{% for p in listing %}
<script>
(() => {
{% if not v or v.highlightcomments %}
showNewCommentCounts('{{p.id}}', {{p.comment_count}})
{% endif %}
})()
</script>
{% set ups=p.upvotes %}