forked from rDrama/rDrama
1
0
Fork 0

restore offsite_mentions_task for normal every-5-minute usage

master
Aevann 2023-09-11 20:55:46 +03:00
parent 0ccbe7aad3
commit b0f6e81ccc
1 changed files with 3 additions and 9 deletions

View File

@ -38,14 +38,8 @@ def get_mentions(cache, queries, reddit_notifs_users=False):
data = []
for query in queries:
last_processed = 9999999999
while True:
url = f'https://api.pullpush.io/reddit/search/{kind}?q={query}&before={last_processed}'
new_data = requests.get(url, headers=HEADERS, timeout=5, proxies=proxies).json()['data']
data += new_data
try: last_processed = int(new_data[-1]['created_utc'])
except: break
if last_processed < 1682872206 or len(new_data) < 100: break
url = f'https://api.pullpush.io/reddit/search/{kind}?q={query}'
data += requests.get(url, headers=HEADERS, timeout=5, proxies=proxies).json()['data']
data = sorted(data, key=lambda x: x['created_utc'], reverse=True)
@ -94,7 +88,7 @@ def notify_mentions(mentions, send_to=None, mention_str='site mention'):
author_id=const.AUTOJANNY_ID,
parent_post=None,
body_html=notif_text).one_or_none()
if existing_comment: continue
if existing_comment: break
new_comment = Comment(
author_id=const.AUTOJANNY_ID,