py_easy_tjbrhk
天津博瑞晧科 Python SDK,提供简单易用的天津博瑞晧科 API 交互功能,支持发送通知等操作。
功能特性
- 通知发送:支持同步和异步发送通知
- 灵活配置:支持通过参数自定义客户端行为
- 响应处理:提供 JSON 数据验证功能
- 同步/异步支持:同时支持同步和异步操作
- 类型提示:完整的类型注解,提供良好的 IDE 支持
安装
使用 pip 安装
pip install py_easy_tjbrhk
从源码安装
git clone https://gitee.com/guolei19850528/py_easy_tjbrhk.git
cd py_easy_tjbrhk
pip install -e .
依赖
- httpx
- py_easy_httpx
快速开始
同步发送通知
from py_easy_tjbrhk.speaker import Speaker
# 初始化播报机器人客户端
speaker = Speaker(
token="YOUR_TOKEN",
id="YOUR_ID"
)
# 发送通知
response = speaker.notify(
message="这是一条测试通知"
)
print(f"发送结果: {response}")
异步发送通知
import asyncio
from py_easy_tjbrhk.speaker import Speaker
async def main():
# 初始化播报机器人客户端
speaker = Speaker(
token="YOUR_TOKEN",
id="YOUR_ID"
)
# 异步发送通知
response = await speaker.async_notify(
message="这是一条测试通知"
)
print(f"发送结果: {response}")
asyncio.run(main())
API 文档
Speaker 类
初始化参数
base_url: API 基础 URL,默认为 "https://speaker.17laimai.cn"token: 认证令牌id: 设备/用户 IDversion: API 版本号,默认为 "1"client_kwargs: 传递给 httpx.Client 的额外参数
方法
notify(client=None, message="", **kwargs): 同步发送通知async_notify(client=None, message="", **kwargs): 异步发送通知
高级用法
自定义客户端配置
from py_easy_tjbrhk.speaker import Speaker
# 初始化播报机器人客户端,自定义客户端配置
speaker = Speaker(
token="YOUR_TOKEN",
id="YOUR_ID",
client_kwargs={
"timeout": 30.0, # 设置超时时间为 30 秒
"headers": {
"User-Agent": "py_easy_tjbrhk"
}
}
)
# 发送通知
response = speaker.notify(
message="这是一条测试通知"
)
print(f"发送结果: {response}")
项目结构
py_easy_tjbrhk/
├── py_easy_tjbrhk/ # 主包目录
│ ├── __init__.py # 包初始化文件
│ └── speaker.py # 播报机器人模块
├── README.md # 项目文档
├── setup.py # 安装配置
├── requirements.txt # 依赖列表
├── LICENSE # 许可证文件
├── deploy.sh # 部署脚本
├── .gitignore # Git 忽略文件
└── test_speaker.py # 测试文件
测试
运行测试:
# 运行测试
python test_speaker.py
许可证
MIT License
贡献
欢迎提交 Issue 和 Pull Request!
联系方式
- 作者:guolei
- 邮箱:174000902@qq.com
- 项目地址:https://gitee.com/guolei19850528/py_easy_tjbrhk
致谢
- httpx - 高性能的异步 HTTP 客户端库
- py_easy_httpx - 简化 HTTP 请求的工具包
Metadata
Release files for py-easy-tjbrhk 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| py_easy_tjbrhk-1.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Release files / py_easy_tjbrhk-1.0.1-py3-none-any.whl
| Download URL | py_easy_tjbrhk-1.0.1-py3-none-any.whl |
|---|---|
| Size | 5.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6c5ec61ac494bd1cfcf63d324813700e3f58d84e8c76ef5bfbc957a72e9c22d8
|
|
BLAKE2b-256 checksum How to use checksums |
32db4acd8f6c6ca9b20d5ba66d3d08ed9e4c2becf20c0e58100f5c917a07af37
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.6
|
Security for py-easy-tjbrhk 1.0.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.