diff --git a/src/nonebot_plugin_alconna/uniseg/exporter.py b/src/nonebot_plugin_alconna/uniseg/exporter.py index c1dbf6f..82f4f63 100644 --- a/src/nonebot_plugin_alconna/uniseg/exporter.py +++ b/src/nonebot_plugin_alconna/uniseg/exporter.py @@ -171,17 +171,22 @@ async def export(self, source: Sequence[Segment], bot: Union[Bot, None], fallbac for seg in source: seg_type = seg.__class__ if seg_type in self._mapping: - res = await self._mapping[seg_type](seg, bot) - if isinstance(res, list): - message.extend(res) - else: - message.append(res) - elif res := await custom.export(self, seg, bot, fallback): # type: ignore + try: + res = await self._mapping[seg_type](seg, bot) + if isinstance(res, list): + message.extend(res) + else: + message.append(res) + continue + except (SerializeFailed, NotImplementedError): + pass + if res := await custom.export(self, seg, bot, fallback): # type: ignore if isinstance(res, list): message.extend(res) else: message.append(res) - elif isinstance(seg, Other): + continue + if isinstance(seg, Other): message.append(seg.origin) # type: ignore elif bot and bot.adapter.get_name() == SupportAdapter.nonebug: message += str(seg) diff --git a/src/nonebot_plugin_alconna/uniseg/message.py b/src/nonebot_plugin_alconna/uniseg/message.py index 808e23d..17e3f9b 100644 --- a/src/nonebot_plugin_alconna/uniseg/message.py +++ b/src/nonebot_plugin_alconna/uniseg/message.py @@ -604,7 +604,7 @@ def template(cls, format_string: Union[str, "UniMessage"]) -> UniMessageTemplate 返回: 消息格式化器 """ - return UniMessageTemplate(format_string, cls) + return UniMessageTemplate(format_string, cls) # type: ignore def __merge_text__(self) -> Self: if not self: