- 基础消息事件
- 按钮事件上报接收
- 机器人设置事件
- 按钮发送
- 表单接收
| 元素 | 支持情况 |
|---|---|
| 文本 Text | ✅ |
| 图片 Image | ✅ |
| 提及用户 At(user) | ✅ |
| 按钮 Buttons | ✅ |
| 表单 Form | ⬇️ |
| 表情包 expression | ⬇️ |
| 语音 Audio | ⬇️ |
| 视频 Video | ✅ |
| 文件 File | ✅ |
| HTML HTML | ✅ |
| 文章 Post | ⬇️ |
| Markdown | ✅ |
| 提示信息 Tip | ⬇️ |
| 回复 Reply | ✅ |
| 操作 | 支持情况 |
|---|---|
| 发送 Send | ✅ |
| 撤回 Recall | ✅ |
| 编辑 Edit | ✅ |
| 表情响应 Reaction | 🚫 |
nonebot-adapter-yunhu 是为 NoneBot2 设计的云湖(YunHu)平台适配器,支持开发云湖机器人,提供完整的消息和服务支持。
pip install nonebot-adapter-yunhunb adapter install nonebot-adapter-yunhupoetry add nonebot-adapter-yunhu在您的 NoneBot 项目配置文件 .env 中添加以下配置:
app_id是 Bot 的 ID,可在 bot 信息页面查看
DRIVER=~fastapi+~httpx
YUNHU_BOTS = '[{
"app_id": "123456",
"token": "xxx",
}
]
'
HOST = 0.0.0.0
PORT = 8080在 bot.py 中注册适配器:
import nonebot
from nonebot.adapters.yunhu import Adapter as YunhuAdapter
nonebot.init()
driver = nonebot.get_driver()
driver.register_adapter(YunhuAdapter)在云湖控制台,上报地址为
http(s)://{HOST}:{PORT}/yunhu/{app_id}
Tip
建议使用 nonebot-plugin-alconna 和 nonebot-plugin-uninfo 等插件,来提高插件可移植性,避免直接与适配器底层交互
from nonebot import on_command
from nonebot.adapters.yunhu import Bot, Event
echo = on_command("echo")
@echo.handle()
async def handle_echo(bot: Bot, event: Event):
await echo.finish(event.get_message())具体类型参考 message.py
from nonebot import on_command
from nonebot.adapters.yunhu import Bot, Event, MessageSegment
test = on_command("test")
@test.handle()
async def handle_send_image(bot: Bot, event: Event):
# 发送文本
await test.send(MessageSegment.text("Hello World"))
# 发送图片, 也可以直接传参 raw=bytes 或 raw="imageKey"
await test.send(MessageSegment.image(url="xxxxx"))
# @某人
await test.send(MessageSegment.at("user_id"))
- 加入云湖群聊【NoneBot 云湖适配器交流群】: 链接
- 群 ID: 519215204
