Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

一个建议、一个反馈 #7

Closed
homileak opened this issue Feb 17, 2022 · 17 comments
Closed

一个建议、一个反馈 #7

homileak opened this issue Feb 17, 2022 · 17 comments
Labels
enhancement New feature or request

Comments

@homileak
Copy link

homileak commented Feb 17, 2022

先向您提一个建议
我在配置这个插件的过程中发现这个插件是需要配置代理的,这确实是一个很棒的功能,免去了很多人需要代理才能连接到sonet的麻烦,呃,不过呢,就是,我的VPS,是不需要代理,直接就能连接到sonet的,所以配置代理,反而成了我的一个障碍。
我想向您建议一下,希望能加一个选择是否开启代理的选项。
我也有试着自己修改

我先是注释掉了__init__.py中的
with open(join(curpath, 'account.json')) as fp:
pinfo = load(fp)
两行

然后删掉了
client_1cx = pcrclient(acinfo_1cx['UDID'], acinfo_1cx['SHORT_UDID'], acinfo_1cx['VIEWER_ID'], acinfo_1cx['TW_SERVER_ID'], pinfo['proxy'])
client_2cx = pcrclient(acinfo_2cx['UDID'], acinfo_2cx['SHORT_UDID'], acinfo_2cx['VIEWER_ID'], acinfo_2cx['TW_SERVER_ID'], pinfo['proxy'])
client_3cx = pcrclient(acinfo_3cx['UDID'], acinfo_3cx['SHORT_UDID'], acinfo_3cx['VIEWER_ID'], acinfo_3cx['TW_SERVER_ID'], pinfo['proxy'])
client_4cx = pcrclient(acinfo_4cx['UDID'], acinfo_4cx['SHORT_UDID'], acinfo_4cx['VIEWER_ID'], acinfo_4cx['TW_SERVER_ID'], pinfo['proxy'])
四行中的
, pinfo['proxy']

接着在pcrclient.py中,删掉了
def __init__(self, udid, short_udid, viewer_id, platform, proxy):
中的
, proxy
注释掉了下方的
self.proxy = proxy
接着注释掉了
resp = await post(self.apiroot + apiurl,
data = crypted,
headers = self.headers,
timeout = 5,
proxies = self.proxy,
verify = False)
response = await resp.content
中的
proxies = self.proxy,

然后我重启了bot,插件工作一切正常,功能都可用,bot查询的数据也都没有问题。
2501

先向您提一个反馈
插件功能在正常运行中,查询、绑定、提示均没有问题。
但是Console里有大量的warning,类似:
warnings.warn(
pcrclient: /load/index api called
/root/.cache/pypoetry/virtualenvs/bot-A667jdCO-py3.9/lib/python3.9/site-packages/urllib3/connectionpool.py:1013: InsecureRequestWarning: Unverified HTTPS request is being made to host 'api-pc.so-net.tw'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings
意思似乎是插件和sonet的api之间的https链接并不可靠。
因为我并没有使用代理而是直连sonet
所以我并不太清楚其他配置了代理的人是否有这些warning
请问这是正常现象吗?

@CYDXDianXian
Copy link
Collaborator

额,其实不用那么麻烦,不用代理的话直接把account.json中的代理地址留空即可。

{
    "proxy": {}
}

至于你说的这个警告,我没有遇到过,我留空代理地址然后上港区服务器测试没有问题。你按照上述方法留空代理,其他地方不要做任何改动试试。

@azmiao
Copy link
Owner

azmiao commented Feb 17, 2022

你莫非用的centos?,centos上确实会有一些ssl证书验证问题,winserver就不会了,有些ssl问题也真的解决不了,不过你这个warning当然完全可以不管,您甚至可以直接添加disable,关掉该warning的显示

@homileak
Copy link
Author

你莫非用的centos?,centos上确实会有一些ssl证书验证问题,winserver就不会了,有些ssl问题也真的解决不了,不过你这个warning当然完全可以不管,您甚至可以直接添加disable,关掉该warning的显示

谢谢您的回复,不过我并没有使用CentOS,我使用的是Ubuntu 18.04.5,我准备试一下上楼[CYDXDianXian]说的会不会有变化。

@homileak
Copy link
Author

额,其实不用那么麻烦,不用代理的话直接把account.json中的代理地址留空即可。

{
    "proxy": {}
}

至于你说的这个警告,我没有遇到过,我留空代理地址然后上港区服务器测试没有问题。你按照上述方法留空代理,其他地方不要做任何改动试试。

多谢您的回复,我试了一下,直接留空代理插件也可以正常工作。不过ssl warning还是依旧。

@azmiao
Copy link
Owner

azmiao commented Feb 18, 2022

InsecureRequestWarning: Unverified HTTPS request is being made to host

pcrclient.py找个地方加一句关闭显示吧,部分linux的ssl问题很麻烦,不过你这个至少能用2333

import reuqests
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)

