Telethon fails to detect invalidated bot token or deleted/banned bot session after initial authorization
Code that causes the issue
After starting a bot with a valid token, Telethon correctly connects and authorizes.
However, if the bot token is later: Revoked (via BotFather), The bot is deleted, Or banned by Telegram,
Lines of code: https://github.com/LonamiWebs/Telethon/blob/e77307d0ed882b0efa880d72aaf0efe4b2fd0f64/telethon/client/updates.py#L262
https://github.com/LonamiWebs/Telethon/blob/e77307d0ed882b0efa880d72aaf0efe4b2fd0f64/telethon/client/updates.py#L323
https://github.com/LonamiWebs/Telethon/blob/e77307d0ed882b0efa880d72aaf0efe4b2fd0f64/telethon/client/updates.py#L366
Expected behavior
If the bot gets unauthorized after original auth, (was_once_logged_in). It should disconnect
Actual behavior
It just prints in the log (Cannot get difference since the account is not logged in .....) and still keep the connection
Traceback
xxxx-xx-xx xx:xx:xx,xxx- telethon.client.updates - INFO - Cannot get difference since the account is not logged in: SessionRevokedError
Telethon version
1.40.0
Python version
3.11.13
Operating system (including distribution name and version)
Windows 11, Ubuntu 22.04
Other details
No response
Checklist
- [x] The error is in the library's code, and not in my own.
- [x] I have searched for this issue before posting it and there isn't an open duplicate.
- [x] I ran
pip install -U https://github.com/LonamiWebs/Telethon/archive/v1.zipand triggered the bug in the latest version.
Feel free to submit a PR since you seem to have a good grasp of the issue. I don't think I'll be able to look into this myself any time soon.