diff --git a/docs/keyboard.rst b/docs/keyboard.rst index bfd3667..f0b1c2d 100644 --- a/docs/keyboard.rst +++ b/docs/keyboard.rst @@ -8,3 +8,5 @@ VkKeyboard :members: .. autoclass:: VkKeyboardColor :members: +.. autoclass:: VkKeyboardButton + :members: diff --git a/setup.py b/setup.py index 0b893a2..1165a84 100644 --- a/setup.py +++ b/setup.py @@ -11,7 +11,7 @@ """ -version = '11.9.0' +version = '11.9.1' with open('README.md', encoding='utf-8') as f: long_description = f.read() diff --git a/vk_api/__init__.py b/vk_api/__init__.py index 7a5831f..e647e78 100644 --- a/vk_api/__init__.py +++ b/vk_api/__init__.py @@ -14,5 +14,5 @@ __author__ = 'python273' -__version__ = '11.9.0' +__version__ = '11.9.1' __email__ = 'vk_api@python273.pw' diff --git a/vk_api/utils.py b/vk_api/utils.py index 82d413c..a8448a8 100644 --- a/vk_api/utils.py +++ b/vk_api/utils.py @@ -143,11 +143,16 @@ def send(self, request, **kwargs): total = end - start + body = request.body + if body and len(body) > 1024: + body = body[:1024] + '[STRIPPED]' + print( - '{:0.2f} {} {} {} {}'.format( + '{:0.2f} {} {} {} {} {}'.format( total, request.method, request.url, + repr(body), response.status_code, response.history ) diff --git a/vk_api/vk_api.py b/vk_api/vk_api.py index d03bbe7..0c164dc 100644 --- a/vk_api/vk_api.py +++ b/vk_api/vk_api.py @@ -27,9 +27,7 @@ RE_LOGIN_HASH = re.compile(r'name="lg_h" value="([a-z0-9]+)"') RE_CAPTCHAID = re.compile(r"onLoginCaptcha\('(\d+)'") RE_NUMBER_HASH = re.compile(r"al_page: '3', hash: '([a-z0-9]+)'") -RE_AUTH_HASH = re.compile( - r"\{.*?act: 'a_authcheck_code'.+?hash: '([a-z_0-9]+)'.*?\}" -) +RE_AUTH_HASH = re.compile(r"Authcheck\.init\('([a-z_0-9]+)'") RE_TOKEN_URL = re.compile(r'location\.href = "(.*?)"\+addr;') RE_PHONE_PREFIX = re.compile(r'label ta_r">\+(.*?)<') @@ -291,7 +289,7 @@ def _vk_login(self, captcha_sid=None, captcha_key=None): raise BadPassword('Bad password') if 'act=authcheck' in response.text: - self.logger.info('Two factor is required') + self.logger.info('2FA is required') response = self.http.get('https://vk.com/login?act=authcheck') @@ -317,19 +315,28 @@ def _pass_twofactor(self, auth_response): :param auth_response: страница с приглашением к аутентификации """ - code, remember_device = self.error_handlers[TWOFACTOR_CODE]() auth_hash = search_re(RE_AUTH_HASH, auth_response.text) + if not auth_hash: + raise TwoFactorError( + 'Two-factor authentication can not be passed:' + ' could not find "hash" value. Please send a bugreport' + ) + + code, remember_device = self.error_handlers[TWOFACTOR_CODE]() + values = { - 'act': 'a_authcheck_code', 'al': '1', 'code': code, - 'remember': int(remember_device), 'hash': auth_hash, + 'remember': int(remember_device), } - response = self.http.post('https://vk.com/al_login.php', values) + response = self.http.post( + 'https://vk.com/al_login.php?act=a_authcheck_code', + values + ) data = json.loads(response.text.lstrip('