Skip to content

Releases: nonebot/plugin-alconna

Nonebot Plugin Alconna 0.20.0

30 Aug 07:53
Compare
Choose a tag to compare

变更

  • 增加适配器 Red Protocol
  • 增加通用标注 Card, 可用于匹配小程序等类型的消息元素

Full Changelog: v0.19.2...v0.20.0

Nonebot Plugin Alconna 0.19.2

26 Aug 16:12
Compare
Choose a tag to compare
  • 修复在 AlconnaParam 中 subclass 的问题 (例如 a: Optional[str])

Full Changelog: v0.19.1...v0.19.2

Nonebot Plugin Alconna 0.19.1

26 Aug 03:39
Compare
Choose a tag to compare
  • AlconnaMatcher 增加方法 reject_path,与 reject_arg 类似

Full Changelog: v0.19.0...v0.19.1

Nonebot Plugin Alconna 0.19.0

25 Aug 19:09
Compare
Choose a tag to compare

破坏性改动

  • 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

Nonebot Plugin Alconna 0.18.1

25 Aug 08:30
Compare
Choose a tag to compare
  • 修改部分名称与类型错误

Full Changelog: v0.18.0...v0.18.1

Nonebot Plugin Alconna 0.18.0

25 Aug 07:59
Compare
Choose a tag to compare
  • 在 discord 适配中增加了一个函数 translate,用于将 Alconna 对象转为 discord 适配器中 on_slash_command 的创建结构
    若原先的命令结构如下:
    from nonebot.adapters.discord.api import (
        IntegerOption,
        NumberOption,
        StringOption,
        SubCommandOption,
        UserOption,
    )
    from nonebot.adapters.discord.commands import on_slash_command
    	
    matcher = on_slash_command(
        name="permission",
        description="权限管理",
        options=[
            SubCommandOption(
                name="add",
                description="添加",
                options=[
                    StringOption(
                        name="plugin",
                        description="插件名",
                        required=True,
                    ),
                    IntegerOption(
                        name="priority",
                        description="优先级",
                        required=False,
                    ),
                ],
            ),
            SubCommandOption(
                name="remove",
                description="移除",
                options=[
                    StringOption(name="plugin", description="插件名", required=True),
                    NumberOption(name="time", description="时长", required=False),
                ],
            ),
            SubCommandOption(
                name="ban",
                description="禁用",
                options=[
                    UserOption(name="user", description="用户", required=False),
                ],
            ),
        ],
    )
    则使用 translate 后可以改为:
    from arclet.alconna import Args, Option, Alconna, CommandMeta
    
    from nonebot_plugin_alconna.adapters.discord import MentionUser, translate
    	
    matcher = translate(
        Alconna(
            "permission",
            Option("add", Args["plugin#插件名", str]["priority?#优先级", int]),
            Option("remove", Args["plugin#插件名", str]["time?#时长", float]),
            Option("ban", Args["user?#用户", MentionUser]),
            meta=CommandMeta("权限管理"),
        )
    )

Full Changelog: v0.17.0...v0.18.0

Nonebot Plugin Alconna 0.17.0

23 Aug 02:50
Compare
Choose a tag to compare
  • 新增配置项 alconna_use_param, 表示是否使用特制的 Param 提供更好的依赖注入,默认为 True
  • 若开启 use_param, AlconnaMatcher 下的响应器对于如下参数皆不再需要依赖注入:
    • CommandResult
    • Arparma
    • Alconna
    • Duplication
    • Match
    • Query
    • AlconnaArg
    • arg in args
      示例:
     async def handle(
         result: CommandResult,
         arp: Arparma,
         dup: Duplication,  # 此处可以是基类及其任意子类
         source: Alconna,
         abc: str,  # 类似 Match, 但是若匹配结果不存在对应字段则跳过该 handler
         foo: Match[str],
         bar: Query[int] = Query("ttt.bar", 0)  # Query 仍然需要一个默认值来传递 path 参数
     ):
     ...
    而倘若需要在 Match 和 Query 处使用 middleware,你仍可以改回原来的依赖注入写法

Full Changelog: v0.16.0...v0.17.0

Nonebot Plugin Alconna 0.16.0

15 Aug 08:56
Compare
Choose a tag to compare

变更

  • 增加 Command 便捷命令创建器:
     book = (
         Command("book", "测试")
         .option("writer", "-w <id:int>")
         .option("writer", "--anonymous", {"id": 0})
         .usage("book [-w <id:int> | --anonymous]")
         .shortcut("测试", {"args": ["--anonymous"]})
         .build()
     )
     
     
     @book.handle()
     async def test1_h(arp: Arparma = AlconnaMatches()):
         await book.send(str(arp.options))

Full Changelog: v0.15.0...v0.16.0

Nonebot Plugin Alconna 0.15.0

15 Aug 03:41
Compare
Choose a tag to compare

What's Changed

New Contributors

Full Changelog: v0.14.2...v0.15.0

Nonebot Plugin Alconna 0.14.2

14 Aug 09:37
Compare
Choose a tag to compare

新增

  • AlconnaMatchAlconnaQuery 新增 middleware 参数,用于对匹配参数进行自定义处理
  • 增加内置 middleware image_fetch ,用于拉取图片参数的二进制数据
  • 为 Alconna 下常用组件进行了 re-export

Full Changelog: v0.14.1...v0.14.2