Chat Tsugu Py
✨ Python 编写的 TsuguBanGDreamBot 自然语言交互库 ✨
📦 安装
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_async是handler的异步版本,使用方法与handler相同。handler_raw_async同理。
🧵多线程支持
- tsugu 在导入时完成了
Alconna的初始化,避免了多线程context错误,因此可以在多线程中使用tsugu。
⚙️ api settings
安装
tsugu后可以直接导入tsugu_api_core的settings修改配置项。
from tsugu_api_core import settings
...
Metadata
Release files for tsugu 3.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| tsugu-3.1.2.tar.gz | 16.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| tsugu-3.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 48.4 kB
Release files / tsugu-3.1.2.tar.gz
| Download URL | tsugu-3.1.2.tar.gz |
|---|---|
| Size | 16.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e99441da2ef48ae7f3a1fdf40de4f2ff19a0378c32c24278976fe2e3001e8bb6
|
|
BLAKE2b-256 checksum How to use checksums |
f17710e153c388a2409969649dccf58933ebdd508faad54657ac941aa0a04afb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.12.4
|
Release files / tsugu-3.1.2-py3-none-any.whl
| Download URL | tsugu-3.1.2-py3-none-any.whl |
|---|---|
| Size | 32.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6cfda0999ed204902441da32b63a590251475d2361afb010200a083fd771727e
|
|
BLAKE2b-256 checksum How to use checksums |
3c9fa8551431b322025f18da794addf42b0073776611f91c5c92bba9efe92723
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.12.4
|