コード例 #1
0
    def register(
        self,
        handler: "Type[EventHandler[ET]]",
        filters: "Tuple[Filter[ET], ...]",
        event: "Type[common.EventBuilder]",
    ) -> "Router":
        """
        Entrypoint for registering event handlers on particular event builders.
        """
        handler = ensure_handler(handler, event_builder=event)
        if handler.filters:
            handler.filters += tuple(ensure_filters(event, filters))
        else:
            handler.filters = tuple(ensure_filters(event, filters))

        self._handlers.append(handler)
        return self
コード例 #2
0
 def decorator(f_or_class: _EventHandlerGT[ET]) -> _EventHandlerGT[ET]:
     f_or_class_to_reg = ensure_handler(f_or_class, event_builder)
     self.register(f_or_class_to_reg, filters, event=event_builder)
     return f_or_class
コード例 #3
0
 def decorator(f_or_class: _EventHandlerGT[ET]) -> _EventHandlerGT[ET]:
     assert self.event is not None
     f_or_class_to_reg = ensure_handler(f_or_class, self.event)
     self.register(f_or_class_to_reg, filters, event=self.event)
     return f_or_class
コード例 #4
0
 def decorator(f_or_class: _EventHandlerGT[ET]) -> _EventHandlerGT[ET]:
     f_or_class_to_reg = ensure_handler(f_or_class, pe.MessageEdited)
     self.register(f_or_class_to_reg, filters, event=pe.MessageEdited)
     return f_or_class
コード例 #5
0
 def decorator(f_or_class: _EventHandlerGT[ET]) -> _EventHandlerGT[ET]:
     f_or_class_to_reg = ensure_handler(f_or_class, pe.ChatAction)
     self.register(f_or_class_to_reg, filters, event=pe.ChatAction)
     return f_or_class
コード例 #6
0
 def decorator(f_or_class: _EventHandlerGT[ET]) -> _EventHandlerGT[ET]:
     f_or_class_to_reg = ensure_handler(f_or_class, pe.CallbackQuery)
     self.register(f_or_class_to_reg, filters, event=pe.CallbackQuery)
     return f_or_class