'Message handler decorator.
This decorator can be used to decorate functions that must handle certain types of messages.
All message handlers are tested in the order they were added.
Example:
bot = TeleBot(\'TOKEN\')
# Handles all messages which text matches regexp.
@bot.message_handler(regexp=\'someregexp\')
def command_help(message):
bot.send_message(message.chat.id, \'Did someone call for help?\')
# Handle all sent documents of type \'text/plain\'.
@bot.message_handler(func=lambda message: message.document.mime_type == \'text/plain\', content_types=[\'document\'])
def command_handle_document(message):
bot.send_message(message.chat.id, \'Document received, sir!\')
# Handle all other commands.
@bot.message_handler(func=lambda message: True, content_types=[\'audio\', \'video\', \'document\', \'text\', \'location\', \'contact\', \'sticker\'])
def default_command(message):
bot.send_message(message.chat.id, "This is the default command handler.")
:param regexp: Optional regular expression.
:param func: Optional lambda function. The lambda receives the message to test as the first parameter. It must return True if the command should handle the message.
:param content_types: This commands\' supported content types. Must be a list. Defaults to [\'text\'].'

def message_handler(self, commands=None, regexp=None, func=None, content_types=['text'], **kwargs):

    def decorator(handler):
        handler_dict = self._build_handler_dict(handler, commands=commands, regexp=regexp, func=func, content_types=content_types, **kwargs)
        self.add_message_handler(handler_dict)
        return handler
    return decorator
