This repository has been archived by the owner on Jul 21, 2023. It is now read-only.
Releases: ArcletProject/nonebot-plugin-alconna
Releases · ArcletProject/nonebot-plugin-alconna
Nonebot Plugin Alconna 0.9.0
变更
-
增加装饰器
funcommand
, 用于将一个接受任意参数,返回str
或Message
或MessageSegment
的函数转换为命令响应器。from nonebot_plugin_alconna import funcommand @funcommand() async def echo(msg: str): return msg
签名:
def funcommand( name: str | None = None, prefixes: list[str] | None = None, description: str | None = None, ) -> Callable[[Callable[..., MReturn]], type[Matcher]]: ...
Full Changelog: v0.8.3...v0.9.0
Nonebot Plugin Alconna 0.8.3
Nonebot Plugin Alconna 0.8.2
变更
- 增加 "Emoji" 通用段标记
class Emoji(Segment): id: str name: Optional[str]
Full Changelog: v0.8.0...v0.8.2
Nonebot Plugin Alconna 0.8.0
变更
-
添加了通用段模型:
class Segment: origin: MessageSegment class At(Segment): target: str class Media(Segment): # Image,Audio,Voice, Video url: Optional[str] id: Optional[str] class File(Segment): id: str name: Optional[str]
-
通用标注现在将把符合条件的
MessageSegment
在命令解析后转换为对应的通用段模型
例如:- at (ob11), mention (ob12, telegram) ->
At
- file (ob12), document (telegram) ->
File
- Image (mirai), photo (telegram), image (ob11, ...) ->
Image
from nonebot.adapters.onebot.v11 import Message, MessageSegment from nonebot_plugin_alconna.adapters import At from arclet.alconna import Alconna, Args msg = Message(["Hello!", MessageSegment.at(123)]) # Hello![CQ:at,qq=123] alc = Alconna("Hello!", Args["target", At]) assert alc.parse(msg).matched target = alc.parse(msg).query("target") assert isinstance(target, At) assert target.target == '123'
- at (ob11), mention (ob12, telegram) ->
Full Changelog: v0.7.0...v0.8.0
Nonebot Plugin Alconna 0.7.0
Nonebot Plugin Alconna 0.6.1
变更
-
⬆️ Bump dependabot/fetch-metadata from 1.5.0 to 1.5.1 by @dependabot in #6
-
修复
aliases
无法使用的 bug
Full Changelog: v0.6.0...v0.6.1
Nonebot Plugin Alconna 0.6.0
变更
- ⬆️ Bump dependabot/fetch-metadata from 1.4.0 to 1.5.0 by @dependabot in #4
CommandResult
增加属性source
, 表示源 Alconnaarclet-alconna
依赖提升至 1.7.7
Full Changelog: v0.5.0...v0.6.0
Nonebot Plugin Alconna 0.5.0
AlconnaRule
,on_alconna
移除参数checker
match_value
,match_path
,assign
转为Check
使用函数- 新增
Check
依赖注入, 用于检查Arparma
并控制当前事件处理函数是否执行:from nonebot_plugin_alconna import Check, assign, on_alconna ... cmd = on_alconna(...) # enter when path `foo` exist @cmd.handle([Check(lambda arp: arp.find("foo"))]) async def foo(...): ... # enter when path `bar.baz` exist @cmd.handle([Check(assign("bar.baz"))]) async def baz(...): ...
Check
接受传入类型为Arparma
, 传出类型为bool
的函数
Nonebot Plugin Alconna 0.4.0
- 升级至 Alconna 1.7.0
- 支持补全会话,在
on_alconna
中传入参数comp_config
即可启用 - 为所有适配器增添特定 Segmeng 标注,并允许像类一样创建 MessageSegment对象:
from nonebot_plugin_alconna.adpaters.onebot11 import At from nonebot.adapters.onebot.v11.message import MessageSegment assert At(123) == MessageSegmeng.at(123)
- 增加通用的 Segment 标注:
- At
- Image
- File
- Video
- Audio
- Voice