这是什么?
oopz-sdk 是一个面向 Oopz 平台 的异步 Python SDK,用于快速构建机器人、监听事件、收发消息、上传媒体并调用平台服务。
✨ 功能特性
- Bot 入口简单:通过
OopzBot完成连接、事件监听、消息回复和 Service 调用。 - 异步优先:基于
asyncio,适合长期运行的机器人和服务端应用。 - 类型友好:核心模型基于 Pydantic v2,便于补全、校验和测试。
- 事件驱动:支持消息、私信、撤回、编辑、频道变化、语音进出、身份组变化等事件。
- 消息与媒体:支持文本、图片、私信、引用回复、消息段解析和文件上传。
- Service 分层:提供消息、媒体、域、频道、用户、管理、语音等能力入口。
- 生态适配:OneBot v11和v12 适配正在不断完善~
📦 安装
pip install oopz-sdk
从源码安装:
git clone https://github.com/tangqingfeng7/Oopzbot-SDK.git
cd Oopzbot-SDK
pip install -e .
开发环境:
pip install -e ".[dev]"
pytest
需要语音能力时,还需要安装 Playwright Chromium:
python -m playwright install chromium
🚀 快速开始
创建 bot.py:
import asyncio
from oopz_sdk import OopzBot, OopzConfig
bot = OopzBot(OopzConfig.from_env())
@bot.on_ready
async def on_ready(ctx):
print("[READY] connected")
@bot.on_message
async def on_message(message, ctx):
if message.text.strip() == "ping":
await ctx.reply("pong")
asyncio.run(bot.run())
设置环境变量后运行:
export OOPZ_LOGIN_PHONE="..."
export OOPZ_LOGIN_PASSWORD="..."
python bot.py
Windows PowerShell:
$env:OOPZ_LOGIN_PHONE = "你的 OOPZ 登录账号"
$env:OOPZ_LOGIN_PASSWORD = "你的 OOPZ 登录密码"
python bot.py
更多登录方法详见 认证与凭据:
在机器人能收到的频道里发送:
ping
机器人会回复:
pong
更多用法请查看文档。
许可
Oopzbot-SDK 采用 MIT 许可证进行开源
免责声明
本项目由社区开发与维护,旨在为 Oopz 机器人开发、自动化集成和协议适配提供更方便的 Python 接口。使用本项目时请遵守 Oopz 平台相关规则,并妥善保管账号凭证、JWT、私钥等敏感信息。
Metadata
Release files for oopz-sdk 0.17.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| oopz_sdk-0.17.1.tar.gz | 192.6 kB | Without provenance | Details for oopz_sdk-0.17.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| oopz_sdk-0.17.1-py3-none-any.whl | Python 3 | none | any | Details for oopz_sdk-0.17.1-py3-none-any.whl |
Total release size: 367.0 kB
Release files / oopz_sdk-0.17.1.tar.gz
| Download URL | oopz_sdk-0.17.1.tar.gz |
|---|---|
| Size | 192.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2d7279be9778c9c4cfda99242171b8825e89264a880a04c4facdc9f205509b96
|
|
BLAKE2b-256 checksum How to use checksums |
6c62f8504fb072634a70b716402a4a2808454c641227003fbe66eac0e1f49dc6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.16
|
Release files / oopz_sdk-0.17.1-py3-none-any.whl
| Download URL | oopz_sdk-0.17.1-py3-none-any.whl |
|---|---|
| Size | 174.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a89466858358543ad8ee364af5b14a619d149ca0d31844d762e670b1b0478e04
|
|
BLAKE2b-256 checksum How to use checksums |
e49efecf639668d058b91c1c08c8dd7c01377386ab0dc04b8b21b4ebad9d54fb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.16
|
Security for oopz-sdk 0.17.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.