Skip to content

Commit

Permalink
Version 5.85, lp version 3, setup.py open encoding (#181)
Browse files Browse the repository at this point in the history
* Version 5.85, lp version 3
  • Loading branch information
Igor authored and python273 committed Sep 24, 2018
1 parent 3f1e7df commit e0c54b1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from io import open
from setuptools import setup

"""
Expand All @@ -12,7 +13,7 @@

version = '11.1.0'

with open('README.md') as f:
with open('README.md', encoding='utf-8') as f:
long_description = f.read()

setup(
Expand Down
18 changes: 9 additions & 9 deletions vk_api/longpoll.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ class VkChatEventType(IntEnum):


MESSAGE_EXTRA_FIELDS = [
'peer_id', 'timestamp', 'subject', 'text', 'attachments', 'random_id'
'peer_id', 'timestamp', 'text', 'extra_values', 'attachments', 'random_id'
]
MSGID = 'message_id'

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

VkEventType.USER_ONLINE: ['user_id', 'extra', 'timestamp'],
VkEventType.USER_OFFLINE: ['user_id', 'extra', 'timestamp'],
VkEventType.USER_OFFLINE: ['user_id', 'flags', 'timestamp'],

VkEventType.PEER_FLAGS_RESET: ['peer_id', 'mask'],
VkEventType.PEER_FLAGS_REPLACE: ['peer_id', 'flags'],
Expand Down Expand Up @@ -339,10 +339,11 @@ def __init__(self, raw):
self.peer_id = None
self.flags = None
self.extra = None
self.extra_values = None

try:
self.type = VkEventType(raw[0])
self._list_to_attr(raw[1:], EVENT_ATTRS_MAPPING[self.type])
self.type = VkEventType(self.raw[0])
self._list_to_attr(self.raw[1:], EVENT_ATTRS_MAPPING[self.type])
except ValueError:
pass

Expand Down Expand Up @@ -379,8 +380,10 @@ def __init__(self, raw):
if self.timestamp:
self.datetime = datetime.utcfromtimestamp(self.timestamp)

def _list_to_attr(self, raw, attrs):
if self.extra_values:
self._dict_to_attr(self.extra_values)

def _list_to_attr(self, raw, attrs):
for i in range(min(len(raw), len(attrs))):
self.__setattr__(attrs[i], raw[i])

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

def _parse_peer_id(self):

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

def _parse_message(self):

if self.flags & VkMessageFlag.OUTBOX:
self.from_me = True
else:
Expand All @@ -436,7 +437,6 @@ def _parse_online_status(self):
pass

def _parse_chat_info(self):

if self.type_id == VkChatEventType.ADMIN_ADDED.value:
self.info = {'admin_id': self.info}

Expand Down Expand Up @@ -524,7 +524,7 @@ def check(self):
'ts': self.ts,
'wait': self.wait,
'mode': self.mode,
'version': 1
'version': 3
}

response = self.session.get(
Expand Down
2 changes: 1 addition & 1 deletion vk_api/vk_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class VkApi(object):
def __init__(self, login=None, password=None, token=None,
auth_handler=None, captcha_handler=None,
config=jconfig.Config, config_filename='vk_config.v2.json',
api_version='5.84', app_id=6222115, scope=DEFAULT_USER_SCOPE,
api_version='5.85', app_id=6222115, scope=DEFAULT_USER_SCOPE,
client_secret=None):

self.login = login
Expand Down

0 comments on commit e0c54b1

Please sign in to comment.