From cd556e004cf27a029bd9cd00b45b48f4965f6a67 Mon Sep 17 00:00:00 2001 From: Mole Shang <135e2@135e2.dev> Date: Thu, 9 Mar 2023 00:22:42 +0800 Subject: fix(bot.py): fix for range iteration to prevent duplication of last email in inbox The start value in range() should be inbox_num + 1. Ref: https://github.com/hyfc/telegram-mail-bot/commit/d741c552a7dbe18515955bfc2c173367a03fdbc7#r103400598 --- bot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bot.py b/bot.py index d0eba3c..eca4d8b 100644 --- a/bot.py +++ b/bot.py @@ -87,7 +87,7 @@ async def periodic_task(context: CallbackContext) -> None: with EmailClient(email_addr, email_passwd) as client: new_inbox_num = client.get_mails_count() if new_inbox_num > inbox_num: - for i in range(inbox_num, new_inbox_num + 1): + for i in range(inbox_num + 1, new_inbox_num + 1): mail = client.get_mail_by_index(i) content = mail.__repr__() for text in handle_large_text(content): -- cgit v1.2.3