From e2a7e33f3dcbfb5193f5b86e8b01d6c6957764a2 Mon Sep 17 00:00:00 2001 From: RussFP <1pyxa1@gmail.com> Date: Thu, 1 Feb 2018 12:47:41 +0300 Subject: [PATCH 1/4] add PHONE_NUMBER_BANNED --- compiler/error/source/400_BAD_REQUEST.tsv | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compiler/error/source/400_BAD_REQUEST.tsv b/compiler/error/source/400_BAD_REQUEST.tsv index 810c503b..5e30172b 100644 --- a/compiler/error/source/400_BAD_REQUEST.tsv +++ b/compiler/error/source/400_BAD_REQUEST.tsv @@ -42,4 +42,5 @@ CDN_METHOD_INVALID The method can't be used on CDN DCs VOLUME_LOC_NOT_FOUND The volume location can't be found FILE_ID_INVALID The file id is invalid LOCATION_INVALID The file location is invalid -CHAT_ADMIN_REQUIRED The method requires admin privileges \ No newline at end of file +CHAT_ADMIN_REQUIRED The method requires admin privileges +PHONE_NUMBER_BANNED The phone number is banned \ No newline at end of file From df5666e2a00c422b72ccd4eab58a1d442962419a Mon Sep 17 00:00:00 2001 From: RussFP <1pyxa1@gmail.com> Date: Thu, 1 Feb 2018 12:49:43 +0300 Subject: [PATCH 2/4] add PhoneNumberBanned exception to 'def authorize' --- pyrogram/client/client.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pyrogram/client/client.py b/pyrogram/client/client.py index 5fd75cc0..ea1ea89e 100644 --- a/pyrogram/client/client.py +++ b/pyrogram/client/client.py @@ -37,7 +37,7 @@ from pyrogram.api.errors import ( PhoneNumberUnoccupied, PhoneCodeInvalid, PhoneCodeHashEmpty, PhoneCodeExpired, PhoneCodeEmpty, SessionPasswordNeeded, PasswordHashInvalid, FloodWait, PeerIdInvalid, FilePartMissing, - ChatAdminRequired, FirstnameInvalid + ChatAdminRequired, FirstnameInvalid, PhoneNumberBanned ) from pyrogram.api.types import ( User, Chat, Channel, @@ -283,6 +283,9 @@ class Client: except FloodWait as e: print(e.MESSAGE.format(x=e.x)) time.sleep(e.x) + except PhoneNumberBanned as e: + log.error(e, exc_info=True) + raise except Exception as e: log.error(e, exc_info=True) else: From 214d3fe0bcbfbc43f332d4034eb4d2595026b7d6 Mon Sep 17 00:00:00 2001 From: RussFP <1pyxa1@gmail.com> Date: Thu, 1 Feb 2018 12:57:06 +0300 Subject: [PATCH 3/4] small fix --- compiler/error/source/400_BAD_REQUEST.tsv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/error/source/400_BAD_REQUEST.tsv b/compiler/error/source/400_BAD_REQUEST.tsv index 5e30172b..0b92aba5 100644 --- a/compiler/error/source/400_BAD_REQUEST.tsv +++ b/compiler/error/source/400_BAD_REQUEST.tsv @@ -43,4 +43,4 @@ VOLUME_LOC_NOT_FOUND The volume location can't be found FILE_ID_INVALID The file id is invalid LOCATION_INVALID The file location is invalid CHAT_ADMIN_REQUIRED The method requires admin privileges -PHONE_NUMBER_BANNED The phone number is banned \ No newline at end of file +PHONE_NUMBER_BANNED The phone number is banned From 00a02472f57b5ce898469d058afc4d40c07df2d8 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Thu, 1 Feb 2018 13:41:23 +0100 Subject: [PATCH 4/4] Make PhoneNumberBanned error looking more gentle --- pyrogram/client/client.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pyrogram/client/client.py b/pyrogram/client/client.py index ea1ea89e..b6180a9c 100644 --- a/pyrogram/client/client.py +++ b/pyrogram/client/client.py @@ -274,7 +274,7 @@ class Client: ) ) break - except PhoneNumberInvalid as e: + except (PhoneNumberInvalid, PhoneNumberBanned) as e: if phone_number_invalid_raises: raise else: @@ -283,9 +283,6 @@ class Client: except FloodWait as e: print(e.MESSAGE.format(x=e.x)) time.sleep(e.x) - except PhoneNumberBanned as e: - log.error(e, exc_info=True) - raise except Exception as e: log.error(e, exc_info=True) else: