Nonebot-plugin-alconna

Latest version: v0.53.1

Safety actively analyzes 675368 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 20 of 22

0.18.0

- 在 discord 适配中增加了一个函数 `translate`,用于将 `Alconna` 对象转为 discord 适配器中 `on_slash_command` 的创建结构
若原先的命令结构如下:
python
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` 后可以改为:
python
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**: https://github.com/nonebot/plugin-alconna/compare/v0.17.0...v0.18.0

0.17.0

- 新增配置项 `alconna_use_param`, 表示是否使用特制的 Param 提供更好的依赖注入,默认为 True
- 若开启 use_param, AlconnaMatcher 下的响应器对于如下参数皆不再需要依赖注入:
- CommandResult
- Arparma
- Alconna
- Duplication
- Match
- Query
- AlconnaArg
- arg in args
示例:
python
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**: https://github.com/nonebot/plugin-alconna/compare/v0.16.0...v0.17.0

0.16.0

变更
- 增加 `Command` 便捷命令创建器:
python
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**: https://github.com/nonebot/plugin-alconna/compare/v0.15.0...v0.16.0

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 https://github.com/nonebot/plugin-alconna/pull/3
* `AlconnaMatcher` 增加方法 `shortcut()` 作为 `Alconna.shortcut` 的快捷调用

New Contributors
* canxin121 made their first contribution in https://github.com/nonebot/plugin-alconna/pull/3

**Full Changelog**: https://github.com/nonebot/plugin-alconna/compare/v0.14.2...v0.15.0

0.14.2

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

**Full Changelog**: https://github.com/nonebot/plugin-alconna/compare/v0.14.1...v0.14.2

0.14.1

- segmatch 现在支持 Reply 匹配了
- `Reply` 的 origin 现在包括原始 segment,适配器特定的`reply: Model`或`reply: Message`

**Full Changelog**: https://github.com/nonebot/plugin-alconna/compare/v0.14.0...v0.14.1

Page 20 of 22

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.