diff --git a/nonebot/adapters/red/__init__.py b/nonebot/adapters/red/__init__.py index ec9682a..ee70143 100644 --- a/nonebot/adapters/red/__init__.py +++ b/nonebot/adapters/red/__init__.py @@ -6,4 +6,4 @@ from .event import GroupMessageEvent as GroupMessageEvent from .event import PrivateMessageEvent as PrivateMessageEvent -__version__ = "0.6.2" +__version__ = "0.7.0" diff --git a/nonebot/adapters/red/bot.py b/nonebot/adapters/red/bot.py index e1f1810..3c31c04 100644 --- a/nonebot/adapters/red/bot.py +++ b/nonebot/adapters/red/bot.py @@ -170,7 +170,15 @@ async def send_message( target: 目标 id message: 发送的消息 """ - element_data = await Message(message).export(self) + message = Message(message) + if message.has("forward"): + forward = message["forward", 0] + return await self.send_fake_forward( + forward.data["nodes"], + chat_type, + target, + ) + element_data = await message.export(self) resp = await self.call_api( "send_message", chat_type=chat_type, @@ -219,7 +227,15 @@ async def send( message: 发送的消息 """ chatType, peerUin = get_peer_data(event, **kwargs) - element_data = await Message(message).export(self) + message = Message(message) + if message.has("forward"): + forward = message["forward", 0] + return await self.send_fake_forward( + forward.data["nodes"], + ChatType(chatType), + peerUin, + ) + element_data = message.export(self) resp = await self.call_api( "send_message", chat_type=chatType, diff --git a/nonebot/adapters/red/message.py b/nonebot/adapters/red/message.py index 97b30ec..d861f75 100644 --- a/nonebot/adapters/red/message.py +++ b/nonebot/adapters/red/message.py @@ -127,15 +127,10 @@ def market_face( ) @staticmethod - def forward(xml: str, id: str, file_name: str) -> "MessageSegment": - log( - "WARNING", - "forward only can be received!\n" - "using `bot.send_fake_forward` to send a fake forward msg", - ) + def forward(nodes: List["ForwardNode"]) -> "MessageSegment": return MessageSegment( "forward", - {"xml": xml, "id": id, "name": file_name}, + {"nodes": nodes}, )