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

Debian 10 + go-cqhttp 图片处理异常 #12

Closed
NekoAria opened this issue Aug 24, 2020 · 9 comments
Closed

Debian 10 + go-cqhttp 图片处理异常 #12

NekoAria opened this issue Aug 24, 2020 · 9 comments

Comments

@NekoAria
Copy link
Collaborator

NekoAria commented Aug 24, 2020

if config.IsLinux:
rss_str = re.sub(re.escape(str(img)),
r'[CQ:image,file=' + str(img_path) + ']',
rss_str)
else:
rss_str = re.sub(re.escape(str(img)), r'[CQ:image,file=file:///' + str(img_path) + ']', rss_str)

这段代码只保留最后一行,就能正常发送图片了。
CQ码发送本地图片都是需要File URI的,这点应该是平台无关。
我看过之前关闭了的一个issue,不知道@OmaruPolka 在那之后是否也遇到我这个情况。

@Quan666
Copy link
Owner

Quan666 commented Aug 24, 2020

能否将完整的报错日志发上来

@NekoAria
Copy link
Collaborator Author

NekoAria commented Aug 24, 2020

ELF_RSS的日志:

[2020-08-24 16:19:41,929 nonebot] INFO: 检查 yande.re_1d 更新
49
50

[CQ:image,file=/root/ELF_RSS/data/imgs/b1878291-e336-48b3-a6c0-775eb3c70d06.jpg]Rating:q Score:42

go-cqhttp的日志:

[2020-08-24 16:19:44] [DEBUG]: WS接收到API调用: send_msg 参数: {"message_type": "private", "user_id": "*", "message": "\u3010Last 24 hours - yande.re\u3011\u66f4\u65b0\u4e86!\n----------------------\n\u5185\u5bb9\uff1a[CQ:image,file=/root/ELF_RSS/data/imgs/b1878291-e336-48b3-a6c0-775eb3c70d06.jpg]Rating:q Score:42\n\u539f\u94fe\u63a5\uff1ahttps://yande.re/post/show/673805\n\u65e5\u671f\uff1a08\u670820\u65e5 05:12:48"}
[2020-08-24 16:19:44] [WARNING]: 转换CQ码到MiraiGo Element时出现错误: invalid image 将原样发送.

@Quan666
Copy link
Owner

Quan666 commented Aug 25, 2020

Mrs4s/go-cqhttp#169 可能是这个问题
今晚我针对性修复下

@NekoAria
Copy link
Collaborator Author

我觉得更像是转义处理这出的问题。

我找了之前把isLinux设为false后的日志:

ELF_RSS的日志:

[2020-08-24 12:17:53,835 nonebot] INFO: 检查 yande.re_1d 更新
45
48

[CQ:image,file=file:///\root\ELF_RSS\data\imgs\b7fb997b-f760-42fc-ba42-4f80cc1a613c.jpg]Rating:e Score:40

go-cqhttp的日志:

[2020-08-24 12:17:56] [DEBUG]: WS接收到API调用: send_msg 参数: {"message_type": "private", "user_id": "*", "message": "\u3010Last 24 hours - yande.re\u3011\u66f4\u65b0\u4e86!\n----------------------\n\u5185\u5bb9\uff1a[CQ:image,file=file:///\root\ELF_RSS\data\imgs\b7fb997b-f760-42fc-ba42-4f80cc1a613c.jpg]Rating:e Score:40\n\u539f\u94fe\u63a5\uff1ahttps://yande.re/post/show/675373\n\u65e5\u671f\uff1a08\u670823\u65e5 23:13:12"}
[2020-08-24 12:17:56] [WARNING]: 转换CQ码到MiraiGo Element时出现错误: open /\root\ELF_RSS\data\imgs\b7fb997b-f760-42fc-ba42-4f80cc1a613c.jpg: no such file or directory 将原样发送.

@NekoAria
Copy link
Collaborator Author

NekoAria commented Aug 25, 2020

PS:

OneBot 标准中消息段类型部分有提到:

发送时,file 参数除了支持使用收到的图片文件名直接发送外,还支持:
绝对路径,例如 file:///C:\\Users\Richard\Pictures\1.png,格式使用 file URI
网络 URL,例如 http://i1.piimg.com/567571/fdd6e7b6d93f1ef0.jpg
Base64 编码,例如 base64://iVBORw0KGgoAAAANSUhEUgAAABQAAAAVCAIAAADJt1n/AAAAKElEQVQ4EWPk5+RmIBcwkasRpG9UM4mhNxpgowFGMARGEwnBIEJVAAAdBgBNAZf+QAAAAABJRU5ErkJggg==

go-cqhttp是按照这个标准走的,而cqhttp-mirai似乎也是。
我认为这个问题的解决方法就是按照我最开始说的那样,最起码我用的go-cqhttp是正常了,cqhttp-mirai则需要测试验证。

Quan666 added a commit that referenced this issue Aug 25, 2020
@Quan666
Copy link
Owner

Quan666 commented Aug 25, 2020

试试最新版本 aefcd13

@NekoAria
Copy link
Collaborator Author

试过了,同样报错。

go-cqhttp的日志:

[2020-08-26 16:25:00] [DEBUG]: WS接收到API调用: send_msg 参数: {"message_type":"private","user_id":"*","message":"\u3010Last week - yande.re\u3011\u66f4\u65b0\u4e86!\n----------------------\n\u5185\u5bb9\uff1a[CQ:image,file=/root/ELF_RSS/data/imgs/bcff7cbe489f4da28de4f4a40176bcd2.jpg]Rating:q Score:85\n\u539f\u94fe\u63a5\uff1ahttps://yande.re/post/show/673799\n\u65e5\u671f\uff1a08\u670820\u65e5 05:12:24"}
[2020-08-26 16:25:00] [WARNING]: 转换CQ码 [CQ:image,file=/root/ELF_RSS/data/imgs/bcff7cbe489f4da28de4f4a40176bcd2.jpg] 到MiraiGo Element时出现错误: invalid image 将原样发送.

为什么不采纳我一开始的提议呢?至少问题在我这是解决了。而且file URI是不可或缺的。

@NekoAria
Copy link
Collaborator Author

if config.IsLinux:
rss_str = re.sub(re.escape(str(img)),
r'[CQ:image,file=' + str(img_path) + ']',
rss_str)

另外我注意到处理视频的部分,代码看起来是直接copy了处理图片那段,完全一致。

Quan666 added a commit that referenced this issue Aug 26, 2020
@Quan666
Copy link
Owner

Quan666 commented Aug 26, 2020

看来是我考虑过多了

@Quan666 Quan666 closed this as completed Aug 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants