diff --git a/packages/alicebot-adapter-cqhttp/alicebot/adapter/cqhttp/__init__.py b/packages/alicebot-adapter-cqhttp/alicebot/adapter/cqhttp/__init__.py index fe10a5b..0d83463 100644 --- a/packages/alicebot-adapter-cqhttp/alicebot/adapter/cqhttp/__init__.py +++ b/packages/alicebot-adapter-cqhttp/alicebot/adapter/cqhttp/__init__.py @@ -37,6 +37,7 @@ tuple[Optional[str], Optional[str], Optional[str]], type[CQHTTPEvent] ] +DETAIL_TYPE_KEYS = ("message_type", "notice_type", "request_type", "meta_event_type") DEFAULT_EVENT_MODELS: EventModels = {} for _, model in inspect.getmembers(event, inspect.isclass): if issubclass(model, CQHTTPEvent): @@ -172,9 +173,14 @@ async def handle_cqhttp_event(self, msg: dict[str, Any]) -> None: if post_type is None: event_class = self.get_event_model(None, None, None) else: + detail_type: Optional[str] = None + for key in DETAIL_TYPE_KEYS: + detail_type = msg.get(key) + if detail_type is not None: + break event_class = self.get_event_model( post_type, - msg.get(post_type + "_type"), + detail_type or msg.get(post_type + "_type"), msg.get("sub_type"), )