mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-07-12 16:02:35 +08:00
fix(event): restore missing method removed in be63e9ed
This commit is contained in:
@@ -105,15 +105,24 @@ class EventManager(metaclass=Singleton):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"停止事件处理线程出错:{str(e)} - {traceback.format_exc()}")
|
logger.error(f"停止事件处理线程出错:{str(e)} - {traceback.format_exc()}")
|
||||||
|
|
||||||
def check(self, etype: EventType):
|
def check(self, etype: Union[EventType, ChainEventType]) -> bool:
|
||||||
"""
|
"""
|
||||||
检查事件是否存在响应,去除掉被禁用的事件响应
|
检查是否有启用的事件处理器可以响应某个事件类型
|
||||||
|
:param etype: 事件类型 (EventType 或 ChainEventType)
|
||||||
|
:return: 返回是否存在可用的处理器
|
||||||
"""
|
"""
|
||||||
if etype not in self.__broadcast_subscribers:
|
if isinstance(etype, ChainEventType):
|
||||||
return False
|
handlers = self.__chain_subscribers.get(etype, [])
|
||||||
handlers = self.__broadcast_subscribers[etype]
|
return any(
|
||||||
return any([handler for handler in handlers.values()
|
self.__is_handler_enabled(handler)
|
||||||
if handler.__qualname__.split(".")[0] not in self.__disabled_handlers])
|
for _, handler in handlers
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
handlers = self.__broadcast_subscribers.get(etype, [])
|
||||||
|
return any(
|
||||||
|
self.__is_handler_enabled(handler)
|
||||||
|
for handler in handlers
|
||||||
|
)
|
||||||
|
|
||||||
def send_event(self, etype: Union[EventType, ChainEventType], data: Optional[Dict] = None,
|
def send_event(self, etype: Union[EventType, ChainEventType], data: Optional[Dict] = None,
|
||||||
priority: int = DEFAULT_EVENT_PRIORITY) -> Optional[Event]:
|
priority: int = DEFAULT_EVENT_PRIORITY) -> Optional[Event]:
|
||||||
|
|||||||
Reference in New Issue
Block a user