Skip to main content

Tsugu Python Frontend

Project description

Chat Tsugu Py tmrn

✨ Python 编写的 TsuguBanGDreamBot 自然语言交互库 ✨

license license license


📦 安装

pip install tsugu --upgrade

API powered by tsugu-api-python

Command matching provided by Alconna


📖 使用

handler & handler_raw

  • handler 是一个同步方法,用于直接处理用户输入的自然语言并返回查询结果:
  • 如果你方便使用 base64,handler_raw 方法或许会更好,tsugu 后端本身返回此数据结构,这个方法可以节省不必要的开销。
import tsugu

# 四个参数,分别意味着 消息内容 用户id 平台 频道id
for i in tsugu.handler('查卡 ars 1x', '1528593481'):
    print('文本: ',i) if isinstance(i, str) else None
    print(f"[图片]") if isinstance(i, bytes) else None

for i in tsugu.handler_raw('查卡 ars 1x', '1528593481'):
    print('文本: ',i) if i['type'] == 'text' else None
    print(f"[图片]") if i['type'] == 'base64' else None

在常用的qqbot中,群号就是 channel_id
当你使用QQ号作为 user_id 时,platform 默认 red

📚 异步支持

handler_async & handler_raw_async

  • handler_asynchandler 的异步版本,使用方法与 handler 相同。
  • handler_raw_async 同理。

🧵多线程支持

  • tsugu 在导入时完成了 Alconna 的初始化,避免了多线程 context 错误,因此可以在多线程中使用 tsugu

⚙️ api settings

安装 tsugu 后可以直接导入 tsugu_api_coresettings 修改配置项。

from tsugu_api_core import settings

...

tsugu_api settings 详细内容


Project details


Release history Release notifications | RSS feed

This version

3.1.6

Download files

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

Source Distribution

tsugu-3.1.6.tar.gz (16.4 kB view details)

Uploaded Source

Built Distribution

tsugu-3.1.6-py3-none-any.whl (32.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tsugu-3.1.6.tar.gz
  • Upload date:
  • Size: 16.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for tsugu-3.1.6.tar.gz
Algorithm Hash digest
SHA256 0e23e54fe6b0ee7c010791c8590fb3c13714d1e7e484810ac8b24b2e78ff8093
MD5 3385d1508c012f9c60110015d4c99d34
BLAKE2b-256 452d1ab0ff980a59bbb5ac097254531582fa936e718029e916e859199dbea9c6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tsugu-3.1.6-py3-none-any.whl
  • Upload date:
  • Size: 32.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for tsugu-3.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 0e8563575ef5454dd9c545cda1125d485aa8679343fdf984bee940a60631624e
MD5 16f66abf4d19d4370f6ca0ff720ce61f
BLAKE2b-256 aac0f09ea2047de4214d4a1ca63854a096330edc6f0c9f61fdc1a47b593af081

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page