Skip to main content

SAA 风格的 alc 兼容插件

Project description

nonebot-plugin-saalc

✨ 使用 SAA 风格混合发送 SAA 和 alc 的消息 ✨

license pypi python

介绍

saalc 提供SAA自有消息段与 plugin-alconna.uniseg 的兼容。允许同时使用 SAA 和 plugin-alconna.uniseg。

UniMessageFactory 继承自 SAA 的 MessageFactory,与原有的 MessageFactory 用法基本一致,只是可以混合使用 nonebot_plugin_alconnanonebot_plugin_saa 的消息段类型(包括SAA不支持的消息段类型)

from nonebot_plugin_alconna import Text as AlcText, Image as AlcImage, UniMessage, File as AlcFile
from nonebot_plugin_saa import Text as SaaText, Image as SaaImage
from nonebot_plugin_saa.ext.uniseg import UniMessageFactory

@a_matcher.handle()
async def some():
    # 混合使用
    umf = UniMessageFactory(
        [
            AlcText("alc"),
            SaaText("saa"),
            AlcImage(url="https://al.c/image.png"),
            SaaImage("https://sa.a/image.png")
        ]
    )

    await umf.send()

    # 从 UniMessage 转换
    um = UniMessage(
        [
            AlcText("alc"),
            AlcImage(url="https://al.c/image.png"),
        ]
    )
    umf = UniMessageFactory.from_unimsg(um)
    await umf.send()

    # 混用 SAA 不支持的 File 消息段
    umf = UniMessageFactory(
        [
            SaaText("alc"),
            AlcFile(url="https://al.c/file.zip"),
        ]
    )
    await umf.send()

[!IMPORTANT]

  • 对于 UniMessageFactory 的发送结果(send/send_to/finish), 所产生的消息回执仍然是 SAA 的消息回执

兼容性

如果想在现有的 SAA 项目中使用 plugin-alconna.uniseg,可以直接导入 UniMessageFactory 来发送消息 只需要这样做:

from nonebot_plugin_saalc import UniMessageFactory as MessageFactory

就可以基本无缝地替换原有的 MessageFactory不保证,但你可以提 Issue 甚至 Pull Request 是吧(

saalc 是基于 SAA 的功能扩展,其范围基本以 SAA 的功能为主,saalc 中所提供功能范围的取决情况:

功能 SAA alc
消息段范围
平台目标
消息回执
消息 ID

安装方法

使用 nb-cli 安装 在 nonebot2 项目的根目录下打开命令行, 输入以下指令即可安装
nb plugin install nonebot-plugin-saalc
使用包管理器安装 在 nonebot2 项目的插件目录下, 打开命令行, 根据你使用的包管理器, 输入相应的安装命令
pip
pip install nonebot-plugin-saalc
pdm
pdm add nonebot-plugin-saalc
poetry
poetry add nonebot-plugin-saalc

打开 nonebot2 项目根目录下的 pyproject.toml 文件, 在 [tool.nonebot] 部分追加写入

plugins = ["nonebot_plugin_template"]

相关项目

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nonebot_plugin_saalc-0.1.0.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

nonebot_plugin_saalc-0.1.0-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file nonebot_plugin_saalc-0.1.0.tar.gz.

File metadata

  • Download URL: nonebot_plugin_saalc-0.1.0.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: pdm/2.15.4 CPython/3.10.12 Linux/6.5.0-1021-azure

File hashes

Hashes for nonebot_plugin_saalc-0.1.0.tar.gz
Algorithm Hash digest
SHA256 234e9594bd664a88f0ecf0c861d58e44d12595d8726b047c48b99d23b9f4bb31
MD5 eea88255bc63ac9729008e0b0cefe2bb
BLAKE2b-256 1ed8c86f9a54d9df285fa72291d5af6f8a9d401b3f2d47d4de763fb87b92ba05

See more details on using hashes here.

File details

Details for the file nonebot_plugin_saalc-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for nonebot_plugin_saalc-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b30e27ad2a4525bb3a3bd4ad14b0eb41d940d3ca3672dae90ae157825e03a830
MD5 4c7dc637f0000d591324e464b44debf8
BLAKE2b-256 559bf95b60c0017840d910e3ec71f8eb57ea324927e910da894225527e3ccc37

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page