Skip to main content

nonebot-plugin-msgbuf

✨ 适用于 NoneBot2 插件的被动消息构造集成 ✨

代码比 SAA 和 SegBuilder 好看(不是)

license PyPI - Downloads pypi pypi python

介绍

nonebot-plugin-msgbuf 是帮助开发者快速构造与发送跨平台消息结构的应用的工具。相较于 SAA 与 SegBuilder,本插件在开发中结构更为清晰优雅。

适配器支持状态

符号 含义
✅ 完全支持
🟨 部分支持,需要用户额外分平台处理
❌ 不支持,发送时自动转化为后备文本
适配器 纯文本 图片 提及(@) 回复 表情 语音 视频 文件 分享 地理位置
OneBot V11 ✅ ✅ 🟨 🟨 🟨 ✅ ✅ ❌ ✅ ✅
OneBot V11 (Go-CQHTTP 拓展) ✅ ✅ 🟨 🟨 🟨 ✅ ✅ ✅ ✅ ✅
OneBot V12 ✅ ✅ 🟨 🟨 ❌ ✅ ✅ ✅ ❌ ✅
QQ 频道 ✅ ✅ 🟨 🟨 🟨 ❌ ❌ ❌ ❌ ❌
Telegram ✅ ✅ 🟨 🟨 🟨 ✅ ✅ ✅ ❌ ✅
未写明的 ✅ ❌ ❌ ❌ ❌ ❌ ❌ ❌ ❌ ❌

安装

通过 nb-cli:

nb plugin install nonebot-plugin-msgbuf

使用

竞品对比

这是常规的消息构造与发送方法:

展开
from nonebot import on_message
from nonebot.adapters.onebot.v11 import MessageSegment
from pathlib import Path

ma = on_message()

@ma.handle()
async def test():
    await ma.send(MessageSegment.image(Path("image.png")) + "Hello world!")

这是 SAA 的消息构造与发送方法:

展开
from nonebot import on_message, require
from pathlib import Path

require("nonebot_plugin_saa")

from nonebot_plugin_saa import MessageFactory, Text, Image

ma = on_message()

@ma.handle()
async def test():
    await MessageFactory([Image(Path("image.png")), Text("Hello world!")]).send()

这是 SegBuilder 的消息构造与发送方法:

展开
from nonebot import on_message, require
from pathlib import Path

require("nonebot_plugin_segbuilder")

from nonebot_plugin_segbuilder import SegmentBuilder

ma = on_message()

@ma.handle()
async def test():
    await ma.send(SegmentBuilder.image(Path("image.png")) + "Hello world!")

这是 MsgBuf 的消息构造与发送方法:

from nonebot import on_message, require
from pathlib import Path

require("nonebot_plugin_msgbuf")

from nonebot_plugin_msgbuf import MsgBuf

ma = on_message()

@ma.handle()
async def test():
    async with MsgBuf() as mb:
        mb.image(Path("image.png"))
        mb.text("Hello world!")
@ma.handle()
async def test():
    async with MsgBuf() as mb:
        mb.image(Path("image.png")).text("Hello world!")
from nonebot_plugin_msgbuf import Image, Text

@ma.handle()
async def test():
    async with MsgBuf() as mb:
        mb << Image(Path("image.png")) << Text("Hello world!")
@ma.handle()
async def test():
    await MsgBuf().image(Path("image.png")).text("Hello world!").send()

使用 Go-CQHTTP 拓展

发送文件

from nonebot_plugin_msgbuf import Specs
from pathlib import Path

@ma.handle()
async def test():
    async with MsgBuf(specs=Specs.OB11_GOCQHTTP) as mb:
        mb.file(Path("image.png"))

发送合并转发

from nonebot.adapters.onebot.v11 import Bot
from nonebot_plugin_msgbuf import FwdBuf

@ma.handle()
async def test(bot: Bot):
    async with FwdBuf(bot, ("group", 114514)) as fb:
        async with fb.node(1919810, "homo") as n:
            n.text("114514")
            n.image("file://homo.jpg")
        async with fb.node(1919810, "homo") as n:
            async with n.node(1919810, "homo") as n1:
                n1.text("homo")
            async with n.node(1919810, "homo") as n1:
                n1.text("1919810")

Metadata

Release files for nonebot-plugin-msgbuf 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nonebot-plugin-msgbuf 0.4.1
File Size Uploaded Provenance Actions
nonebot-plugin-msgbuf-0.4.1.tar.gz 12.9 kB Without provenance Details for nonebot-plugin-msgbuf-0.4.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for nonebot-plugin-msgbuf 0.4.1
File Interpreter ABI Platform Actions
nonebot_plugin_msgbuf-0.4.1-py3-none-any.whl Python 3 none any Details for nonebot_plugin_msgbuf-0.4.1-py3-none-any.whl

Total release size: 26.7 kB

Release files / nonebot-plugin-msgbuf-0.4.1.tar.gz

Download URL nonebot-plugin-msgbuf-0.4.1.tar.gz
Size 12.9 kB
Tags Source
SHA-256 checksum
How to use checksums
d485aeda56e5a467892e31507e983c918a88545923dc3e399f791cb2d8e9997c
BLAKE2b-256 checksum
How to use checksums
eced55a20137bcd936915c7f87b93d91d6c5e264170b628b8fd1165b77133174
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.17

Release files / nonebot_plugin_msgbuf-0.4.1-py3-none-any.whl

Download URL nonebot_plugin_msgbuf-0.4.1-py3-none-any.whl
Size 13.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a397d88dbed9ab6b489200ecbd5b7565dca730abc26035b6c1ef06d33658e01c
BLAKE2b-256 checksum
How to use checksums
346af95b577a10185b273e4cfd199832f31b19683884e2962d9dfc55169e3e82
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.17

Security for nonebot-plugin-msgbuf 0.4.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page