From 346150bd9cc96ac099abd4d15fa3de39bd65e9d1 Mon Sep 17 00:00:00 2001 From: Stijn Peeters Date: Mon, 15 Jul 2024 15:57:55 +0200 Subject: [PATCH] Catch UPDATE_APP_TO_LOGIN in Telegram --- datasources/telegram/search_telegram.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/datasources/telegram/search_telegram.py b/datasources/telegram/search_telegram.py index 158e62e0..df6c06af 100644 --- a/datasources/telegram/search_telegram.py +++ b/datasources/telegram/search_telegram.py @@ -21,7 +21,7 @@ from datetime import datetime from telethon import TelegramClient from telethon.errors.rpcerrorlist import UsernameInvalidError, TimeoutError, ChannelPrivateError, BadRequestError, \ - FloodWaitError, ApiIdInvalidError, PhoneNumberInvalidError + FloodWaitError, ApiIdInvalidError, PhoneNumberInvalidError, RPCError from telethon.tl.functions.channels import GetFullChannelRequest from telethon.tl.functions.users import GetFullUserRequest from telethon.tl.types import User @@ -940,6 +940,10 @@ def validate_query(query, request, user): # wrong phone number raise QueryParametersException( "The phone number provided is not a valid phone number for these credentials.") + except RPCError as e: + # only seen this with an 'UPDATE_APP_TO_LOGIN' status + raise QueryParametersException(f"Could not verify your authentication. You may need to update your " + f"Telegram app(s) to the latest version to proceed ({e}).") except Exception as e: # ? raise QueryParametersException(