Skip to main content

天津博瑞晧科 Python SDK,提供简单易用的天津博瑞晧科 API 交互功能,支持发送通知等操作。

Project description

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: 设备/用户 ID
  • version: 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!

联系方式

致谢

  • httpx - 高性能的异步 HTTP 客户端库
  • py_easy_httpx - 简化 HTTP 请求的工具包

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

py_easy_tjbrhk-1.0.1-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file py_easy_tjbrhk-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: py_easy_tjbrhk-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 5.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.6

File hashes

Hashes for py_easy_tjbrhk-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6c5ec61ac494bd1cfcf63d324813700e3f58d84e8c76ef5bfbc957a72e9c22d8
MD5 f069a24373982dfe9bd351038a287160
BLAKE2b-256 32db4acd8f6c6ca9b20d5ba66d3d08ed9e4c2becf20c0e58100f5c917a07af37

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