mirror of https://github.com/Mai-with-u/MaiBot.git
EventType.UNKNOWN
parent
cd9223ac63
commit
b534340009
|
|
@ -21,7 +21,7 @@ class BaseEventHandler(ABC):
|
|||
"""处理器权重,越大权重越高"""
|
||||
intercept_message: bool = False
|
||||
"""是否拦截消息,默认为否"""
|
||||
init_subscribe: List[Union[EventType, str]] = []
|
||||
init_subscribe: List[Union[EventType, str]] = [EventType.UNKNOWN]
|
||||
"""初始化时订阅的事件名称"""
|
||||
|
||||
def __init__(self):
|
||||
|
|
|
|||
|
|
@ -145,6 +145,9 @@ class EventManager:
|
|||
"""
|
||||
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:
|
||||
logger.warning(f"事件处理器 {handler_name} 已存在,跳过注册")
|
||||
return False
|
||||
|
|
|
|||
Loading…
Reference in New Issue