# Path: vkapi/incoming_message.py
# class IncomingMessage:
# 
#     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
#         return self.user_id
# 
#     @property
#     def is_chat(self):
#         return self.chat_id is not None
# 
#     @cached_property
#     def fwd_messages(self):
#         fwd_messages = [self._construct_forwarded_message(data) for data in self._fwd_messages_raw]
#         del self._fwd_messages_raw
#         return fwd_messages
# 
# Path: vkapi/utils.py
# 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
# 
# class doc_types:
#     TEXT_DOC = 1
#     ARCHIVE = 2
#     GIF = 3
#     IMAGE = 4
#     AUDIO = 5
#     VIDEO = 6
#     EBOOK = 7
#     UNKNOWN = 8
# 
# CONF_START = 2000000000


import re
import config
from vkapi.incoming_message import IncomingMessage
from vkapi.utils import cached_property, doc_types, CONF_START

    def __init__(self, *args, self_id=None, voice_recognizer=None, **kwargs):
        super().__init__(*args, **kwargs)
        self.self_id = self_id
        self.voice_recognizer = voice_recognizer

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

    def _get_voice_content(self, voice):
        if self.voice_recognizer is None or 'link_mp3' not in voice:
            return self.VOICE_FALLBACK
        text = self.voice_recognizer.get_text(voice['link_mp3'])
        return text if text is not None else self.VOICE_FALLBACK

    def _process_body(self, toplevel=False):
        if self.is_my_message:
            return ''
        if self.action:
            return None

        result = self.body
        att = []
        for a in self.attachments:
            if a['type'] == 'audio':
                if not config.get('vkbot.ignore_audio', 'b'):
                    att.append(a['audio']['title'])
            elif a['type'] == 'video':
                att.append(a['video']['title'])
            elif a['type'] == 'wall':

# Path: vkapi/incoming_message.py
# class IncomingMessage:
# 
#     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
#         return self.user_id
# 
#     @property
#     def is_chat(self):
#         return self.chat_id is not None
# 
#     @cached_property
#     def fwd_messages(self):
#         fwd_messages = [self._construct_forwarded_message(data) for data in self._fwd_messages_raw]
#         del self._fwd_messages_raw
#         return fwd_messages
# 
# Path: vkapi/utils.py
# 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
# 
# class doc_types:
#     TEXT_DOC = 1
#     ARCHIVE = 2
#     GIF = 3
#     IMAGE = 4
#     AUDIO = 5
#     VIDEO = 6
#     EBOOK = 7
#     UNKNOWN = 8
# 
# CONF_START = 2000000000


# Path: vkbot_message.py
import re
import config
from vkapi.incoming_message import IncomingMessage
from vkapi.utils import cached_property, doc_types, CONF_START


    def __init__(self, *args, self_id=None, voice_recognizer=None, **kwargs):
        super().__init__(*args, **kwargs)
        self.self_id = self_id
        self.voice_recognizer = voice_recognizer

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

    def _get_voice_content(self, voice):
        if self.voice_recognizer is None or 'link_mp3' not in voice:
            return self.VOICE_FALLBACK
        text = self.voice_recognizer.get_text(voice['link_mp3'])
        return text if text is not None else self.VOICE_FALLBACK

    def _process_body(self, toplevel=False):
        if self.is_my_message:
            return ''
        if self.action:
            return None

        result = self.body
        att = []
        for a in self.attachments:
            if a['type'] == 'audio':
                if not config.get('vkbot.ignore_audio', 'b'):
                    att.append(a['audio']['title'])
            elif a['type'] == 'video':
                att.append(a['video']['title'])
            elif a['type'] == 'wall':

                att.append(a['wall']['text'])