Skip to main content

A NoneBot adapter for YunHu

Project description

nonebot

# NoneBot-Adapter-YunHu

✨ YunHu adapter for NoneBot2 ✨

PyPI PyPI - Python Version GitHub

事件支持情况

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

简介

nonebot-adapter-yunhu 是一个为 NoneBot2 设计的云湖(YunHu)平台适配器。它允许您使用 NoneBot2 框架开发云湖机器人,提供了对云湖平台消息和服务的完整支持。

安装

使用 pip 安装

pip install nonebot-adapter-yunhu

使用 poetry 安装

poetry add nonebot-adapter-yunhu

配置

在您的 NoneBot 项目配置文件 .env 中添加以下配置:

DRIVER=~fastapi+~httpx

YUNHU_BOTS = '[{
    "app_id": "123456",
    "token": "xxx",
}
]
'

HOST = 127.0.0.1
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, MessageEvent

echo = on_command("echo")

@echo.handle()
async def handle_echo(bot: Bot, event: MessageEvent):
    await echo.finish(event.get_message())

发送不同类型的消息

具体类型参考message.py

from nonebot import on_command
from nonebot.adapters.yunhu import Bot, MessageEvent, MessageSegment

send_image = on_command("image")

@send_image.handle()
async def handle_send_image(bot: Bot, event: MessageEvent):
    # 发送文本
    await bot.send(event, MessageSegment.text("Hello World"))

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

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

特性

  • ✅ 支持接收和发送多种类型的消息
  • ✅ 支持 Webhook 回调模式
  • ✅ 完整的事件系统支持
  • ✅ 易于使用的 API 封装
  • ✅ 良好的类型提示支持

支持

image

许可证

MIT License

相关链接

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.3.tar.gz (18.2 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.3-py3-none-any.whl (21.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: nonebot_adapter_yunhu-0.0.3.tar.gz
  • Upload date:
  • Size: 18.2 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.3.tar.gz
Algorithm Hash digest
SHA256 7422cb2427bbf03cc2d20779c6609b4d319580780fd3d9d493d01e32617e3d3f
MD5 99155fa4d88d671b0e7940aa0a278b3e
BLAKE2b-256 e3e563de4b909827a1226a934c26e7c1eb28d74d8192b13b40d8118734706919

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for nonebot_adapter_yunhu-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ed7a7cb5b02753a5b62424d9455da385028564f7f06399b53d7a707d3724b2f0
MD5 200350ad8db5d29dbd37af6c5c2ce2b3
BLAKE2b-256 18b9a8aace8291abdecc0e528c2071dfe0857a34a059b16d2f258c7bee48deb1

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