📖 介绍
「能不能好好说话?」—— 拼音首字母缩写翻译插件。
看不懂群友在说什么?直接问 bot 就行。支持主动查询、自然语言问句触发,以及开启后的自动划词翻译。数据来源:神奇海螺试验场。
🎨 效果图
💿 安装
使用 nb-cli 安装
在 nonebot2 项目的根目录下打开命令行, 输入以下指令即可安装nb plugin install nonebot-plugin-nbnhhsh --upgrade
使用 pypi 源安装
nb plugin install nonebot-plugin-nbnhhsh --upgrade -i "https://pypi.org/simple"
使用清华源安装
nb plugin install nonebot-plugin-nbnhhsh --upgrade -i "https://pypi.tuna.tsinghua.edu.cn/simple"
使用包管理器安装
在 nonebot2 项目的插件目录下, 打开命令行, 根据你使用的包管理器, 输入相应的安装命令uv
uv add nonebot-plugin-nbnhhsh
安装仓库 master 分支
uv add git+https://github.com/ByteColtX/nonebot-plugin-nbnhhsh@master
pdm
pdm add nonebot-plugin-nbnhhsh
安装仓库 master 分支
pdm add git+https://github.com/ByteColtX/nonebot-plugin-nbnhhsh@master
poetry
poetry add nonebot-plugin-nbnhhsh
安装仓库 master 分支
poetry add git+https://github.com/ByteColtX/nonebot-plugin-nbnhhsh@master
打开 nonebot2 项目根目录下的 pyproject.toml 文件, 在 [tool.nonebot] 部分追加写入
plugins = ["nonebot_plugin_nbnhhsh"]
使用 nbr 安装(使用 uv 管理依赖可用)
nbr 是一个基于 uv 的 nb-cli,可以方便地管理 nonebot2
nbr plugin install nonebot-plugin-nbnhhsh
使用 pypi 源安装
nbr plugin install nonebot-plugin-nbnhhsh -i "https://pypi.org/simple"
使用清华源安装
nbr plugin install nonebot-plugin-nbnhhsh -i "https://pypi.tuna.tsinghua.edu.cn/simple"
⚙️ 配置
在 nonebot2 项目的.env文件中添加下表中的必填配置
| 配置项 | 必填 | 默认值 | 说明 |
|---|---|---|---|
NBNHHSH_AUTO |
否 | false |
开启自动划词翻译,bot 会自动识别消息中的缩写并回复 |
NBNHHSH_AUTO_MIN_LEN |
否 | 2 |
自动划词触发的最短缩写长度 |
NBNHHSH_TIMEOUT |
否 | 10 |
设置 HTTP 请求的超时时间(秒) |
NBNHHSH_TEXT2PIC |
否 | true |
是否将翻译结果以图片形式发送,避免因敏感词导致消息无法发送 |
图片渲染:
NBNHHSH_TEXT2PIC=true时结果画成图片发送。画图是直接用 Pillow 画的, 字体优先用系统里已有的中文字体(如fonts-noto-cjk),找不到会自动下载一份NotoSansSC.ttf缓存到系统用户缓存目录的nonebot-plugin-nbnhhsh/子目录;想手动指定,把字体文件放到那个目录即可。 系统没有中文字体且下载失败时,插件会退回发纯文本,不会中断回复。
🎉 使用
指令表
| 指令 | 权限 | 需要@ | 范围 | 说明 |
|---|---|---|---|---|
/nbnhhsh <缩写> |
群员 | 否 | 群聊/私聊 | 翻译缩写,别名:/好好说话 /hhsh /缩写 |
/nbnhhsh submit <缩写> <文字> |
群员 | 否 | 群聊/私聊 | 提交缩写的对应文字,审核通过后生效 |
/nbnhhsh 或 /nbnhhsh help |
群员 | 否 | 群聊/私聊 | 查看指令列表 |
| 自然语言问句 | 群员 | 否 | 群聊/私聊 | 发送「xx是什么」「xx是啥」「xx啥意思」等自动触发查询 |
自然语言触发示例
以下问法均可触发查询,无需命令前缀:
yyds是什么
gkd是啥
nbcs啥意思
yyds是什么意思
自动划词
开启 NBNHHSH_AUTO=true 后,bot 会自动识别消息中出现的缩写并翻译,只回复有实际翻译结果的词条,暂未录入的词条不会触发回复。
Metadata
Release files for nonebot-plugin-nbnhhsh 0.2.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| nonebot_plugin_nbnhhsh-0.2.4.tar.gz | 20.3 kB | Without provenance | Details for nonebot_plugin_nbnhhsh-0.2.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nonebot_plugin_nbnhhsh-0.2.4-py3-none-any.whl | Python 3 | none | any | Details for nonebot_plugin_nbnhhsh-0.2.4-py3-none-any.whl |
Total release size: 42.9 kB
Release files / nonebot_plugin_nbnhhsh-0.2.4.tar.gz
| Download URL | nonebot_plugin_nbnhhsh-0.2.4.tar.gz |
|---|---|
| Size | 20.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
23e17a91278b0e6858e0134c4df310d43c28b8e5c11cba2356981fc41b95ef1a
|
|
BLAKE2b-256 checksum How to use checksums |
4fe516118e341a799ec1998fa05e1a5af71cf2d4886fbdb0ce17785e3bbd47e6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / nonebot_plugin_nbnhhsh-0.2.4-py3-none-any.whl
| Download URL | nonebot_plugin_nbnhhsh-0.2.4-py3-none-any.whl |
|---|---|
| Size | 22.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7445fdbd8f67db2722436b447837fecc59c157bb0bb33ed31105d92343331d2a
|
|
BLAKE2b-256 checksum How to use checksums |
48ec1db6b97ae4372a18754c9189797845e7200acfec74e675a1b8e16bd47b34
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Security for nonebot-plugin-nbnhhsh 0.2.4
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.