check more pages

This commit is contained in:
bakatrouble 2023-10-27 18:28:44 +03:00
parent 897c0f8ef5
commit 3c9973e1e7

27
main.py
View File

@ -122,20 +122,21 @@ async def check_updates():
for tl_idx in range(0, len(tag_list), 40): for tl_idx in range(0, len(tag_list), 40):
tags = ' '.join(f'~{tag}' for tag in tag_list[tl_idx: tl_idx + 40]) tags = ' '.join(f'~{tag}' for tag in tag_list[tl_idx: tl_idx + 40])
logging.warning(tags) logging.warning(tags)
posts = []
for page in range(1, 11): for page in range(1, 11):
posts = await e621.get_posts(tags, page) posts.extend(await e621.get_posts(tags, page))
if not posts: if not posts:
return return
already_sent: List = await redis.smismember('e621:sent', [p.id for p in posts]) already_sent: List = await redis.smismember('e621:sent', [p.id for p in posts])
# last_index = len(posts) # last_index = len(posts)
# if already_sent.count(True): # if already_sent.count(True):
# last_index = already_sent.index(True) # last_index = already_sent.index(True)
# await redis.sadd('e621:sent', *[posts[i].id for i in range(last_index, len(posts))]) # await redis.sadd('e621:sent', *[posts[i].id for i in range(last_index, len(posts))])
for i in list(range(len(posts)))[::-1]: for i in list(range(len(posts)))[::-1]:
if already_sent[i]: if already_sent[i]:
continue continue
await send_post(posts[i], tag_list) await send_post(posts[i], tag_list)
await sleep(1) await sleep(1)
@dp.message(filters.Command('add'), ChatFilter) @dp.message(filters.Command('add'), ChatFilter)