EventType.UNKNOWN

pull/1215/head
Windpicker-owo 2025-08-24 02:47:44 +08:00
parent cd9223ac63
commit b534340009
2 changed files with 4 additions and 1 deletions

View File

@ -21,7 +21,7 @@ class BaseEventHandler(ABC):
"""处理器权重,越大权重越高""" """处理器权重,越大权重越高"""
intercept_message: bool = False intercept_message: bool = False
"""是否拦截消息,默认为否""" """是否拦截消息,默认为否"""
init_subscribe: List[Union[EventType, str]] = [] init_subscribe: List[Union[EventType, str]] = [EventType.UNKNOWN]
"""初始化时订阅的事件名称""" """初始化时订阅的事件名称"""
def __init__(self): def __init__(self):

View File

@ -145,6 +145,9 @@ class EventManager:
""" """
handler_name = handler_class.handler_name or handler_class.__name__.lower().replace("handler", "") handler_name = handler_class.handler_name or handler_class.__name__.lower().replace("handler", "")
if EventType.UNKNOWN in handler_class.init_subscribe:
logger.error(f"事件处理器 {handler_name} 不能订阅 UNKNOWN 事件")
return False
if handler_name in self._event_handlers: if handler_name in self._event_handlers:
logger.warning(f"事件处理器 {handler_name} 已存在,跳过注册") logger.warning(f"事件处理器 {handler_name} 已存在,跳过注册")
return False return False