不过不确定这样写是否有问题,如果没记错的话,用的应该是星乃的aio,用装饰器装饰过requests了。
不行的画就把这一段加到hoshinobot下的aiorequests.py里面

@homileak
Copy link
Author

你莫非用的centos?,centos上确实会有一些ssl证书验证问题,winserver就不会了,有些ssl问题也真的解决不了,不过你这个warning当然完全可以不管,您甚至可以直接添加disable,关掉该warning的显示

我刚按照CYDXDianXian说的试了一下,插件可以正常直连sonet,ssl warning还是依旧(不过并不影响使用就是了)。

哦,如果您不介意的话,我想顺便向您提问一下,这个插件在推送查询信息的时候,会在支援角色名的后面加上头像,这确实是一个很棒的功能,因为hoshinobot的角色名经常会出现日文,有头像的话就不会混,但是有一个问题就是,这个头像实在是太大了,导致一条查询推送要上下拉好几下,手机也要划好几下才能看全。
3225
我想让它显示显示的小一点,我找到了发送消息的部分
msg_f = f'{c_favorite.name}{c_favorite.icon.cqcode}'
但是这里是直接角色名+头像cq码,我不不知道该如何实现让现有的头像缩小一些再发出去,如果可以的话,希望您能指点一下。

@homileak
Copy link
Author

InsecureRequestWarning: Unverified HTTPS request is being made to host

pcrclient.py找个地方加一句关闭显示吧,部分linux的ssl问题很麻烦,不过你这个至少能用2333

import reuqests
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)

不过不确定这样写是否有问题,如果没记错的话,用的应该是星乃的aio,用装饰器装饰过requests了。 不行的画就把这一段加到hoshinobot下的aiorequests.py里面

好的,我试一下。

@azmiao
Copy link
Owner

azmiao commented Feb 18, 2022

你莫非用的centos?,centos上确实会有一些ssl证书验证问题,winserver就不会了,有些ssl问题也真的解决不了,不过你这个warning当然完全可以不管,您甚至可以直接添加disable,关掉该warning的显示

我刚按照CYDXDianXian说的试了一下,插件可以正常直连sonet,ssl warning还是依旧(不过并不影响使用就是了)。

哦,如果您不介意的话,我想顺便向您提问一下,这个插件在推送查询信息的时候,会在支援角色名的后面加上头像,这确实是一个很棒的功能,因为hoshinobot的角色名经常会出现日文,有头像的话就不会混,但是有一个问题就是,这个头像实在是太大了,导致一条查询推送要上下拉好几下,手机也要划好几下才能看全。 3225 我想让它显示显示的小一点,我找到了发送消息的部分 msg_f = f'{c_favorite.name}{c_favorite.icon.cqcode}' 但是这里是直接角色名+头像cq码,我不不知道该如何实现让现有的头像缩小一些再发出去,如果可以的话,希望您能指点一下。

这个好像还真没法改小,QQ会把图片自动缩放,有一说一我也觉得太大了。
一个解决方案是,可以把所有支援的角色全部用pil嵌入合成一张图片,我待会有时间的话就改改

@homileak
Copy link
Author

InsecureRequestWarning: Unverified HTTPS request is being made to host

pcrclient.py找个地方加一句关闭显示吧,部分linux的ssl问题很麻烦,不过你这个至少能用2333

import reuqests
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)

不过不确定这样写是否有问题,如果没记错的话,用的应该是星乃的aio,用装饰器装饰过requests了。 不行的画就把这一段加到hoshinobot下的aiorequests.py里面

