From e0e3947d2f45d1ee483ee558d4337df02541caca Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Mon, 18 Sep 2017 09:37:20 +0200 Subject: [PATCH] Fix some misleading errors/documentation --- telethon/errors/rpc_errors_400.py | 24 +++++++++++++++++------- telethon/telegram_client.py | 3 +-- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/telethon/errors/rpc_errors_400.py b/telethon/errors/rpc_errors_400.py index 216910c8..68874199 100644 --- a/telethon/errors/rpc_errors_400.py +++ b/telethon/errors/rpc_errors_400.py @@ -22,7 +22,9 @@ class ChannelInvalidError(BadRequestError): def __init__(self, **kwargs): super(Exception, self).__init__( self, - 'Invalid channel object. Make sure to pass the right types.' + 'Invalid channel object. Make sure to pass the right types,' + ' for instance making sure that the request is designed for ' + 'channels or otherwise look for a different one more suited.' ) @@ -40,7 +42,12 @@ class ChatIdInvalidError(BadRequestError): def __init__(self, **kwargs): super(Exception, self).__init__( self, - 'Invalid object ID for a chat. Make sure to pass the right types.' + 'Invalid object ID for a chat. Make sure to pass the right types,' + ' for instance making sure that the request is designed for chats' + ' (not channels/megagroups) or otherwise look for a different one' + ' more suited.\nAn example working with a megagroup and' + ' AddChatUserRequest, it will fail because megagroups are channels' + '. Use InviteToChannelRequest instead.' ) @@ -48,7 +55,8 @@ class ConnectionLangPackInvalid(BadRequestError): def __init__(self, **kwargs): super(Exception, self).__init__( self, - 'The specified language pack is not valid.' + 'The specified language pack is not valid. This is meant to be ' + 'used by official applications only so far, leave it empty.' ) @@ -284,7 +292,7 @@ class UsernameInvalidError(BadRequestError): def __init__(self, **kwargs): super(Exception, self).__init__( self, - 'Unacceptable username. Must match r"[a-zA-Z][\w\d]{4,31}"' + 'Unacceptable username. Must match r"[a-zA-Z][\w\d]{4,31}".' ) @@ -292,7 +300,7 @@ class UsernameNotModifiedError(BadRequestError): def __init__(self, **kwargs): super(Exception, self).__init__( self, - 'The username is not different from the current username' + 'The username is not different from the current username.' ) @@ -300,7 +308,7 @@ class UsernameNotOccupiedError(BadRequestError): def __init__(self, **kwargs): super(Exception, self).__init__( self, - 'See issue #96 for Telethon - try upgrading the library.' + 'The username is not in use by anyone else yet.' ) @@ -333,7 +341,9 @@ class UserIdInvalidError(BadRequestError): def __init__(self, **kwargs): super(Exception, self).__init__( self, - 'Invalid object ID for an user. Make sure to pass the right types.' + 'Invalid object ID for an user. Make sure to pass the right types,' + 'for instance making sure that the request is designed for users' + 'or otherwise look for a different one more suited.' ) diff --git a/telethon/telegram_client.py b/telethon/telegram_client.py index 5fc6b1f6..4f123055 100644 --- a/telethon/telegram_client.py +++ b/telethon/telegram_client.py @@ -292,8 +292,7 @@ class TelegramClient(TelegramBareClient): If no phone or code is provided, then the sole password will be used. The password should be used after a normal authorization attempt - has happened and an RPCError with `.password_required = True` was - raised. + has happened and an SessionPasswordNeededError was raised. To login as a bot, only `bot_token` should be provided. This should equal to the bot access hash provided by