Beispiel #1
0
    def decorator(func):

        if 'forwards' not in kwargs:
            kwargs['forwards'] = ALLOW_F_COMMANDS

        if ALLOW_COMMANDS_FROM_EXC is True:
            P = '[/!]'
        else:
            P = '/'

        if arg is True:
            cmd = "^{P}(?i:{0}|{0}@{1})(?: |$)(.*){2}".format(command,
                                                              BOT_USERNAME,
                                                              additional,
                                                              P=P)
        elif word_arg is True:
            cmd = "^{P}(?i:{0}|{0}@{1})(?: |$)(\S*){2}".format(command,
                                                               BOT_USERNAME,
                                                               additional,
                                                               P=P)
        else:
            cmd = "^{P}(?i:{0}|{0}@{1})$".format(command,
                                                 BOT_USERNAME,
                                                 additional,
                                                 P=P)

        bot.add_event_handler(
            func, events.NewMessage(incoming=True, pattern=cmd, **kwargs))
        bot.add_event_handler(
            func, events.MessageEdited(incoming=True, pattern=cmd, **kwargs))
Beispiel #2
0
 def decorator(func):
     bot.add_event_handler(func, events.ChatAction)
Beispiel #3
0
 def decorator(func):
     bot.add_event_handler(func,
                           events.NewMessage(incoming=True, pattern=cmd))
     bot.add_event_handler(func,
                           events.MessageEdited(incoming=True, pattern=cmd))
Beispiel #4
0
 def decorator(func):
     bot.add_event_handler(func, events.NewMessage())
     bot.add_event_handler(func, events.MessageEdited())
Beispiel #5
0
 def decorator(func):
     if compile is True:
         bot.add_event_handler(func,
                               events.CallbackQuery(data=re.compile(data)))
     else:
         bot.add_event_handler(func, events.CallbackQuery(data=data))
Beispiel #6
0
 def decorator(func):
     bot.add_event_handler(func, events.NewMessage(*args, **kwargs))
     bot.add_event_handler(func, events.MessageEdited(*args, **kwargs))