Skip to main content

A NoneBot adapter for YunHu

Project description

nonebot

NoneBot-Adapter-YunHu

✨ YunHu adapter for NoneBot2 ✨

PyPI PyPI - Python Version GitHub

支持情况

事件支持情况

  • 基础消息事件
  • 按钮事件上报接收
  • 机器人设置事件
  • 按钮发送
  • 表单发送

支持的消息元素

元素 支持情况
文本 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 安装

pip install nonebot-adapter-yunhu

使用 poetry 安装

poetry 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}

使用方法

基本用法

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

send_image = on_command("image")

@send_image.handle()
async def handle_send_image(bot: Bot, event: Event):
    # 发送文本
    await bot.send(event, MessageSegment.text("Hello World"))
    # 有一种更简单的写法可以不用在上方写bot传参
    # await send_image.send(MessageSegment.text("test"))

    # 发送图片(需要先上传图片获取 image_key)/ 也可以直接传参raw=bytes,适配器会自动上传
    await bot.send(event, MessageSegment.image("image_key"))

    # @某人
    await bot.send(event, MessageSegment.at("user_id"))

获取帮助

image
  • 加入云湖群聊【NoneBot 云湖适配器交流群】: 链接
  • 群 ID: 519215204

相关链接

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_adapter_yunhu-0.0.7.tar.gz (20.1 kB view details)

Uploaded Source

Built Distribution

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

nonebot_adapter_yunhu-0.0.7-py3-none-any.whl (23.4 kB view details)

Uploaded Python 3

File details

Details for the file nonebot_adapter_yunhu-0.0.7.tar.gz.

File metadata

  • Download URL: nonebot_adapter_yunhu-0.0.7.tar.gz
  • Upload date:
  • Size: 20.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.14.0 Linux/6.11.0-1018-azure

File hashes

Hashes for nonebot_adapter_yunhu-0.0.7.tar.gz
Algorithm Hash digest
SHA256 d883bcd2f5995ca5423de94b9ccb5f5f2ef4f8ca105f0e4d4049f713abcb47be
MD5 7ea323fbb8f32188fde9bf5c210807cc
BLAKE2b-256 4fb935f08a75e36121dfbf61f8311775fb68e0faf4eac3ec069c515212e49c5c

See more details on using hashes here.

File details

Details for the file nonebot_adapter_yunhu-0.0.7-py3-none-any.whl.

File metadata

File hashes

Hashes for nonebot_adapter_yunhu-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 8d45c13a3acb9be9da97753fa789ad83f7d2a3df2b2ac08444ed5a687704b979
MD5 2a20a9d41e29a794c73e8d5a07bb16f9
BLAKE2b-256 f3ea20dcb22bf0b7e3b6be290bc6841f1d65fddc54728995e7e302a04521ae80

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