Skip to main content

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

Project description

nonebot-plugin-msgbuf

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

代码比 SAASegBuilder 好看(不是)

license PyPI - Downloads pypi pypi python

介绍

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

适配器支持状态

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

安装

通过 nb-cli:

nb plugin install nonebot-plugin-msgbuf

使用

关于 require() 的使用问题:

NoneBot2 插件的首次导入必须通过 NoneBot2 自身的方式(包括但不限于 require(), load_plugin() 等)完成,否则之后使用 NoneBot2 方式导入该插件的插件将无法正常工作。

NoneBot2 插件体系要求必须使用 require() 加载插件依赖。

竞品对比

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

展开
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.image(Path("image.png")).text("Hello world!").file(Path("image.png"))

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-msgbuf-0.2.0.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nonebot_plugin_msgbuf-0.2.0-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file nonebot-plugin-msgbuf-0.2.0.tar.gz.

File metadata

  • Download URL: nonebot-plugin-msgbuf-0.2.0.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for nonebot-plugin-msgbuf-0.2.0.tar.gz
Algorithm Hash digest
SHA256 6acccd5750b9ec07112d8d5e16baea2d2d89745b290017c0499e948f0d39117b
MD5 1af88f3b807bb0eae9d434eda4e126b4
BLAKE2b-256 c7bd32845f798f34fbb9fa0e510be4968ce5ebf7be5289f310eb54b7258b825b

See more details on using hashes here.

File details

Details for the file nonebot_plugin_msgbuf-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for nonebot_plugin_msgbuf-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b9fdabb6ee7f39b0b3f0f404328da7fe49bb8e476833c627b84d5c02599933f6
MD5 788547bc9ae18ecc3749ca920f8f3e48
BLAKE2b-256 e4fd931de01e4ea78d18f0f1f79f89bfdc32d8f3d845664806d1f454c0b02a19

See more details on using hashes here.

Supported by

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