# Path: vkapi/utils.py
# CONF_START = 2000000000
# 
# class doc_types:
#     TEXT_DOC = 1
#     ARCHIVE = 2
#     GIF = 3
#     IMAGE = 4
#     AUDIO = 5
#     VIDEO = 6
#     EBOOK = 7
#     UNKNOWN = 8
# 
# class cached_property:
# 
#     def __init__(self, fun):
#         self.fun = fun
#         functools.update_wrapper(self, fun)
# 
#     def __get__(self, instance, owner):
#         if instance is None:
#             return self
#         value = self.fun(instance)
#         setattr(instance, self.fun.__name__, value)
#         return value


from .utils import CONF_START, doc_types, cached_property
    def __init__(self, data, method=''):
        self.id = data.get('id')
        self.date = data['date']
        self.body = data.get('text', '')
        self.user_id = data['from_id']
        if 'peer_id' in data:
            self.chat_id = data['peer_id'] - CONF_START if data['peer_id'] > CONF_START else None
        else:
            self.chat_id = None
        self.action = data.get('action')
        self.attachments = data.get('attachments', [])
        self._fwd_messages_raw = data.get('fwd_messages', [])
        if 'reply_message' in data:
            self._fwd_messages_raw.append(data['reply_message'])
        self.method = method

        self.is_sticker = False
        self.is_voice = False
        for att in self.attachments:
            if att['type'] == 'sticker':
                self.is_sticker = True
            if att['type'] == 'doc' and att['doc']['type'] == doc_types.AUDIO:
                self.is_voice = True

    def _construct_forwarded_message(self, data):
        return self.__class__(data)

    @property
    def peer_id(self):
        if self.chat_id is not None:

# Path: vkapi/utils.py
# CONF_START = 2000000000
# 
# class doc_types:
#     TEXT_DOC = 1
#     ARCHIVE = 2
#     GIF = 3
#     IMAGE = 4
#     AUDIO = 5
#     VIDEO = 6
#     EBOOK = 7
#     UNKNOWN = 8
# 
# class cached_property:
# 
#     def __init__(self, fun):
#         self.fun = fun
#         functools.update_wrapper(self, fun)
# 
#     def __get__(self, instance, owner):
#         if instance is None:
#             return self
#         value = self.fun(instance)
#         setattr(instance, self.fun.__name__, value)
#         return value


# Path: vkapi/incoming_message.py
from .utils import CONF_START, doc_types, cached_property

    def __init__(self, data, method=''):
        self.id = data.get('id')
        self.date = data['date']
        self.body = data.get('text', '')
        self.user_id = data['from_id']
        if 'peer_id' in data:
            self.chat_id = data['peer_id'] - CONF_START if data['peer_id'] > CONF_START else None
        else:
            self.chat_id = None
        self.action = data.get('action')
        self.attachments = data.get('attachments', [])
        self._fwd_messages_raw = data.get('fwd_messages', [])
        if 'reply_message' in data:
            self._fwd_messages_raw.append(data['reply_message'])
        self.method = method

        self.is_sticker = False
        self.is_voice = False
        for att in self.attachments:
            if att['type'] == 'sticker':
                self.is_sticker = True
            if att['type'] == 'doc' and att['doc']['type'] == doc_types.AUDIO:
                self.is_voice = True

    def _construct_forwarded_message(self, data):
        return self.__class__(data)

    @property
    def peer_id(self):
        if self.chat_id is not None:

            return CONF_START + self.chat_id