Skip to main content

Tsugu Python Frontend

Project description

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


🛠 Related Projects

📜 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_iduser_id,当 platformredchronocatonebot 时,该值一般为用户 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 默认

Project details


Release history Release notifications | RSS feed

This version

6.4.1

Download files

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

Source Distribution

tsugu-6.4.1.tar.gz (20.8 kB view details)

Uploaded Source

Built Distribution

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

tsugu-6.4.1-py3-none-any.whl (20.0 kB view details)

Uploaded Python 3

File details

Details for the file tsugu-6.4.1.tar.gz.

File metadata

  • Download URL: tsugu-6.4.1.tar.gz
  • Upload date:
  • Size: 20.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for tsugu-6.4.1.tar.gz
Algorithm Hash digest
SHA256 f11087d141693ba1bce4853e4bccfef9dd3b41adde0f8b27b28d23625cb215b8
MD5 7a2c56adbdfd2ea78fb8ae17eb254014
BLAKE2b-256 d6b2bbc587c365b00581e69795d800ade55042dcf3df1c25001e0244b57a0baa

See more details on using hashes here.

File details

Details for the file tsugu-6.4.1-py3-none-any.whl.

File metadata

  • Download URL: tsugu-6.4.1-py3-none-any.whl
  • Upload date:
  • Size: 20.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for tsugu-6.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ac161f3c1bba29244af55e2e173e2a11cedeecbb6cb2af1b2ee0639fd14b239e
MD5 cae58d9ba7689d05714f9eaf12e8abc0
BLAKE2b-256 c597462bdd82c4eb00cdf29906408365f3a0b1019c1c0755982a8e58827b0600

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