Skip to content

Commit

Permalink
✨ version 0.7.0
Browse files Browse the repository at this point in the history
support send forward by MessageSegment.forward
  • Loading branch information
RF-Tar-Railt committed Oct 29, 2023
1 parent eb6d4d4 commit 8e9b750
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
2 changes: 1 addition & 1 deletion nonebot/adapters/red/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
from .event import GroupMessageEvent as GroupMessageEvent
from .event import PrivateMessageEvent as PrivateMessageEvent

__version__ = "0.6.2"
__version__ = "0.7.0"
20 changes: 18 additions & 2 deletions nonebot/adapters/red/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
9 changes: 2 additions & 7 deletions nonebot/adapters/red/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -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},
)


Expand Down

0 comments on commit 8e9b750

Please sign in to comment.