Added two-step verification (fixes #4) and more info for errors

This commit is contained in:
Lonami Exo
2016-11-26 12:04:02 +01:00
parent be94bff576
commit 6c93d08b8d
4 changed files with 72 additions and 17 deletions

View File

@@ -126,6 +126,8 @@ class RPCError(Exception):
'CHAT_ADMIN_REQUIRED': 'Chat admin privileges are required to do that in the specified chat '
'(for example, to send a message in a channel which is not yours).',
'PASSWORD_HASH_INVALID': 'The password (and thus its hash value) you entered is invalid.',
# 401 UNAUTHORIZED
'AUTH_KEY_UNREGISTERED': 'The key is not registered in the system.',
@@ -141,6 +143,8 @@ class RPCError(Exception):
'AUTH_KEY_PERM_EMPTY': 'The method is unavailable for temporary authorization key, not bound to permanent.',
'SESSION_PASSWORD_NEEDED': 'Two-steps verification is enabled and a password is required.',
# 420 FLOOD
'FLOOD_WAIT_(\d+)': 'A wait of {} seconds is required.'
}
@@ -164,6 +168,10 @@ class RPCError(Exception):
self.additional_data = None
super().__init__(self, error_msg)
# Add another field to easily determine whether this error
# should be handled as a password-required error
self.password_required = message == 'SESSION_PASSWORD_NEEDED'
called_super = True
break