Skip to main content

Tsugu Beta3

✨tsugu✨

⚡️ Python 编写的 Tsugu 前端 ----- 第三次迭代的设计产物。⚡️

license license license


📜 Introduction

Tsugu-b3是 Tsugu 的第一个非官方前端, 自诞生以来致力于用户友好、开发自由.

自QQ官方机器人推出以来, Tsugu-b3 主要为 Tsugu QQ 官方机器人提供支持, 并稳定运行至今.

在未来, Tsugu-b3 依靠高阶函数设计, 也能随时为在各种环境下提供支持。

得益于此设计方式, Tsugu-b3 完全支持命令行下的使用, 为整体前后端的单元测试提供便捷思路.


📦 Install & Cli-Example

pip install tsugu
tsugu -h
tsugu 查卡 686

API powered by tsugu-api-python
Command matching provided by Alconna


📜 Feat

  • 为改善用户体验,本包与 koishi 插件 在部分行为上略有不同。
    • 更加详细的帮助信息。
    • 默认不需要命令头后跟上完整的空格(可关闭)。
    • 绑定玩家 解除绑定 刷新验证吗 等自验证策略。
    • 基于 Alconna 的真 “可选参数” 。
    • 车站相关功能不主动支持绑定账号的配队信息,但被动渲染车站给出的配队信息。
    • 参数错误时输出完整的命令帮助信息。
    • 略有不同的车站屏蔽词策略。
    • 增加 上传车牌 命令,但仍然支持自动从文本开头提取车牌。
    • 主账号 和 解除绑定 的不同行为。
  • 争议功能
    • 暂时支持 玩家状态 <serverName> 策略
    • 暂不支持 shortcut类指令
      • 暂不支持 国服模式 国服玩家状态 等指令
      • 而应该使用 主服务器 国服 玩家状态 国服 等指令式响应。
    • 暂不支持 Tsugu 内部车站互通,只通 bangdori station 。
  • 为了适应官方 BOT 的特性,本包提供了隐式一些非通用方法。
    • 当解除绑定用户数据库返回特定值时会被认定为安全模式,触发直接解除绑定操作。

🔧 Development

pip install -r req
pip install pillow

📚 Async & Higher-Order Function

cmd_generator 是一个异步方法,用于直接处理用户输入的自然语言并处理,调用传入的 send_func 发送结果

  • message (str):用户输入的自然语言
  • user_id (str):用户的 channel_id 或 user_id,当 platform 为 red 、 chronocat 、 onebot 时,该值一般为用户 QQ 号
  • platform (str):用户的平台(默认值:red)
  • send_func(Awaitable):期望一个接受 result 参数的异步方法,用于发送结果,具体需要实现的方法请参考下方示例
import asyncio
from tsugu import cmd_generator
from loguru import logger

async def _test_send_eg(result):
    if isinstance(result, list): [logger.success(item['string']) for item in result if item["type"] == "string"]

asyncio.run(cmd_generator(message='查卡 -h', user_id='114514', platform='satori',send_func=_test_send_eg))

✏️ Config

通过 环境变量 或通过项目下 .env 文件配置。

tsugu -e

查看可选的环境变量配置

优先级: .env 文件 > 环境变量 > b3 默认 > Tsugu Api Python 默认

Metadata

Release files for tsugu 6.4.1

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

Source distribution (sdist)

Source distribution for tsugu 6.4.1
File Size Uploaded Provenance Actions
tsugu-6.4.1.tar.gz 20.8 kB Without provenance Details for tsugu-6.4.1.tar.gz

Built distribution (wheel)

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

Total release size: 40.8 kB

Release files / tsugu-6.4.1.tar.gz

Download URL tsugu-6.4.1.tar.gz
Size 20.8 kB
Tags Source
SHA-256 checksum
How to use checksums
f11087d141693ba1bce4853e4bccfef9dd3b41adde0f8b27b28d23625cb215b8
BLAKE2b-256 checksum
How to use checksums
d6b2bbc587c365b00581e69795d800ade55042dcf3df1c25001e0244b57a0baa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / tsugu-6.4.1-py3-none-any.whl

Download URL tsugu-6.4.1-py3-none-any.whl
Size 20.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ac161f3c1bba29244af55e2e173e2a11cedeecbb6cb2af1b2ee0639fd14b239e
BLAKE2b-256 checksum
How to use checksums
c597462bdd82c4eb00cdf29906408365f3a0b1019c1c0755982a8e58827b0600
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Security for tsugu 6.4.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.

Release history Release notifications | RSS feed

This release

6.4.1 This release

2 release files No provenance

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