async def handleMessageForTempMessage( self, message: T.Union[ MessageChain, BaseMessageComponent, T.List[BaseMessageComponent], str ]): if isinstance(message, MessageChain): return json.loads(message.json()) elif isinstance(message, BaseMessageComponent): return [json.loads(message.json())] elif isinstance(message, (tuple, list)): result = [] for i in message: if isinstance(i, InternalImage): result.append({ "type": "Image" if not i.flash else "FlashImage", "imageId": (await self.handleInternalImageForTempMessage(i)).asFriendImage() }) elif isinstance(i, components.Image): result.append({ "type": "Image" if not i.flash else "FlashImage", "imageId": i.asFriendImage() }) else: result.append(json.loads(i.json())) return result elif isinstance(message, str): return [json.loads(components.Plain(text=message).json())] else: raise raiser(ValueError("invaild message."))
async def handleMessageAsFriend( self, message: T.Union[MessageChain, BaseMessageComponent, T.List[BaseMessageComponent], str]): return json.loads(message.json()) \ if isinstance(message, MessageChain) else \ [json.loads(message.json())] \ if isinstance(message, BaseMessageComponent) else \ [ json.loads(i.json()) \ # 对Image特殊处理 if type(i) != InternalImage else \ { "type": "Image", "imageId": (await self.handleInternalImageAsFriend(i)).asFriendImage() } \ for i in message if i ] \ if isinstance(message, (tuple, list)) else \ [json.loads(components.Plain(text=message).json())] \ if isinstance(message, str) else \ raiser(ValueError("invaild message(s)."))