Skip to content

Releases: nonebot/plugin-alconna

Nonebot Plugin Alconna 0.45.1

01 May 11:33
Compare
Choose a tag to compare

What's Changed

  • 升级 nonebot2 依赖版本至 2.3.0
  • ⬆️ Bump dependabot/fetch-metadata from 2.0.0 to 2.1.0 by @dependabot in #47

Note

随着 nonebot2 升级至 2.3.0,本插件同样也放弃了对 python 3.8 的支持。

Full Changelog: v0.45.0...v0.45.1

Nonebot Plugin Alconna 0.45.0

29 Apr 11:33
Compare
Choose a tag to compare

破坏性改动

  • 删除 Custom

新增

  • builtins 模块,目前包括 extensionspluginsuniseg
  • extensions 模块目前包含:
    • ReplyRecordExtension: 将消息事件中的回复暂存在 extension 中,使得解析用的消息不带回复信息,同时可以在后续的处理中获取回复信息。
    • DiscordSlashExtension: 将 Alconna 的命令自动转换为 Discord 的 Slash Command,并将 Slash Command 的交互事件转换为消息交给 Alconna 处理。
    • MarkdownOutputExtension: 将 Alconna 的自动输出转换为 Markdown 格式
    • TelegramSlashExtension: 将 Alconna 的命令注册在 Telegram 上以获得提示。
  • plugins 目前有 echohelp 两个插件
  • uniseg 目前有 chronocat 模块,拓展了 chronocat:facechronocat:marketface

改进

  • custom_register 现不再限制为 Custom 子类的构造,任意 Segment 子类都可
  • Custom.export 改为 custom_handler,允许任意 Segment 子类转为适配器对应消息段

Full Changelog: v0.44.0...v0.45.0

Nonebot Plugin Alconna 0.44.0

26 Apr 11:05
Compare
Choose a tag to compare

破坏性改动

  • Custom.exportcustom_register 所需函数的签名分别增加了 exporterbuilder
  • Referencecontent 参数被移除

新增

  • Segment 新增 children 属性,即支持嵌套元素
  • Segment 实例可以通过 __call__来增加子元素:
    video = Video(url="https://www.bilibili.com/video/BV15p421S7da")(
        Text("当前平台不支持发送视频,请在 https://www.bilibili.com/video/BV15p421S7da 观看视频!")
        .mark(15, 58, "link")
    )
  • 新增 Segment.from_select 等方法,以表达提取嵌套元素:
    from nepattern import Dot
    from nonebot_plugin_alconna import Image, Video, select_first
    from nonebot_plugin_alconna.typings import Link
    
    # 该指令接收任意可提取出图片的元素,并返回第一个图片的 url
    m1 = Alconna("/m1", Args["img", Dot(select_first(Image), str, "url")])
    # 该指令接收链接或者视频元素里的链接
    m2 = Alconna("/m2", Args["link", [Link, Link.from_(Video)]])

改进

  • 类 koishi 构造器 Command 的参数现在能塞入 UniSeg 了:
    from nonebot_plugin_alconna import Command
    
    cmd = Command("/test <img:Image>").build()

Full Changelog: v0.43.0...v0.44.0

Nonebot Plugin Alconna 0.43.0

23 Apr 10:36
Compare
Choose a tag to compare

Full Changelog: v0.42.5...v0.43.0

Nonebot Plugin Alconna 0.42.5

21 Apr 15:29
Compare
Choose a tag to compare

升级依赖

Full Changelog: v0.42.4...v0.42.5

Nonebot Plugin Alconna 0.42.4

13 Apr 11:03
Compare
Choose a tag to compare
  • 修复 UniMessage 出现的递归 bug

Full Changelog: v0.42.3...v0.42.4

Nonebot Plugin Alconna 0.42.3

07 Apr 13:08
Compare
Choose a tag to compare
  • 修复未增加 onebot12 target fetcher 的问题
  • 去掉 Target 的 dataclass 以避免 pyd 的加料

