Skip to content

Commit

Permalink
将InvalidMessage错误合并至UnsupportedMessageOperation
Browse files Browse the repository at this point in the history
  • Loading branch information
ssttkkl committed Jul 20, 2022
1 parent a7c1e5b commit 32debe6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
9 changes: 0 additions & 9 deletions nonebot/adapters/kaiheila/exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,6 @@ class UnsupportedMessageType(KaiheilaAdapterException):
pass


class InvalidMessage(KaiheilaAdapterException):
"""
:说明:
在构建/发送不合法的消息类型时抛出,例如 Message 中只有一个图片类型的 MessageSegment 时添加其他 MessageSegment。
"""
pass


class UnsupportedMessageOperation(KaiheilaAdapterException):
"""
:说明:
Expand Down
4 changes: 2 additions & 2 deletions nonebot/adapters/kaiheila/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from nonebot.adapters import MessageSegment as BaseMessageSegment
from nonebot.typing import overrides

from .exception import UnsupportedMessageType, UnsupportedMessageOperation, InvalidMessage
from .exception import UnsupportedMessageType, UnsupportedMessageOperation
from .utils import unescape_kmarkdown

msg_type_map = {
Expand Down Expand Up @@ -225,7 +225,7 @@ async def serialize(self, for_send: bool = True) -> Tuple[int, str]:
self.message.reduce()

if len(self.message) != 1:
raise InvalidMessage()
raise UnsupportedMessageOperation()

msg_type = self.message[0].type
msg_type_code = msg_type_map[msg_type]
Expand Down

0 comments on commit 32debe6

Please sign in to comment.