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))
def decorator(func): bot.add_event_handler(func, events.ChatAction)
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))
def decorator(func): bot.add_event_handler(func, events.NewMessage()) bot.add_event_handler(func, events.MessageEdited())
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))
def decorator(func): bot.add_event_handler(func, events.NewMessage(*args, **kwargs)) bot.add_event_handler(func, events.MessageEdited(*args, **kwargs))