Releases: nonebot/plugin-alconna
Releases · nonebot/plugin-alconna
Nonebot Plugin Alconna 0.20.0
Nonebot Plugin Alconna 0.19.2
- 修复在 AlconnaParam 中 subclass 的问题 (例如 a: Optional[str])
Full Changelog: v0.19.1...v0.19.2
Nonebot Plugin Alconna 0.19.1
AlconnaMatcher
增加方法reject_path
,与reject_arg
类似
Full Changelog: v0.19.0...v0.19.1
Nonebot Plugin Alconna 0.19.0
破坏性改动
adapters.__init__
内的内容移动至./uniseg.py
- 移除
SegMatch
相关内容
新增
on_alconna
增加参数use_cmd_start
, 以便局部使用nb配置里的命令前缀 (前提是命令本体没有手动传入前缀)- 新增通用标记
Other
, 用于标记所有特殊类型 - 新增依赖注入函数
UniversalMessage
( Annotated 版本为UniMsg
),返回类似于Message
的UniMessage
- 新增类
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
- 修改部分名称与类型错误
Full Changelog: v0.18.0...v0.18.1
Nonebot Plugin Alconna 0.18.0
- 在 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
- 新增配置项
alconna_use_param
, 表示是否使用特制的 Param 提供更好的依赖注入,默认为 True - 若开启 use_param, AlconnaMatcher 下的响应器对于如下参数皆不再需要依赖注入:
- CommandResult
- Arparma
- Alconna
- Duplication
- Match
- Query
- AlconnaArg
- arg in args
示例:
而倘若需要在 Match 和 Query 处使用 middleware,你仍可以改回原来的依赖注入写法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 参数 ): ...
Full Changelog: v0.16.0...v0.17.0
Nonebot Plugin Alconna 0.16.0
变更
- 增加
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
What's Changed
- Alconna 依赖升级至 1.7.17
- 新增适配器: Discord (https://github.com/nonebot/plugin-alconna/tree/master/src/nonebot_plugin_alconna/adapters/discord.py)
- 为Reply添加Discord和Kaiheila适配 by @canxin121 in #3
AlconnaMatcher
增加方法shortcut()
作为Alconna.shortcut
的快捷调用
New Contributors
- @canxin121 made their first contribution in #3
Full Changelog: v0.14.2...v0.15.0
Nonebot Plugin Alconna 0.14.2
新增
- 为
AlconnaMatch
与AlconnaQuery
新增middleware
参数,用于对匹配参数进行自定义处理 - 增加内置 middleware
image_fetch
,用于拉取图片参数的二进制数据 - 为 Alconna 下常用组件进行了 re-export
Full Changelog: v0.14.1...v0.14.2