Ejemplo n.º 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)
                log.debug(
                    f"[KIGMSG] 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))
                log.debug(
                    f"[KIGMSG] Loaded filter pattern {pattern} for function {func.__name__}"
                )

            return func
Ejemplo n.º 2
0
 def _callbackquery(func):
     self._dispatcher.add_handler(
         CallbackQueryHandler(pattern=pattern,
                              callback=func,
                              run_async=run_async))
     log.debug(
         f'[KIGCALLBACK] Loaded callbackquery handler with pattern {pattern} for function {func.__name__}'
     )
     return func
Ejemplo n.º 3
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))
     log.debug(
         f'[KIGINLINE] 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
Ejemplo n.º 4
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)
                log.debug(
                    f"[KIGCMD] 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))
                log.debug(
                    f"[KIGCMD] Loaded handler {command} for function {func.__name__}"
                )

            return func