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.1.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

nonebot_plugin_saalc-0.1.1-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: nonebot_plugin_saalc-0.1.1.tar.gz
  • Upload date:
  • Size: 8.7 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.1.tar.gz
Algorithm Hash digest
SHA256 a7fa6c35a8d3818d48e282e525ef6e8e41d58b8e382e8a49d79fa9c4c8b75bf0
MD5 97b006326ecc59fca8c27a3f467aa4e3
BLAKE2b-256 8575b0398fb421c70639f2109ab3f8e00e8ae823a9d46548d828eba23a6fb837

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for nonebot_plugin_saalc-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d39cfe71a3bafc6c16a7b42b089066528f649045ec3bbc761218b16af44d8f82
MD5 b29d059f7e9932a59571c38be35e43ed
BLAKE2b-256 422c20a94a63603b783fe75d84199abe1fb621d02811ee4c8ad1178a180eb0ea

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