Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: 消息段数据采用 str 存储 #97

Merged
merged 2 commits into from
Feb 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions nonebot/adapters/onebot/v11/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from nonebot.adapters.onebot.utils import truncate as trunc
from nonebot.adapters import MessageSegment as BaseMessageSegment

from .utils import log, escape, unescape
from .utils import escape, unescape


class MessageSegment(BaseMessageSegment["Message"]):
Expand Down Expand Up @@ -102,7 +102,6 @@

@classmethod
def forward(cls, id_: str) -> Self:
log("WARNING", "Forward Message only can be received!")
return cls("forward", {"id": id_})

@classmethod
Expand All @@ -121,7 +120,7 @@
"type": type_,
"cache": b2s(cache),
"proxy": b2s(proxy),
"timeout": timeout,
"timeout": timeout if timeout is None else str(timeout),
},
)

Expand Down Expand Up @@ -149,7 +148,7 @@

@classmethod
def music(cls, type_: str, id_: int) -> Self:
return cls("music", {"type": type_, "id": id_})
return cls("music", {"type": type_, "id": str(id_)})

Check warning on line 151 in nonebot/adapters/onebot/v11/message.py

View check run for this annotation

Codecov / codecov/patch

nonebot/adapters/onebot/v11/message.py#L151

Added line #L151 was not covered by tests

@classmethod
def music_custom(
Expand Down Expand Up @@ -204,7 +203,7 @@
"magic": b2s(magic),
"cache": b2s(cache),
"proxy": b2s(proxy),
"timeout": timeout,
"timeout": timeout if timeout is None else str(timeout),
},
)

Expand Down
Loading