示例#1
0
        def _message(func):
            try:
                if can_disable:
                    self._dispatcher.add_handler(
                        DisableAbleMessageHandler(pattern,
                                                  func,
                                                  friendly=friendly,
                                                  run_async=run_async),
                        group,
                    )
                else:
                    self._dispatcher.add_handler(
                        MessageHandler(pattern, func, run_async=run_async),
                        group)
                LOGGER.debug(
                    f"[KAIMSG] Loaded filter pattern {pattern} for function {func.__name__} in group {group}"
                )
            except TypeError:
                if can_disable:
                    self._dispatcher.add_handler(
                        DisableAbleMessageHandler(pattern,
                                                  func,
                                                  friendly=friendly,
                                                  run_async=run_async))
                else:
                    self._dispatcher.add_handler(
                        MessageHandler(pattern, func, run_async=run_async))
                LOGGER.debug(
                    f"[KAIMSG] Loaded filter pattern {pattern} for function {func.__name__}"
                )

            return func
示例#2
0
 def _callbackquery(func):
     self._dispatcher.add_handler(
         CallbackQueryHandler(pattern=pattern,
                              callback=func,
                              run_async=run_async))
     LOGGER.debug(
         f"[KAICALLBACK] Loaded callbackquery handler with pattern {pattern} for function {func.__name__}"
     )
     return func
示例#3
0
        def _command(func):
            try:
                if can_disable:
                    self._dispatcher.add_handler(
                        DisableAbleCommandHandler(
                            command,
                            func,
                            filters=filters,
                            run_async=run_async,
                            pass_args=pass_args,
                            admin_ok=admin_ok,
                        ),
                        group,
                    )
                else:
                    self._dispatcher.add_handler(
                        CommandHandler(
                            command,
                            func,
                            filters=filters,
                            run_async=run_async,
                            pass_args=pass_args,
                        ),
                        group,
                    )
                LOGGER.debug(
                    f"[KAICMD] Loaded handler {command} for function {func.__name__} in group {group}"
                )
            except TypeError:
                if can_disable:
                    self._dispatcher.add_handler(
                        DisableAbleCommandHandler(
                            command,
                            func,
                            filters=filters,
                            run_async=run_async,
                            pass_args=pass_args,
                            admin_ok=admin_ok,
                            pass_chat_data=pass_chat_data,
                        ))
                else:
                    self._dispatcher.add_handler(
                        CommandHandler(
                            command,
                            func,
                            filters=filters,
                            run_async=run_async,
                            pass_args=pass_args,
                            pass_chat_data=pass_chat_data,
                        ))
                LOGGER.debug(
                    f"[KAICMD] Loaded handler {command} for function {func.__name__}"
                )

            return func
示例#4
0
 def _inlinequery(func):
     self._dispatcher.add_handler(
         InlineQueryHandler(
             pattern=pattern,
             callback=func,
             run_async=run_async,
             pass_user_data=pass_user_data,
             pass_chat_data=pass_chat_data,
             chat_types=chat_types,
         ))
     LOGGER.debug(
         f"[KAIINLINE] Loaded inlinequery handler with pattern {pattern} for function {func.__name__} | PASSES USER DATA: {pass_user_data} | PASSES CHAT DATA: {pass_chat_data} | CHAT TYPES: {chat_types}"
     )
     return func