Skip to content

Commit

Permalink
⬆️ version 0.23.1
Browse files Browse the repository at this point in the history
adapt red-protocol 0.4.0
command_sep
  • Loading branch information
RF-Tar-Railt committed Sep 18, 2023
1 parent 8e83de4 commit 3b4afad
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 29 deletions.
49 changes: 25 additions & 24 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ dev = [
"nonebot-adapter-villa>=0.6.5",
"nonebot-adapter-discord>=0.1.0b1",
"nonebot-adapter-kaiheila>=0.2.9a1",
"nonebot-adapter-red>=0.1.0",
"nonebot-adapter-red>=0.4.1",
]
[tool.pdm.build]
includes = ["src/nonebot_plugin_alconna"]
Expand Down
2 changes: 1 addition & 1 deletion src/nonebot_plugin_alconna/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
from .consts import ALCONNA_EXEC_RESULT as ALCONNA_EXEC_RESULT
from .rule import set_output_converter as set_output_converter

__version__ = "0.23.0"
__version__ = "0.23.1"

_meta_source = {
"name": "Alconna 插件",
Expand Down
4 changes: 2 additions & 2 deletions src/nonebot_plugin_alconna/uniseg/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -606,8 +606,8 @@ async def generate_red_message(
raise SerializeFailed(f"Invalid {name} segment: {seg!r}")
elif isinstance(seg, File):
message.append(ms.file(seg.raw)) # type: ignore
# elif isinstance(seg, Reply):
# message.append(ms.reply(seg.id))
elif isinstance(seg, Reply):
message.append(ms.reply(seg.id))
elif isinstance(seg, Other):
message.append(seg.origin) # type: ignore
elif fallback:
Expand Down
11 changes: 11 additions & 0 deletions src/nonebot_plugin_alconna/uniseg/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,17 @@ async def reply_handle(event: Event, bot: Bot):
event.message_reference.message_id, # type: ignore
None,
)
elif adapter_name == "RedProtocol":
if TYPE_CHECKING:
from nonebot.adapters.red.event import MessageEvent

assert isinstance(event, MessageEvent)

if event.reply:
return Reply(
event.reply,
event.reply.replayMsgSeq,
)

elif _reply := getattr(event, "reply", None):
return Reply(_reply, str(_reply.message_id), getattr(_reply, "message", None))
Expand Down
3 changes: 2 additions & 1 deletion src/nonebot_plugin_alconna/uniseg/segment.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ class Reply(Segment):

origin: Any
id: str
"""此处不一定是消息ID,可能是其他ID,如消息序号等"""
msg: Optional[Union[Message, str]] = field(default=None)


Expand Down Expand Up @@ -458,7 +459,7 @@ def solve(self, seg: MessageSegment):
if "message_id" in seg.data: # ob12
return Reply(seg, seg.data["message_id"])
if "msg_id" in seg.data: # red
return Reply(seg, seg.data["msg_id"])
return Reply(seg.data["_origin"], seg.data["msg_seq"])
if seg.type == "quote":
if "msg_id" in seg.data: # kook:
return Reply(seg, seg.data["msg_id"])
Expand Down

0 comments on commit 3b4afad

Please sign in to comment.