Skip to content

Commit

Permalink
[OneBot] Add extra field "action_type" to flag Echo type in validate_…
Browse files Browse the repository at this point in the history
…handler
  • Loading branch information
aicorein committed Dec 13, 2024
1 parent 66870e5 commit 0589f3a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
6 changes: 2 additions & 4 deletions src/melobot/protocols/onebot/v11/adapter/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,9 @@ async def create(self, packet: EchoPacket) -> ec.Echo | None:
if packet.noecho:
return None

ac_type = packet.action_type
data = packet.data
return await self.validate_handle(data)(ec.Echo.resolve)(
action_type=ac_type, **data
)
data["action_type"] = packet.action_type
return await self.validate_handle(data)(ec.Echo.resolve)(**data)


class EchoRequireCtx(Context[bool]):
Expand Down
3 changes: 1 addition & 2 deletions src/melobot/protocols/onebot/v11/adapter/echo.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ def is_failed(self) -> bool:

@classmethod
def resolve(cls, **kwds: Any) -> Echo:
action_type = kwds.pop("action_type")
match action_type:
match kwds["action_type"]:
case "send_private_msg" | "send_group_msg" | "send_msg":
return SendMsgEcho(**kwds)
case "send_private_forward_msg" | "send_group_forward_msg":
Expand Down

0 comments on commit 0589f3a

Please sign in to comment.