This commit is contained in:
Aevann1 2022-01-28 22:55:59 +02:00
parent b210e9604d
commit 587e945d6e
13 changed files with 78 additions and 28 deletions

View file

@ -660,7 +660,62 @@ def thumbnail_thread(pid):
db.add(post)
db.commit()
for i in requests.get('https://api.pushshift.io/reddit/submission/search?html_decode=true&q=rdrama&size=100').json()["data"]:
print(i)
body_html = sanitize(f'New rdrama mention: https://old.reddit.com{i["permalink"]}', noimages=True)
existing_comment = db.query(Comment.id).filter_by(author_id=NOTIFICATIONS_ID, parent_submission=None, distinguish_level=6, body_html=body_html, level=1, sentto=0).first()
if existing_comment: break
print('sex')
new_comment = Comment(author_id=NOTIFICATIONS_ID,
parent_submission=None,
distinguish_level=6,
body_html=body_html,
level=1,
sentto=0,
)
db.add(new_comment)
db.flush()
admins = db.query(User).filter(User.admin_level > 0).all()
for admin in admins:
notif = Notification(comment_id=new_comment.id, user_id=admin.id)
db.add(notif)
break
for i in requests.get('https://api.pushshift.io/reddit/comment/search?html_decode=true&q=rdrama&size=100').json()["data"]:
print(i)
body_html = sanitize(f'New rdrama mention: https://old.reddit.com{i["permalink"]}', noimages=True)
existing_comment = db.query(Comment.id).filter_by(author_id=NOTIFICATIONS_ID, parent_submission=None, distinguish_level=6, body_html=body_html, level=1, sentto=0).first()
if existing_comment: break
print('ffugq')
new_comment = Comment(author_id=NOTIFICATIONS_ID,
parent_submission=None,
distinguish_level=6,
body_html=body_html,
level=1,
sentto=0,
)
db.add(new_comment)
db.flush()
admins = db.query(User).filter(User.admin_level > 0).all()
for admin in admins:
notif = Notification(comment_id=new_comment.id, user_id=admin.id)
db.add(notif)
break
db.commit()
db.close()
stdout.flush()
return