Full Changelog: v0.42.2...v0.42.3

Nonebot Plugin Alconna 0.42.2

07 Apr 05:05
Compare
Choose a tag to compare
  • Target.dump 增加 only_scope 参数,设为 True则不保存 adapter 信息
  • SupportScope 新增 onebot12_othersatori_other
  • MsgTarget 等获取的 target 会携带 scope 信息

Full Changelog: v0.42.1...v0.42.2

Nonebot Plugin Alconna 0.42.1

07 Apr 02:02
Compare
Choose a tag to compare
  • Target 的 selector 与 从 scope 获得的 selector 现在是独立的(即二者会组合)
  • 新增 apply_fetch_targets,调用后会在 nonebot 启动后为每个 bot 运行一次发送对象列表拉取
  • Target 的 selector 的默认函数现在为从拉取到的对象列表中判断是否符合
  • 新增配置项 alconna_apply_fetch_targets,控制是否启动时拉取一次发送对象列表
  • Target 增加 dump, load 方法,用来存储与读取

附1:target 上 adapter,scope等的优先级为 adapter & platform > scope > selector
附2:自定义 selector:

async def is_friend(target: Target, bot: Bot):
    if not target.private:
        return False
    friends = await bot.get_friend_list()
    return target.id in [friend["user_id"] for friend in friends]

user_target = Target("123", private=True, selector=is_friend, adapter=SupportAdapter.onebot11)

Full Changelog: v0.42.0...v0.42.1

Nonebot Plugin Alconna 0.42.0

05 Apr 11:47
Compare
Choose a tag to compare

What's Changed

  • Target 新增属性 selector, scopeplatform,原 platform 字段改为 adapter
    selector 负责从 bots 中选择符合条件的具体 Bot 实例,scope 可以选择插件内置的 selectoradapterplatform 用于先验条件:
     from nonebot_plugin_alconna import Target, UniMessage, SupportAdapter, SupportScope
     
     async def _():
         # 所有属于 `qq协议端` 的适配器下的 bot 都是可选择的,在无更多条件时随机挑选
         receipt = await Target.group("123456789", SupportScope.qq_client).send(UniMessage.image(path="test.png"))
         # receipt 会使用上次选择的 bot
         await receipt.send(...)
         # 此时仅选择 QQ 适配器的 bot
         await Target.channel_("123456789", SupportScope.qq_api, SupportAdapter.qq).send(UniMessage.image(path="test.png"))
         # 此时在 Satori 适配器下选择 `platform` 参数在 ["chronocat", "lark", "wecom"] 中的 bot
         await Target("123456789", adapter=SupportAdapter.satori, platform={"chronocat", "lark", "wecom"}).send(UniMessage.image(path="test.png"))
  • 新增 SupportScope:
     qq_client = "QQClient"
     """QQ 协议端"""
     qq_api = "QQAPI"
     """QQ 官方接口"""
     telegram = "Telegram"
     discord = "Discord"
     feishu = "Feishu"
     dodo = "DoDo"
     kook = "Kaiheila"
     minecraft = "Minecraft"
     github = "GitHub"
     bilibili = "Bilibili"
     console = "Console"
     ding = "Ding"
     wechat = "WeChat"
     """微信平台"""
     wechat_oap = "WeChatOfficialAccountPlatform"
     """微信公众号平台"""
     wecom = "WeCom"
     """企业微信平台"""
  • Receipt 增加属性 recallableeditable, 用来判断是否能够撤回消息和编辑消息
  • MediaToUrl 函数增加参数 bot: Bot
  • 修复合并转发在 onebot11 下的发送
  • get_bot 可以传入 predicate 参数,原 adapter 作为构建 predicate 的便捷方式
  • ⬆️ Bump dependabot/fetch-metadata from 1.6.0 to 2.0.0 by @dependabot in #42
  • ⬆️ auto update by pre-commit hooks by @pre-commit-ci in #44

Full Changelog: v0.41.1...v0.42.0