刚刚尝试,加到pcrclient.py里并不行,似乎是pceclient.py并不能改变aiorequests.py的设定。
再次尝试,加到aiorequests.py之后就不再显示ssl warning了。

@homileak
Copy link
Author

你莫非用的centos?,centos上确实会有一些ssl证书验证问题,winserver就不会了,有些ssl问题也真的解决不了,不过你这个warning当然完全可以不管,您甚至可以直接添加disable,关掉该warning的显示

我刚按照CYDXDianXian说的试了一下,插件可以正常直连sonet,ssl warning还是依旧(不过并不影响使用就是了)。
哦,如果您不介意的话,我想顺便向您提问一下,这个插件在推送查询信息的时候,会在支援角色名的后面加上头像,这确实是一个很棒的功能,因为hoshinobot的角色名经常会出现日文,有头像的话就不会混,但是有一个问题就是,这个头像实在是太大了,导致一条查询推送要上下拉好几下,手机也要划好几下才能看全。 3225 我想让它显示显示的小一点,我找到了发送消息的部分 msg_f = f'{c_favorite.name}{c_favorite.icon.cqcode}' 但是这里是直接角色名+头像cq码,我不不知道该如何实现让现有的头像缩小一些再发出去,如果可以的话,希望您能指点一下。

这个好像还真没法改小,QQ会把图片自动缩放,有一说一我也觉得太大了。 一个解决方案是,可以把所有支援的角色全部用pil嵌入合成一张图片,我待会有时间的话就改改

我现在是用了两种方法
一种是直接不发送头像,只发送角色名,这样的话消息比较简洁,一屏就能全部显示,不足之处是有些角色会出现日文(主要是一些比较新的限定角色)。
另一种是不显示角色名,只发送头像,这样在PC QQ客户端上头像不会被QQ换行,一行可以显示两个头像,虽然头像还是很大,不过比起之前也好多了。手机QQ客户端上并没有什么改善。

@azmiao azmiao added the enhancement New feature or request label Feb 18, 2022
@azmiao
Copy link
Owner

azmiao commented Feb 18, 2022

哦,我发现这个在Post请求时故意不验证ssl的,所以才会爆warning,这个属于必然现象,我好像很久之前就加了关闭显示所以看不到,然后支援头像合并也差不多快弄好了,先出趟门,待会回来改完就提交

@CYDXDianXian
Copy link
Collaborator

CYDXDianXian commented Feb 18, 2022

哦,我发现这个在Post请求时故意不验证ssl的,所以才会爆warning,这个属于必然现象,我好像很久之前就加了关闭显示所以看不到,然后支援头像合并也差不多快弄好了,先出趟门,待会回来改完就提交

好耶!蟹蟹!图像合并很棒!azmiao辛苦啦!还有其实那个warning在verify = False情况下,我试了试,只在Linux系统下出现,Windows系统下不会出现warning

@azmiao azmiao closed this as completed in 9815706 Feb 18, 2022
@azmiao
Copy link
Owner

azmiao commented Feb 18, 2022

哦,我发现这个在Post请求时故意不验证ssl的,所以才会爆warning,这个属于必然现象,我好像很久之前就加了关闭显示所以看不到,然后支援头像合并也差不多快弄好了,先出趟门,待会回来改完就提交

好耶!蟹蟹!图像合并很棒!azmiao辛苦啦!还有其实那个warning在verify = False情况下,我试了试,只在Linux系统下出现,Windows系统下不会出现warning

windows太黑啦,出事了也不告诉你hhhh

@homileak
Copy link
Author

哦,我发现这个在Post请求时故意不验证ssl的,所以才会爆warning,这个属于必然现象,我好像很久之前就加了关闭显示所以看不到,然后支援头像合并也差不多快弄好了,先出趟门,待会回来改完就提交

