Skip to content

Nonebot Plugin Alconna 0.19.0

Compare
Choose a tag to compare
@RF-Tar-Railt RF-Tar-Railt released this 25 Aug 19:09
· 433 commits to master since this release

破坏性改动

  • adapters.__init__ 内的内容移动至 ./uniseg.py
  • 移除 SegMatch 相关内容

新增

  • on_alconna 增加参数 use_cmd_start, 以便局部使用nb配置里的命令前缀 (前提是命令本体没有手动传入前缀)
  • 新增通用标记 Other, 用于标记所有特殊类型
  • 新增依赖注入函数 UniversalMessage ( Annotated 版本为 UniMsg),返回类似于 MessageUniMessage
  • 新增类 UniMessage, 其与 Message 类似,但操作类型为 Segment:
    from nonebot_plugin_alconna import UniMsg, Reply, Image, At
    ...
    matcher = on_xxx(...)
    @matcher.handle()
    async def _(msg: UniMsg):
        reply = msg[Reply, 0]  # type: Reply
        ats = msg.get(At)  # type: UniMessage[At]
        await matcher.send(f"{reply}{ats}")
        if msg.has(Image):
          for img in msg[Image, 1:]:
              await matcher.send(img.url)
        await matcher.finish(msg.extract_plain_text())

Full Changelog: v0.18.1...v0.19.0