SAGIRI-kawaii / sagiri-bot

基于Graia Ariadne和Mirai的QQ机器人 SAGIRI-BOT
GNU Affero General Public License v3.0
695 stars 83 forks source link

[Bug Report] Docker环境下:中文字符无法正常渲染/方块文字 #416

Open oldking139 opened 1 year ago

oldking139 commented 1 year ago

问题

经测试,此问题在Linux 容器化环境与Linux 裸机环境均有出现。

无法正常将中文渲染在图片上。 在Sagiri-bot启动后,使用帮助唤出机器人,机器人能够正常回答,但所有中文字符是方块。

如何复现

使用环境:请见下文 mcl正常启动,sagiri-bot正常启动并连接mirai。

发送帮助唤出机器人,等待机器人回复图片帮助信息。

预期行为

中文能够正常渲染在图片上。

使用环境

裸机与容器化环境均有测试。容器化启动时的镜像版本使用latest。Linux中文与英文环境均测试过。

- 系统: Ubuntu 22.04/CentOS 8-Stream/Ubuntu 20.04
- mirai 版本: 2.1.2-61c8bd8
- mirai-api-http 版本: v2.9.1
- Python 版本: 3.10.9 (from conda)
- 源码版本: sagiri-bot-4.2.0 (from git clone)
- 其他 Graia 库版本: 仓库克隆|docker镜像拉取版本
- 其他 有关 库版本: docker 23.0.1
- Mirai与Sagiri-bot未安装任何额外插件

日志/截图

日志

Sagiri-bot 日志
2023-03-14 01:48:33.758 | INFO     | __main__:group_message_handler:46 - 收到来自 Bot <2421973071> 群 <bot测试> 中成员 <George Kazami> 的消息:帮助
modules.required.helper True
2023-03-14 01:48:37.781 | INFO     | __main__:active_group_message_handler:80 - 成功向 Bot <2421973071> 群 <bot测试> 发送消息:[图片]
Mirai 日志
2023-03-14 01:48:33 V/Bot.2421973071: [bot测试(797291754)] George Kazami(1768172632) -> 帮助
2023-03-14 01:48:37 V/Bot.2421973071: Group(797291754) <- [mirai:quote:[mirai:source:ids=[575], internalIds=[-1363814527], from group 1768172632 to 797291754 at 1678729713], content=帮助][mirai:image:{4BB31546-72D8-8AF0-155D-96DE8E88D3D1}.jpg, width=1500, height=2913, size=398244, type=JPG, isEmoji=false]

图例

)R C1}8M}YM3PDEL )MPFMK

oldking139 commented 1 year ago

抄送 @YRFBK

nullqwertyuiop commented 1 year ago

系统缺少中文字体,需自行安装。

oldking139 commented 1 year ago

刚刚在windows上使用docker再次进行了测试。

镜像版本:

zaphakiel/sagiri-bot:latest
zaphakiel/sagiri-mah:latest

测试的结果是一样的,文字同样是方块。 同时,之前并没有注意,不过sagiri-bot在收到帮助指令时,容器抛出如下错误日志:

modules.required.helper True
modules.required.about not found!
modules.required.backend_api not found!
modules.required.chat_recorder not found!
modules.required.command not found!
modules.required.exception_catcher not found!
modules.required.group_member_backup not found!
modules.required.message_revoke not found!
modules.required.mirai_events not found!
modules.required.saya_manager not found!
modules.required.system_status not found!
modules.self_contained.abbreviated_prediction not found!
modules.self_contained.abstract_message_transform not found!
modules.self_contained.ai_text2img not found!
modules.self_contained.aminer not found!
modules.self_contained.anti_revoke not found!
modules.self_contained.apex_stat not found!
modules.self_contained.av_bt not found!
modules.self_contained.bangumi_info_searcher not found!
modules.self_contained.bangumi_searcher not found!
modules.self_contained.bilibili_bangumi_scheduler not found!
modules.self_contained.bilibili_resolve not found!
modules.self_contained.bt not found!
modules.self_contained.chat_gpt not found!
modules.self_contained.color_card not found!
modules.self_contained.cp_generator not found!
modules.self_contained.daily_newspaper not found!
modules.self_contained.dd_check not found!
modules.self_contained.dice not found!
modules.self_contained.emoji_mix not found!
modules.self_contained.genshin_chara_card not found!
modules.self_contained.genshin_voice not found!
modules.self_contained.github_info not found!
modules.self_contained.google_verification not found!
modules.self_contained.group_team not found!
modules.self_contained.homo_number_converter not found!
modules.self_contained.hot_words_explainer not found!
modules.self_contained.i_have_a_friend not found!
modules.self_contained.ill not found!
modules.self_contained.image_searcher not found!
modules.self_contained.joke not found!
modules.self_contained.keyword_respondent not found!
modules.self_contained.kugimiya_voice not found!
modules.self_contained.leetcode_info not found!
modules.self_contained.lolicon_keyword_searcher not found!
modules.self_contained.marketing_content_generator not found!
modules.self_contained.mockingbird not found!
modules.self_contained.music not found!
modules.self_contained.network_compiler not found!
modules.self_contained.pdf_searcher not found!
modules.self_contained.pero_dog not found!
modules.self_contained.phantom_tank not found!
modules.self_contained.pica not found!
modules.self_contained.qrcode_generator not found!
modules.self_contained.random_character not found!
modules.self_contained.random_food not found!
modules.self_contained.random_wife not found!
modules.self_contained.speak not found!
modules.self_contained.steam_game_info_searcher not found!
modules.self_contained.style_picture_generator not found!
modules.self_contained.super_resolution not found!
modules.self_contained.tarot not found!
modules.self_contained.test_plugin not found!
modules.self_contained.the_wondering_earth_counting_down not found!
modules.self_contained.trending not found!
modules.self_contained.wolfram_alpha not found!
modules.self_contained.wordcloud not found!
modules.self_contained.wordle not found!
modules.self_contained.xslist not found!