非常感谢您的改进,看CYDXDianXian的反馈,效果应该是很不错
不过更新插件后,我这边反倒是报错了。
看错误内容似乎是字体文件读取有问题,但是我尝试给字体文件权限777,问题还是依旧。
我现在只能先回到旧版。
[2022-02-18 18:32:35,045 nonebot] INFO: Self: 465123789, Message -1943157416 from 145621387@[群:941254623]: '详细查询'
[2022-02-18 18:32:35,046 竞技场推送_tw] INFO: Message -1943157416 triggered wrapper.
pcrclient: /check/check_agreement api called
pcrclient: /check/game_start api called
pcrclient: /load/index api called
pcrclient: /profile/get_profile api called
[2022-02-18 18:32:38,971 竞技场推送_tw] ERROR: <class 'OSError'> occured when wrapper handling message -1943157416.
[2022-02-18 18:32:38,971 竞技场推送_tw] ERROR: cannot open resource
Traceback (most recent call last):
File "/root/HoshinoBot/hoshino/modules/pcrjjc3-tw/create_img.py", line 71, in generate_img
head_f = CreateImg(300, 100, color='white',text=f'最爱的角色:\n\n{c_favorite_name}')
File "/root/HoshinoBot/hoshino/modules/pcrjjc3-tw/create_img.py", line 24, in init
font = ImageFont.truetype(path_to_ttf, size=20)
File "/home/carlos/.cache/pypoetry/virtualenvs/pcrbot-Z439reJW-py3.9/lib/python3.9/site-packages/PIL/ImageFont.py", line 855, in truetype
return freetype(font)
File "/home/carlos/.cache/pypoetry/virtualenvs/pcrbot-Z439reJW-py3.9/lib/python3.9/site-packages/PIL/ImageFont.py", line 852, in freetype
return FreeTypeFont(font, size, index, encoding, layout_engine)
File "/home/carlos/.cache/pypoetry/virtualenvs/pcrbot-Z439reJW-py3.9/lib/python3.9/site-packages/PIL/ImageFont.py", line 211, in init
self.font = core.getfont(
OSError: cannot open resource

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/root/HoshinoBot/hoshino/msghandler.py", line 28, in handle_message
await service_func.func(bot, event)
File "/root/HoshinoBot/hoshino/modules/pcrjjc3-tw/safeservice.py", line 25, in wrapper
return await func(*args, **kwargs)
File "/root/HoshinoBot/hoshino/modules/pcrjjc3-tw/init.py", line 293, in on_query_arena_all
img = await generate_img(img_data)
File "/root/HoshinoBot/hoshino/modules/pcrjjc3-tw/create_img.py", line 74, in generate_img
head_f = CreateImg(300, 100, color='white',text=f'最爱的角色:\n\n(无)')
File "/root/HoshinoBot/hoshino/modules/pcrjjc3-tw/create_img.py", line 24, in init
font = ImageFont.truetype(path_to_ttf, size=20)
File "/home/carlos/.cache/pypoetry/virtualenvs/pcrbot-Z439reJW-py3.9/lib/python3.9/site-packages/PIL/ImageFont.py", line 855, in truetype
return freetype(font)
File "/home/carlos/.cache/pypoetry/virtualenvs/pcrbot-Z439reJW-py3.9/lib/python3.9/site-packages/PIL/ImageFont.py", line 852, in freetype
return FreeTypeFont(font, size, index, encoding, layout_engine)
File "/home/carlos/.cache/pypoetry/virtualenvs/pcrbot-Z439reJW-py3.9/lib/python3.9/site-packages/PIL/ImageFont.py", line 211, in init
self.font = core.getfont(
OSError: cannot open resource
[2022-02-18 18:32:38,974 nonebot] INFO: Message -1943157416 is ignored: Handled by Hoshino

😨

@homileak
Copy link
Author

哦,我发现这个在Post请求时故意不验证ssl的,所以才会爆warning,这个属于必然现象,我好像很久之前就加了关闭显示所以看不到,然后支援头像合并也差不多快弄好了,先出趟门,待会回来改完就提交

非常感谢您的改进,看CYDXDianXian的反馈,效果应该是很不错 不过更新插件后,我这边反倒是报错了。 看错误内容似乎是字体文件读取有问题,但是我尝试给字体文件权限777,问题还是依旧。 我现在只能先回到旧版。 [2022-02-18 18:32:35,045 nonebot] INFO: Self: 465123789, Message -1943157416 from 145621387@[群:941254623]: '详细查询' [2022-02-18 18:32:35,046 竞技场推送_tw] INFO: Message -1943157416 triggered wrapper. pcrclient: /check/check_agreement api called pcrclient: /check/game_start api called pcrclient: /load/index api called pcrclient: /profile/get_profile api called [2022-02-18 18:32:38,971 竞技场推送_tw] ERROR: <class 'OSError'> occured when wrapper handling message -1943157416. [2022-02-18 18:32:38,971 竞技场推送_tw] ERROR: cannot open resource Traceback (most recent call last): File "/root/HoshinoBot/hoshino/modules/pcrjjc3-tw/create_img.py", line 71, in generate_img head_f = CreateImg(300, 100, color='white',text=f'最爱的角色:\n\n{c_favorite_name}') File "/root/HoshinoBot/hoshino/modules/pcrjjc3-tw/create_img.py", line 24, in init font = ImageFont.truetype(path_to_ttf, size=20) File "/home/carlos/.cache/pypoetry/virtualenvs/pcrbot-Z439reJW-py3.9/lib/python3.9/site-packages/PIL/ImageFont.py", line 855, in truetype return freetype(font) File "/home/carlos/.cache/pypoetry/virtualenvs/pcrbot-Z439reJW-py3.9/lib/python3.9/site-packages/PIL/ImageFont.py", line 852, in freetype return FreeTypeFont(font, size, index, encoding, layout_engine) File "/home/carlos/.cache/pypoetry/virtualenvs/pcrbot-Z439reJW-py3.9/lib/python3.9/site-packages/PIL/ImageFont.py", line 211, in init self.font = core.getfont( OSError: cannot open resource

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/root/HoshinoBot/hoshino/msghandler.py", line 28, in handle_message await service_func.func(bot, event) File "/root/HoshinoBot/hoshino/modules/pcrjjc3-tw/safeservice.py", line 25, in wrapper return await func(*args, **kwargs) File "/root/HoshinoBot/hoshino/modules/pcrjjc3-tw/init.py", line 293, in on_query_arena_all img = await generate_img(img_data) File "/root/HoshinoBot/hoshino/modules/pcrjjc3-tw/create_img.py", line 74, in generate_img head_f = CreateImg(300, 100, color='white',text=f'最爱的角色:\n\n(无)') File "/root/HoshinoBot/hoshino/modules/pcrjjc3-tw/create_img.py", line 24, in init font = ImageFont.truetype(path_to_ttf, size=20) File "/home/carlos/.cache/pypoetry/virtualenvs/pcrbot-Z439reJW-py3.9/lib/python3.9/site-packages/PIL/ImageFont.py", line 855, in truetype return freetype(font) File "/home/carlos/.cache/pypoetry/virtualenvs/pcrbot-Z439reJW-py3.9/lib/python3.9/site-packages/PIL/ImageFont.py", line 852, in freetype return FreeTypeFont(font, size, index, encoding, layout_engine) File "/home/carlos/.cache/pypoetry/virtualenvs/pcrbot-Z439reJW-py3.9/lib/python3.9/site-packages/PIL/ImageFont.py", line 211, in init self.font = core.getfont( OSError: cannot open resource [2022-02-18 18:32:38,974 nonebot] INFO: Message -1943157416 is ignored: Handled by Hoshino

😨

想了一下改了权限还读不到会不会是Linux存在字体缓存之类的东西
试着重新生成了字体缓存之后已经解决了
看来Linux和Window的字体调用方式是不一样的。
改版后的插件显示效果很棒,赞一个
2101

@azmiao
Copy link
Owner

azmiao commented Feb 18, 2022

哦,我发现这个在Post请求时故意不验证ssl的,所以才会爆warning,这个属于必然现象,我好像很久之前就加了关闭显示所以看不到,然后支援头像合并也差不多快弄好了,先出趟门,待会回来改完就提交

非常感谢您的改进,看CYDXDianXian的反馈,效果应该是很不错 不过更新插件后,我这边反倒是报错了。 看错误内容似乎是字体文件读取有问题,但是我尝试给字体文件权限777,问题还是依旧。 我现在只能先回到旧版。 [2022-02-18 18:32:35,045 nonebot] INFO: Self: 465123789, Message -1943157416 from 145621387@[群:941254623]: '详细查询' [2022-02-18 18:32:35,046 竞技场推送_tw] INFO: Message -1943157416 triggered wrapper. pcrclient: /check/check_agreement api called pcrclient: /check/game_start api called pcrclient: /load/index api called pcrclient: /profile/get_profile api called [2022-02-18 18:32:38,971 竞技场推送_tw] ERROR: <class 'OSError'> occured when wrapper handling message -1943157416. [2022-02-18 18:32:38,971 竞技场推送_tw] ERROR: cannot open resource Traceback (most recent call last): File "/root/HoshinoBot/hoshino/modules/pcrjjc3-tw/create_img.py", line 71, in generate_img head_f = CreateImg(300, 100, color='white',text=f'最爱的角色:\n\n{c_favorite_name}') File "/root/HoshinoBot/hoshino/modules/pcrjjc3-tw/create_img.py", line 24, in init font = ImageFont.truetype(path_to_ttf, size=20) File "/home/carlos/.cache/pypoetry/virtualenvs/pcrbot-Z439reJW-py3.9/lib/python3.9/site-packages/PIL/ImageFont.py", line 855, in truetype return freetype(font) File "/home/carlos/.cache/pypoetry/virtualenvs/pcrbot-Z439reJW-py3.9/lib/python3.9/site-packages/PIL/ImageFont.py", line 852, in freetype return FreeTypeFont(font, size, index, encoding, layout_engine) File "/home/carlos/.cache/pypoetry/virtualenvs/pcrbot-Z439reJW-py3.9/lib/python3.9/site-packages/PIL/ImageFont.py", line 211, in init self.font = core.getfont( OSError: cannot open resource
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/root/HoshinoBot/hoshino/msghandler.py", line 28, in handle_message await service_func.func(bot, event) File "/root/HoshinoBot/hoshino/modules/pcrjjc3-tw/safeservice.py", line 25, in wrapper return await func(*args, **kwargs) File "/root/HoshinoBot/hoshino/modules/pcrjjc3-tw/init.py", line 293, in on_query_arena_all img = await generate_img(img_data) File "/root/HoshinoBot/hoshino/modules/pcrjjc3-tw/create_img.py", line 74, in generate_img head_f = CreateImg(300, 100, color='white',text=f'最爱的角色:\n\n(无)') File "/root/HoshinoBot/hoshino/modules/pcrjjc3-tw/create_img.py", line 24, in init font = ImageFont.truetype(path_to_ttf, size=20) File "/home/carlos/.cache/pypoetry/virtualenvs/pcrbot-Z439reJW-py3.9/lib/python3.9/site-packages/PIL/ImageFont.py", line 855, in truetype return freetype(font) File "/home/carlos/.cache/pypoetry/virtualenvs/pcrbot-Z439reJW-py3.9/lib/python3.9/site-packages/PIL/ImageFont.py", line 852, in freetype return FreeTypeFont(font, size, index, encoding, layout_engine) File "/home/carlos/.cache/pypoetry/virtualenvs/pcrbot-Z439reJW-py3.9/lib/python3.9/site-packages/PIL/ImageFont.py", line 211, in init self.font = core.getfont( OSError: cannot open resource [2022-02-18 18:32:38,974 nonebot] INFO: Message -1943157416 is ignored: Handled by Hoshino
😨

想了一下改了权限还读不到会不会是Linux存在字体缓存之类的东西 试着重新生成了字体缓存之后已经解决了 看来Linux和Window的字体调用方式是不一样的。 改版后的插件显示效果很棒,赞一个 2101

好耶,正好Linux端的python异常我也不太懂2333,能解决就好。不过目前仍有小问题,比如由于角色名太长了就会超过图片边框,就会被截断了,只能减小字体大小解决了,后续会找一找更好的解决方案

@CYDXDianXian
Copy link
Collaborator

哦,我发现这个在Post请求时故意不验证ssl的,所以才会爆warning,这个属于必然现象,我好像很久之前就加了关闭显示所以看不到,然后支援头像合并也差不多快弄好了,先出趟门,待会回来改完就提交

非常感谢您的改进,看CYDXDianXian的反馈,效果应该是很不错 不过更新插件后,我这边反倒是报错了。 看错误内容似乎是字体文件读取有问题,但是我尝试给字体文件权限777,问题还是依旧。 我现在只能先回到旧版。 [2022-02-18 18:32:35,045 nonebot] INFO: Self: 465123789, Message -1943157416 from 145621387@[群:941254623]: '详细查询' [2022-02-18 18:32:35,046 竞技场推送_tw] INFO: Message -1943157416 triggered wrapper. pcrclient: /check/check_agreement api called pcrclient: /check/game_start api called pcrclient: /load/index api called pcrclient: /profile/get_profile api called [2022-02-18 18:32:38,971 竞技场推送_tw] ERROR: <class 'OSError'> occured when wrapper handling message -1943157416. [2022-02-18 18:32:38,971 竞技场推送_tw] ERROR: cannot open resource Traceback (most recent call last): File "/root/HoshinoBot/hoshino/modules/pcrjjc3-tw/create_img.py", line 71, in generate_img head_f = CreateImg(300, 100, color='white',text=f'最爱的角色:\n\n{c_favorite_name}') File "/root/HoshinoBot/hoshino/modules/pcrjjc3-tw/create_img.py", line 24, in init font = ImageFont.truetype(path_to_ttf, size=20) File "/home/carlos/.cache/pypoetry/virtualenvs/pcrbot-Z439reJW-py3.9/lib/python3.9/site-packages/PIL/ImageFont.py", line 855, in truetype return freetype(font) File "/home/carlos/.cache/pypoetry/virtualenvs/pcrbot-Z439reJW-py3.9/lib/python3.9/site-packages/PIL/ImageFont.py", line 852, in freetype return FreeTypeFont(font, size, index, encoding, layout_engine) File "/home/carlos/.cache/pypoetry/virtualenvs/pcrbot-Z439reJW-py3.9/lib/python3.9/site-packages/PIL/ImageFont.py", line 211, in init self.font = core.getfont( OSError: cannot open resource
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/root/HoshinoBot/hoshino/msghandler.py", line 28, in handle_message await service_func.func(bot, event) File "/root/HoshinoBot/hoshino/modules/pcrjjc3-tw/safeservice.py", line 25, in wrapper return await func(*args, **kwargs) File "/root/HoshinoBot/hoshino/modules/pcrjjc3-tw/init.py", line 293, in on_query_arena_all img = await generate_img(img_data) File "/root/HoshinoBot/hoshino/modules/pcrjjc3-tw/create_img.py", line 74, in generate_img head_f = CreateImg(300, 100, color='white',text=f'最爱的角色:\n\n(无)') File "/root/HoshinoBot/hoshino/modules/pcrjjc3-tw/create_img.py", line 24, in init font = ImageFont.truetype(path_to_ttf, size=20) File "/home/carlos/.cache/pypoetry/virtualenvs/pcrbot-Z439reJW-py3.9/lib/python3.9/site-packages/PIL/ImageFont.py", line 855, in truetype return freetype(font) File "/home/carlos/.cache/pypoetry/virtualenvs/pcrbot-Z439reJW-py3.9/lib/python3.9/site-packages/PIL/ImageFont.py", line 852, in freetype return FreeTypeFont(font, size, index, encoding, layout_engine) File "/home/carlos/.cache/pypoetry/virtualenvs/pcrbot-Z439reJW-py3.9/lib/python3.9/site-packages/PIL/ImageFont.py", line 211, in init self.font = core.getfont( OSError: cannot open resource [2022-02-18 18:32:38,974 nonebot] INFO: Message -1943157416 is ignored: Handled by Hoshino
😨

想了一下改了权限还读不到会不会是Linux存在字体缓存之类的东西 试着重新生成了字体缓存之后已经解决了 看来Linux和Window的字体调用方式是不一样的。 改版后的插件显示效果很棒,赞一个 2101

好耶,正好Linux端的python异常我也不太懂2333,能解决就好。不过目前仍有小问题,比如由于角色名太长了就会超过图片边框,就会被截断了,只能减小字体大小解决了,后续会找一找更好的解决方案

我这边尝试下吧所有信息都贴到一张图里,这样排版还美观

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants