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
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
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
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
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
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