Skip to main content

米游社大别野Bot Python SDK。MiHoYo Villa Bot Python SDK.

Project description

Villa

✨ 米游社大别野Bot Python SDK ✨

license version python pypi download wakatime ruff

特性

  • 基于FastAPIPydantic,异步优先、快速、高性能!
  • 完整的类型注解支持,便于开发。
  • 便捷的消息构造和发送方法。
  • 完整的消息段和API支持。
  • Serverless云函数支持。
  • More 想不出来了

安装

  • 使用 pip: pip install villa
  • 使用 poetry: poetry add villa
  • 使用 pdm: pdm add villa

快速开始

你需要一个米游社大别野的 Bot,可前往大别野「机器人开发者社区」(ID: OpenVilla)申请,取得bot_idbot_secretpub_key

from villa import Bot
from villa.event import SendMessageEvent

bot = Bot(
    bot_id="your_bot_id",
    bot_secret="your_bot_secret",
    pub_key="-----BEGIN PUBLIC KEY-----\nyour_pub_key\n-----END PUBLIC KEY-----\n",
    callback_url="your_callback_url_endpoint",
)
# 初始化Bot,填写你的bot_id、密钥、pub_key以及回调地址endpoint
# 举例:若申请时提供的回调地址为https://域名/callback,这里的callback_url就填`/callback`

@bot.on_startswith("hello")
async def handler(event: SendMessageEvent):
    await event.send("world!")
    # 一个简单的处理函数,向你的Bot发送包含`hello`关键词的消息,它将会回复你`world`!


if __name__ == "__main__":
    bot.run(host="127.0.0.1", port=13350)
    # 启动bot,注意,port端口号要和你所使用的回调地址端口对上

示例

详见 example 文件夹:

交流、建议和反馈

注意:本SDK并非官方SDK

大别野 Bot 和本 SDK 均为开发测试中,如遇问题请提出 issue ,感谢支持!

也欢迎来我的大别野「尘世闲游」(ID: wgiJNaU)进行交流~

相关项目

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

villa-0.7.0.tar.gz (25.3 kB view details)

Uploaded Source

Built Distribution

villa-0.7.0-py3-none-any.whl (26.8 kB view details)

Uploaded Python 3

File details

Details for the file villa-0.7.0.tar.gz.

File metadata

  • Download URL: villa-0.7.0.tar.gz
  • Upload date:
  • Size: 25.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.17

File hashes

Hashes for villa-0.7.0.tar.gz
Algorithm Hash digest
SHA256 4972a4028f0012fb56c7297fdd2da962493384756bc693ab600f4e106b9f24a4
MD5 eed4bfc816b765ac00c3e794e8d9001d
BLAKE2b-256 bd02588029ed422f9d7dfbba3e33c0f1f19768e93c036bd417131325e065d35e

See more details on using hashes here.

File details

Details for the file villa-0.7.0-py3-none-any.whl.

File metadata

  • Download URL: villa-0.7.0-py3-none-any.whl
  • Upload date:
  • Size: 26.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.17

File hashes

Hashes for villa-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dae4b9f5afc89c590b4a487131862de0c6861f015bce878d2727105a150dd639
MD5 4f35e5fede93f87d38fedc48cdbc7cba
BLAKE2b-256 a1ba3d51bc207c5860c79293b8648ef2e65d08549529f99678988ccce41e108d

See more details on using hashes here.

Supported by

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