Tsugu Python Frontend
Project description
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
...
Project details
Release history Release notifications | RSS feed
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.1.tar.gz
(16.0 kB
view details)
Built Distribution
tsugu-3.1.1-py3-none-any.whl
(32.4 kB
view details)
File details
Details for the file tsugu-3.1.1.tar.gz
.
File metadata
- Download URL: tsugu-3.1.1.tar.gz
- Upload date:
- Size: 16.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a2c7a8c5011c3f3e6726526414d208fb524df761945dc97dd2a832fb30568f04 |
|
MD5 | ee7d64052f22bb2c0af09b28852db2eb |
|
BLAKE2b-256 | 6b23bd4baa667e8879943a0fc63edc4ce1bf8a93c58e11f47da188d922c48ef3 |
File details
Details for the file tsugu-3.1.1-py3-none-any.whl
.
File metadata
- Download URL: tsugu-3.1.1-py3-none-any.whl
- Upload date:
- Size: 32.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 47c80c49fedb2038609a6d553400b9650bcf2999449a592c9378e324990d1ef3 |
|
MD5 | a487b579bcd7d2a13b7aed8c6170a24a |
|
BLAKE2b-256 | d289fc12a9b404b5f36c46a170f1dc3747c7e884ed7bac6079abb8de70064de0 |