add check_aliases command
This commit is contained in:
21
main.py
21
main.py
@@ -297,6 +297,27 @@ async def list_tags(msg: Message):
|
||||
await msg.reply(f'Monitored tags:\n\n{lines}')
|
||||
|
||||
|
||||
@dp.message(filters.Command('check_aliases'), ChatFilter)
|
||||
async def check_aliases(msg: Message):
|
||||
tags = [t.decode() for t in await redis.smembers(REDIS_SUBS_KEY)]
|
||||
tags.sort()
|
||||
progress = 0
|
||||
lines = []
|
||||
|
||||
resp = await msg.reply('tmp')
|
||||
|
||||
async def send_progress():
|
||||
await resp.edit_text(f'Checking aliases {progress}/{len(tags)}\n\n'
|
||||
f'{"\n".join(lines)}', parse_mode=ParseMode.HTML)
|
||||
|
||||
for sub in tags:
|
||||
for subtag in sub.split():
|
||||
if replacements := await e621.get_tag_aliases(subtag):
|
||||
lines.append(f'- {subtag} -> {replacements[0]}, (<code>{sub}</code>)')
|
||||
progress += 1
|
||||
await send_progress()
|
||||
|
||||
|
||||
@dp.message(filters.Command('update'), ChatFilter)
|
||||
async def update(msg: Message):
|
||||
await check_updates()
|
||||
|
Reference in New Issue
Block a user