Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Napcat端由于图片缓存格式不同导致无法正常设置问题 #15

Closed
ragnarok6324 opened this issue Aug 25, 2024 · 17 comments
Closed
Labels
wontfix This will not be worked on

Comments

@ragnarok6324
Copy link

设置带图片的回复后,bot并不回复该问题。
1

hoshino后台日志
image

Napcat后台日志
2024-08-25 23:34:58 [ [32mINFO [39m] 芬里尔(438980368) | 群[尔威希、739039361、木华 陽、芬里尔(463922023)] 739039361(739039361): 开始测试
2024-08-25 23:35:02 [ [32mINFO [39m] 芬里尔(438980368) | 群[尔威希、739039361、木华 陽、芬里尔(463922023)] 739039361(739039361): 全群问这是一个
问题你答
[图片|https://gchat.qpic.cn/gchatpic_new/739039361/3953922023-2935700190-2A775A7BC55EABDA3BD8D99697B3A993/0?term=255&is_o
rigin=0]
2024-08-25 23:35:03 [ [91mERROR [39m] 芬里尔(438980368) | 发生错误 Error: file not found
at GetImage._handle (file:///C:/Users/Administrator/Desktop/%E8%BF%99%E4%B8%AA%E6%98%AF%E4%BD%A0%E7%9A%84%E6%9C%BA%E
5%99%A8%E4%BA%BA%E7%99%BB%E9%99%86/NapCat-new/NapCat.win32.x64/napcat.mjs:24445:11)
at async GetImage.websocketHandle (file:///C:/Users/Administrator/Desktop/%E8%BF%99%E4%B8%AA%E6%98%AF%E4%BD%A0%E7%9A
%84%E6%9C%BA%E5%99%A8%E4%BA%BA%E7%99%BB%E9%99%86/NapCat-new/NapCat.win32.x64/napcat.mjs:21764:23)
at async ReverseWebsocket.onmessage (file:///C:/Users/Administrator/Desktop/%E8%BF%99%E4%B8%AA%E6%98%AF%E4%BD%A0%E7%
9A%84%E6%9C%BA%E5%99%A8%E4%BA%BA%E7%99%BB%E9%99%86/NapCat-new/NapCat.win32.x64/napcat.mjs:27137:28)
at async WebSocket. (file:///C:/Users/Administrator/Desktop/%E8%BF%99%E4%B8%AA%E6%98%AF%E4%BD%A0%E7%9A%84
%E6%9C%BA%E5%99%A8%E4%BA%BA%E7%99%BB%E9%99%86/NapCat-new/NapCat.win32.x64/napcat.mjs:27177:7)
2024-08-25 23:35:03 [ [32mINFO [39m] 芬里尔(438980368) | 发送消息 给群聊 群[尔威希、739039361、木华 陽、芬里尔(463922023)] : 好的我记住了
2024-08-25 23:35:11 [ [32mINFO [39m] 芬里尔(438980368) | 群[尔威希、739039361、木华 陽、芬里尔(463922023)] 739039361(739039361): 这是一个问题

2024-08-25 23:35:11 [ [91mERROR [39m] 芬里尔(438980368) | 发生错误 Error: file not found
at GetImage._handle (file:///C:/Users/Administrator/Desktop/%E8%BF%99%E4%B8%AA%E6%98%AF%E4%BD%A0%E7%9A%84%E6%9C%BA%E
5%99%A8%E4%BA%BA%E7%99%BB%E9%99%86/NapCat-new/NapCat.win32.x64/napcat.mjs:24445:11)
at async GetImage.websocketHandle (file:///C:/Users/Administrator/Desktop/%E8%BF%99%E4%B8%AA%E6%98%AF%E4%BD%A0%E7%9A
%84%E6%9C%BA%E5%99%A8%E4%BA%BA%E7%99%BB%E9%99%86/NapCat-new/NapCat.win32.x64/napcat.mjs:21764:23)
at async ReverseWebsocket.onmessage (file:///C:/Users/Administrator/Desktop/%E8%BF%99%E4%B8%AA%E6%98%AF%E4%BD%A0%E7%
9A%84%E6%9C%BA%E5%99%A8%E4%BA%BA%E7%99%BB%E9%99%86/NapCat-new/NapCat.win32.x64/napcat.mjs:27137:28)
at async WebSocket. (file:///C:/Users/Administrator/Desktop/%E8%BF%99%E4%B8%AA%E6%98%AF%E4%BD%A0%E7%9A%84
%E6%9C%BA%E5%99%A8%E4%BA%BA%E7%99%BB%E9%99%86/NapCat-new/NapCat.win32.x64/napcat.mjs:27177:7)
2024-08-25 23:35:11 [ [91mERROR [39m] 芬里尔(438980368) | 发生错误 Error: ENOENT: no such file or directory, open 'C:\Users\Adm
inistrator\Desktop\Resources\img\xqa\img{2A775A7B-C55E-ABDA-3BD8-D99697B3A993}.png'

@azmiao
Copy link
Owner

azmiao commented Aug 26, 2024

麻烦尝试一下将util.py中122行开始的doing_img函数替换为如下:

async def doing_img(bot, img: str, is_ans: bool = False, save: bool = False) -> str:
    img_path = os.path.join(FILE_PATH, 'img/')
    if save:
        logger.info('开始调用get_image接口获取图片信息')
        img_url = await bot.get_image(file=img)
        logger.info('图片信息接口返回:' + str(img_url))
        file = os.path.join(img_path, img)
        if not os.path.isfile(img_path + img):
            urllib.request.urlretrieve(url=img_url['url'], filename=file)
            logger.critical(f'XQA: 已下载图片{img}')
    if is_ans:  # 保证保存图片的完整性,方便迁移和后续做操作
        return 'file:///' + os.path.abspath(img_path + img)
    return img

之后再发送一次设置问题,然后截图一下hoshino的日志我看看napcat的接口返回的啥,只需要hoshino的日志就行

@ragnarok6324
Copy link
Author

image
image

@azmiao
Copy link
Owner

azmiao commented Aug 26, 2024

看起来napcat接口请求出错了,但我看他们的文档是支持的
image

你看看你那边是否需要更新一下napcat?

@ragnarok6324
Copy link
Author

image
已安装Napcat的最新版本v2.2.12,似乎还是不行

@azmiao
Copy link
Owner

azmiao commented Aug 26, 2024

那我这没法解决了欸,你可以尝试携带napcat的日志去那边问问get_image这个接口现在正常不

@azmiao
Copy link
Owner

azmiao commented Aug 27, 2024

看napcat的get_file接口炸了,可以去问问get_image接口是不是也炸了
image

@azmiao
Copy link
Owner

azmiao commented Aug 27, 2024

mark一手便于后续跟进
napcat issue 313

@azmiao azmiao added the wontfix This will not be worked on label Aug 29, 2024
@azmiao
Copy link
Owner

azmiao commented Sep 1, 2024

你在utils.py中搜索下这行:

raw_body = raw_body if '.' in raw_body else raw_body + '.image'

然后直接吧这行删掉再试试

@ragnarok6324
Copy link
Author

你在utils.py中搜索下这行:

raw_body = raw_body if '.' in raw_body else raw_body + '.image'

然后直接吧这行删掉再试试

1
2

@azmiao
Copy link
Owner

azmiao commented Sep 1, 2024

我去,他这接口返回的URL怎么变成路径了。。。。

@ragnarok6324
Copy link
Author

1
2
这是2.2.36下,我把您告诉我删掉的那行恢复后运行的日志,需不需要删掉后再发送日志给你看看呢

@azmiao
Copy link
Owner

azmiao commented Sep 1, 2024

1 2 这是2.2.36下,我把您告诉我删掉的那行恢复后运行的日志,需不需要删掉后再发送日志给你看看呢

需要删掉的,你用napcat之后应该都需要删掉那行

@ragnarok6324
Copy link
Author

1
2
3
4
删掉后运行的日志

@azmiao
Copy link
Owner

azmiao commented Sep 2, 2024

看来是文件名不合法,我看看咋改

@azmiao
Copy link
Owner

azmiao commented Sep 2, 2024

更新下试试?

@ragnarok6324
Copy link
Author

感谢!已能成功下载图片并回复问题
image
1

@azmiao
Copy link
Owner

azmiao commented Sep 2, 2024

ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants