Skip to main content

tiebameow

License PyPI Python CI codecov

Tiebameow 项目通用模块

简介

tiebameow 是在 Tiebameow 项目内使用的通用模块,提供了通用的数据模型、序列化/反序列化工具、日志模块以及辅助函数。

目录

  • client: 包含增强的 aiotieba.Client 与 httpx 客户端。
  • models: 定义了通用数据交换模型和 ORM 数据模型。
  • parser: 提供解析和处理 aiotieba 数据和审查规则的解析器。
  • renderer: 提供将 DTO 内容或简单文本渲染为图片的功能。
  • schemas: 定义了各种数据片段与审查规则的 Pydantic 模型。
  • serializer: 提供数据交换模型的序列化和反序列化方法。
  • utils: 包含通用日志模块和一些辅助函数和工具类。

安装

推荐使用 uv 进行环境管理和依赖安装。

仅安装基础功能:

uv add tiebameow

如需使用数据库模型,请安装 orm 额外依赖:

uv add tiebameow[orm]

如需使用渲染功能,请安装 renderer 额外依赖和 Playwright 所需浏览器:

uv add tiebameow[renderer]
uv run playwright install chromium-headless-shell

基本用法

更多用法请参阅源码。

Client

Tieba Client

from tiebameow.client import Client

async with Client() as client:
    user_info = await client.get_user_info("some_username")

HTTP Client

from tiebameow.client import HTTPXClient

response = await HTTPXClient.get("https://example.com")

Parser

数据转换器

将 aiotieba 对象转换为通用数据交换模型:

from tiebameow.parser import convert_aiotieba_thread
from tiebameow.client import Client

async with Client() as client:
    threads = await client.get_threads("some_tieba")
    for thread in threads:
        converted_thread = convert_aiotieba_thread(thread)

规则引擎解析器

以 DSL 或 CNL 模式解析规则和动作:

from tiebameow.parser import RuleEngineParser

parser = RuleEngineParser()
rule_node = parser.parse_rule("(title contains 'A' AND title contains 'B') OR NOT title contains 'C'")
actions = parser.parse_actions("DO: delete(reason='spam content'), ban(days=1)")

Renderer

from tiebameow.renderer import Renderer

async with Renderer() as renderer:
    image_bytes = await renderer.text_to_image("Hello, World!")

开发指南

欢迎贡献代码,请确保遵循项目的编码规范,并在提交前运行 pre-commit hooks:

uv sync --dev
pre-commit install
pre-commit run --all-files

有关详细信息,请参阅 CONTRIBUTING.md 文件。

Metadata

Release files for tiebameow 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tiebameow 0.5.0
File Size Uploaded Provenance Actions
tiebameow-0.5.0.tar.gz 4.3 MB Without provenance Details for tiebameow-0.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for tiebameow 0.5.0
File Interpreter ABI Platform Actions
tiebameow-0.5.0-py3-none-any.whl Python 3 none any Details for tiebameow-0.5.0-py3-none-any.whl

Total release size: 8.5 MB

Release files / tiebameow-0.5.0.tar.gz

Download URL tiebameow-0.5.0.tar.gz
Size 4.3 MB
Tags Source
SHA-256 checksum
How to use checksums
9b770927fe74eef306add37857dd6fd25e19354fae4bc31efcd0f1e6bb284c35
BLAKE2b-256 checksum
How to use checksums
95400ed22b6861071c667ab59e4bbb27b9d406db9f4bdd25d6f4c4a852214456
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / tiebameow-0.5.0-py3-none-any.whl

Download URL tiebameow-0.5.0-py3-none-any.whl
Size 4.2 MB
Tags Python 3
SHA-256 checksum
How to use checksums
b0f7a9c61087b7e0e346ae133fb61efa1bc79da1be91dff62f9112efa2f0883d
BLAKE2b-256 checksum
How to use checksums
d78d94bfdd7231dd8c492ad26bbbc6842c893812af970de7484fa4083386a420
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for tiebameow 0.5.0

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.

Release history Release notifications | RSS feed

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page