Skip to main content

一个支持图片翻译的nonebot2插件

Project description

NoneBotPluginLogo

NoneBotPluginText

nonebot-plugin-pictranslator

✨ NoneBot 插件简单描述 ✨

license pypi python

📖 介绍

一个基于Nonebot2的插件,提供多个api的文本及图片翻译功能,附带中英词典和ocr功能。

支持的api

一般来说只要百度API就够用了,如果想同时返回多个API的结果,可以在配置中设置对应TRANSLATE_MODEall

图片翻译

  • 有道 质量最好,但仅在注册账号时发放一次性免费余额
  • 百度 比有道稍差,不过免费额度每月刷新
  • 腾讯 API不支持整段识别,且不返回渲染后的图片,故对复杂图片质量较差,不推荐,尽管免费额度每月刷新

文本翻译

  • 腾讯 免费额度每月刷新,量大
  • 有道 仅在注册账号时发放一次性免费余额
  • 百度 免费额度每月刷新,额度比腾讯少

词典功能

语种识别

用于在未指定目标语言时检测源语言来自动选择目标语言

💿 安装

使用 nb-cli 安装 在 nonebot2 项目的根目录下打开命令行, 输入以下指令即可安装
nb plugin install nonebot-plugin-pictranslator
使用包管理器安装 在 nonebot2 项目的插件目录下, 打开命令行, 根据你使用的包管理器, 输入相应的安装命令
pip
pip install nonebot-plugin-pictranslator
pdm
pdm add nonebot-plugin-pictranslator
poetry
poetry add nonebot-plugin-pictranslator
uv
uv add nonebot-plugin-pictranslator
conda
conda install nonebot-plugin-pictranslator

打开 nonebot2 项目根目录下的 pyproject.toml 文件, 在 [tool.nonebot] 部分追加写入

plugins = ["nonebot_plugin_pictranslator"]

⚙️ 配置

在 nonebot2 项目的.env文件中添加下表中的必填配置

配置项 必填 默认值 可填值 说明
TEXT_TRANSLATE_APIS [tencent, baidu, youdao] List[tencent, baidu, youdao] 以什么优先级调用哪些api进行文本翻译
IMAGE_TRANSLATE_APIS [baidu, youdao, tencent] List[tencent, youdao, baidu] 以什么优先级调用哪些api进行图片翻译
TEXT_TRANSLATE_MODE 'auto' 'auto', 'all' 文本翻译模式,auto代表以优先级调用第一个可用api,all代表调用全部可用api
IMAGE_TRANSLATE_MODE 'auto' 'auto', 'all' 图片翻译模式,同上
腾讯API相关 / / / 详见腾讯文档
TENCENT_ID 若使用则必填 String 腾讯API的secret_id
TENCENT_KEY 若使用则必填 String 腾讯API的secret_key
USE_TENCENT / Bool 是否启用腾讯API,填写了上两项则默认启用
TENCENT_PROJECT_ID 0 Int 腾讯API的project_id
TENCENT_API_REGION String 腾讯API的secret_key
有道API相关 / / / 详见有道文档
YOUDAO_ID 若使用则必填 String 有道翻译API的secret_id
YOUDAO_KEY 若使用则必填 String 有道翻译API的secret_key
USE_YOUDAO / Bool 是否启用有道翻译API,填写了上两项则默认启用
百度API相关 / / / 详见百度文档
BAIDU_ID 若使用则必填 String 百度翻译API的secret_id
BAIDU_KEY 若使用则必填 String 百度翻译API的secret_key
USE_BAIDU / Bool 是否启用百度翻译API,填写了上两项则默认启用
TIANAPI_KEY String 天聚数行APIkey,用于中英词典查询

🎉 使用

指令表

指令 权限 需要@ 范围 说明
词典/查词 <单词> 群员 群聊 查询单词释义
(图片)翻译/<语言>译<语言> 群员 群聊 核心翻译功能,使用<语言>译<语言>来指定源语言和目标语言,可回复触发
ocr 群员 群聊 进行图片文字提取,可回复触发

Project details


Download files

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

Source Distribution

nonebot_plugin_pictranslator-0.1.2.tar.gz (18.9 kB view details)

Uploaded Source

Built Distribution

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

nonebot_plugin_pictranslator-0.1.2-py3-none-any.whl (22.7 kB view details)

Uploaded Python 3

File details

Details for the file nonebot_plugin_pictranslator-0.1.2.tar.gz.

File metadata

File hashes

Hashes for nonebot_plugin_pictranslator-0.1.2.tar.gz
Algorithm Hash digest
SHA256 1f5deba59ec888d5acdfc86fb0d3e56447ec430eed176ef351ef34e07693d059
MD5 167c51871d229b2773da0a3eebab9b54
BLAKE2b-256 b2140c64552d2b9ee5490b4d313d101941103f89b74f7f5b753c561c2b9f16c1

See more details on using hashes here.

File details

Details for the file nonebot_plugin_pictranslator-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for nonebot_plugin_pictranslator-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2c7fba4b584d0b8fadb696d47c2464b8f1aaee7c4d2510befa5c330215e79596
MD5 1f7d46a7b72f45171c5ed3edbbc16e13
BLAKE2b-256 f8202664a38c11722a0867a5460a4a1855491187a6395c3a03a54d5708e5ff0f

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