在Linux与Windows的docker环境测试后,个人觉得该问题应该与docker镜像构建环境有关。 可能需要在apt install处理相关依赖前处理容器镜像的语言环境。 https://github.com/SAGIRI-kawaii/sagiri-bot/blob/f4d16e0d6216c6c0dec20cc535dd99e515e76213/Dockerfile#L1 https://github.com/SAGIRI-kawaii/sagiri-bot/blob/f4d16e0d6216c6c0dec20cc535dd99e515e76213/Dockerfile#L5-L13

SAGIRI-kawaii commented 1 year ago

刚刚在windows上使用docker再次进行了测试。

镜像版本:

zaphakiel/sagiri-bot:latest
zaphakiel/sagiri-mah:latest

测试的结果是一样的,文字同样是方块。 同时,之前并没有注意,不过sagiri-bot在收到帮助指令时,容器抛出如下错误日志:

modules.required.helper True
modules.required.about not found!
modules.required.backend_api not found!
modules.required.chat_recorder not found!
modules.required.command not found!
modules.required.exception_catcher not found!
modules.required.group_member_backup not found!
modules.required.message_revoke not found!
modules.required.mirai_events not found!
modules.required.saya_manager not found!
modules.required.system_status not found!
modules.self_contained.abbreviated_prediction not found!
modules.self_contained.abstract_message_transform not found!
modules.self_contained.ai_text2img not found!
modules.self_contained.aminer not found!
modules.self_contained.anti_revoke not found!
modules.self_contained.apex_stat not found!
modules.self_contained.av_bt not found!
modules.self_contained.bangumi_info_searcher not found!
modules.self_contained.bangumi_searcher not found!
modules.self_contained.bilibili_bangumi_scheduler not found!
modules.self_contained.bilibili_resolve not found!
modules.self_contained.bt not found!
modules.self_contained.chat_gpt not found!
modules.self_contained.color_card not found!
modules.self_contained.cp_generator not found!
modules.self_contained.daily_newspaper not found!
modules.self_contained.dd_check not found!
modules.self_contained.dice not found!
modules.self_contained.emoji_mix not found!
modules.self_contained.genshin_chara_card not found!
modules.self_contained.genshin_voice not found!
modules.self_contained.github_info not found!
modules.self_contained.google_verification not found!
modules.self_contained.group_team not found!
modules.self_contained.homo_number_converter not found!
modules.self_contained.hot_words_explainer not found!
modules.self_contained.i_have_a_friend not found!
modules.self_contained.ill not found!
modules.self_contained.image_searcher not found!
modules.self_contained.joke not found!
modules.self_contained.keyword_respondent not found!
modules.self_contained.kugimiya_voice not found!
modules.self_contained.leetcode_info not found!
modules.self_contained.lolicon_keyword_searcher not found!
modules.self_contained.marketing_content_generator not found!
modules.self_contained.mockingbird not found!
modules.self_contained.music not found!
modules.self_contained.network_compiler not found!
modules.self_contained.pdf_searcher not found!
modules.self_contained.pero_dog not found!
modules.self_contained.phantom_tank not found!
modules.self_contained.pica not found!
modules.self_contained.qrcode_generator not found!
modules.self_contained.random_character not found!
modules.self_contained.random_food not found!
modules.self_contained.random_wife not found!
modules.self_contained.speak not found!
modules.self_contained.steam_game_info_searcher not found!
modules.self_contained.style_picture_generator not found!
modules.self_contained.super_resolution not found!
modules.self_contained.tarot not found!
modules.self_contained.test_plugin not found!
modules.self_contained.the_wondering_earth_counting_down not found!
modules.self_contained.trending not found!
modules.self_contained.wolfram_alpha not found!
modules.self_contained.wordcloud not found!
modules.self_contained.wordle not found!
modules.self_contained.xslist not found!

在Linux与Windows的docker环境测试后,个人觉得该问题应该与docker镜像构建环境有关。 可能需要在apt install处理相关依赖前处理容器镜像的语言环境。

https://github.com/SAGIRI-kawaii/sagiri-bot/blob/f4d16e0d6216c6c0dec20cc535dd99e515e76213/Dockerfile#L1

https://github.com/SAGIRI-kawaii/sagiri-bot/blob/f4d16e0d6216c6c0dec20cc535dd99e515e76213/Dockerfile#L5-L13

此处非错误日志,只是插件管理检测到插件不在信息文件内显示的提示,随后会将其信息写入文件

docker确实没有考虑到系统字体,之后会更改,也欢迎pr

Ly2817 commented 1 year ago

所以这个没有中文应该怎么办呢

nullqwertyuiop commented 1 year ago

所以这个没有中文应该怎么办呢

可能的解决方案:

  1. 在环境中自行安装中文字体
  2. 在帮助菜单 html 中定义来自于网络的中文字体
  3. 同 2,在 playwright 截图时劫持请求提供本地中文字体

补充: 方案 2 & 3 可能出现渲染 timeout (https://github.com/ProjectNu11/Eric/issues/53)