Skip to content

Commit e0c54b1

Browse files
Igorpython273
authored andcommitted
Version 5.85, lp version 3, setup.py open encoding (#181)
* Version 5.85, lp version 3
1 parent 3f1e7df commit e0c54b1

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
3+
from io import open
34
from setuptools import setup
45

56
"""
@@ -12,7 +13,7 @@
1213

1314
version = '11.1.0'
1415

15-
with open('README.md') as f:
16+
with open('README.md', encoding='utf-8') as f:
1617
long_description = f.read()
1718

1819
setup(

vk_api/longpoll.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ class VkChatEventType(IntEnum):
256256

257257

258258
MESSAGE_EXTRA_FIELDS = [
259-
'peer_id', 'timestamp', 'subject', 'text', 'attachments', 'random_id'
259+
'peer_id', 'timestamp', 'text', 'extra_values', 'attachments', 'random_id'
260260
]
261261
MSGID = 'message_id'
262262

@@ -271,7 +271,7 @@ class VkChatEventType(IntEnum):
271271
VkEventType.READ_ALL_OUTGOING_MESSAGES: ['peer_id', 'local_id'],
272272

273273
VkEventType.USER_ONLINE: ['user_id', 'extra', 'timestamp'],
274-
VkEventType.USER_OFFLINE: ['user_id', 'extra', 'timestamp'],
274+
VkEventType.USER_OFFLINE: ['user_id', 'flags', 'timestamp'],
275275

276276
VkEventType.PEER_FLAGS_RESET: ['peer_id', 'mask'],
277277
VkEventType.PEER_FLAGS_REPLACE: ['peer_id', 'flags'],
@@ -339,10 +339,11 @@ def __init__(self, raw):
339339
self.peer_id = None
340340
self.flags = None
341341
self.extra = None
342+
self.extra_values = None
342343

343344
try:
344-
self.type = VkEventType(raw[0])
345-
self._list_to_attr(raw[1:], EVENT_ATTRS_MAPPING[self.type])
345+
self.type = VkEventType(self.raw[0])
346+
self._list_to_attr(self.raw[1:], EVENT_ATTRS_MAPPING[self.type])
346347
except ValueError:
347348
pass
348349

@@ -379,8 +380,10 @@ def __init__(self, raw):
379380
if self.timestamp:
380381
self.datetime = datetime.utcfromtimestamp(self.timestamp)
381382

382-
def _list_to_attr(self, raw, attrs):
383+
if self.extra_values:
384+
self._dict_to_attr(self.extra_values)
383385

386+
def _list_to_attr(self, raw, attrs):
384387
for i in range(min(len(raw), len(attrs))):
385388
self.__setattr__(attrs[i], raw[i])
386389

@@ -389,7 +392,6 @@ def _dict_to_attr(self, values):
389392
self.__setattr__(k, v)
390393

391394
def _parse_peer_id(self):
392-
393395
if self.peer_id < 0: # Сообщение от/для группы
394396
self.from_group = True
395397
self.group_id = abs(self.peer_id)
@@ -416,7 +418,6 @@ def _parse_peer_flags(self):
416418
)
417419

418420
def _parse_message(self):
419-
420421
if self.flags & VkMessageFlag.OUTBOX:
421422
self.from_me = True
422423
else:
@@ -436,7 +437,6 @@ def _parse_online_status(self):
436437
pass
437438

438439
def _parse_chat_info(self):
439-
440440
if self.type_id == VkChatEventType.ADMIN_ADDED.value:
441441
self.info = {'admin_id': self.info}
442442

@@ -524,7 +524,7 @@ def check(self):
524524
'ts': self.ts,
525525
'wait': self.wait,
526526
'mode': self.mode,
527-
'version': 1
527+
'version': 3
528528
}
529529

530530
response = self.session.get(

vk_api/vk_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class VkApi(object):
8585
def __init__(self, login=None, password=None, token=None,
8686
auth_handler=None, captcha_handler=None,
8787
config=jconfig.Config, config_filename='vk_config.v2.json',
88-
api_version='5.84', app_id=6222115, scope=DEFAULT_USER_SCOPE,
88+
api_version='5.85', app_id=6222115, scope=DEFAULT_USER_SCOPE,
8989
client_secret=None):
9090

9191
self.login = login

0 commit comments

Comments
 (0)