适用于 NoneBot2 插件的被动消息构造集成
Project description
介绍
nonebot-plugin-msgbuf
是帮助开发者快速构造与发送跨平台消息结构的应用的工具。相较于 SAA 与 SegBuilder,本插件在开发中结构更为清晰优雅。
适配器支持状态
符号 | 含义 |
---|---|
✅ | 完全支持 |
🟨 | 部分支持,需要用户额外分平台处理 |
❌ | 不支持,发送时自动转化为后备文本 |
适配器 | 纯文本 | 图片 | 提及(@) | 回复 | 表情 | 语音 | 视频 | 文件 | 分享 | 地理位置 |
---|---|---|---|---|---|---|---|---|---|---|
OneBot V11 | ✅ | ✅ | 🟨 | 🟨 | 🟨 | ✅ | ✅ | ❌ | ✅ | ✅ |
OneBot V11 (Go-CQHTTP 拓展) | ✅ | ✅ | 🟨 | 🟨 | 🟨 | ✅ | ✅ | ✅ | ✅ | ✅ |
未写明的 | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
安装
通过 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")) + "")
这是 SAA 的消息构造与发送方法:
展开
from nonebot import on_message
from pathlib import Path
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
from pathlib import Path
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()
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
Built Distribution
Close
Hashes for nonebot-plugin-msgbuf-0.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | b406cbf6c4f1a19d57f29a8725559aa3572c7ec3dfeac39fea5f6bc815c3fc20 |
|
MD5 | 306211bc256842f0816929e55ce431b2 |
|
BLAKE2b-256 | 29aabc37d7ac3779a779790019dfcb02ec28c8faed23fa3b1bdaa49c83becd2c |
Close
Hashes for nonebot_plugin_msgbuf-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5c3d30a6055bea1ca8e78bee22a5bd5a95f6dcd07db4828ba5a229a967fb2986 |
|
MD5 | e4299ec60aaa3276b9b0caf337c2b542 |
|
BLAKE2b-256 | 01c148c10538191d8063c9fb68ac77ef4f39f5b6a2acedda95879ce5b54a30e1 |