Пример #1
0
def parse_messages(message):
    try:
        parser = MessageParser(message.text)
        responses, message_type = parser.get_response()
        if message_type == MessageTypes.COORDS:
            lat, long = responses
            bot.send_location(message.chat.id, lat, long)
        elif message_type == MessageTypes.IMAGE:
            with open(responses, 'rb') as f:
                bot.send_photo(message.chat.id, f)
        elif message_type == MessageTypes.TEXT:

            if isinstance(responses, str):
                responses = [responses]
            for text in responses:
                bot.send_message(message.chat.id, text, parse_mode='HTML')
    except Exception as e:
        logging.error("Can not sent message: {}".format(e))