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

群成员头像为gif时获取的头像链接是错误的 #1557

Closed
4o4E opened this issue Sep 16, 2021 · 6 comments · Fixed by #1721
Closed

群成员头像为gif时获取的头像链接是错误的 #1557

4o4E opened this issue Sep 16, 2021 · 6 comments · Fixed by #1721
Labels
N 优先级: 一般 s:core 子系统: mirai-core t:problem 类型: 不容易归类为特性或 bug 的综合问题 x:question 标签: 需要更多信息
Milestone

Comments

@4o4E
Copy link

4o4E commented Sep 16, 2021

当头像为gif格式时User.getAvatarUrl()会返回错误的头像链接,显示为
image

复现

  1. 将头像换为gif格式
  2. 让bot获取头像链接

版本及相关选项选择

  • mirai-core: 2.7.1-dev-1
  • bot-protocol: ANDROID_PAD

补充信息

@4o4E 4o4E added the x:question 标签: 需要更多信息 label Sep 16, 2021
@Him188 Him188 added N 优先级: 一般 t:problem 类型: 不容易归类为特性或 bug 的综合问题 labels Sep 18, 2021
@Him188 Him188 added this to the Backlog milestone Sep 18, 2021
@Kazusa1412
Copy link

http://q1.qlogo.cn/g?b=qq&nk=uin&s=640 这个地址拿不到 gif 图
http://q.qlogo.cn/g?b=qq&k=???&s=640 这里能正确的拿到 gif,不过这个参数 k 不知道怎么算。 但是可以通过其他 api 比如 https://ptlogin2.qq.com/getface?imgtype=1&uin=uin 拿到 k
除非知道 k 怎么算,不然获取头像链接需要先进行一次网络请求,可以加个 suspend 函数(kt 怎么还不支持 suspend 属性), 或者在 ContactOrBot 初始化的时候拿

@4o4E
Copy link
Author

4o4E commented Sep 29, 2021

http://q1.qlogo.cn/g?b=qq&nk=uin&s=640 这个地址拿不到 gif 图 http://q.qlogo.cn/g?b=qq&k=???&s=640 这里能正确的拿到 gif,不过这个参数 k 不知道怎么算。 但是可以通过其他 api 比如 https://ptlogin2.qq.com/getface?imgtype=1&uin=uin 拿到 k 除非知道 k 怎么算,不然获取头像链接需要先进行一次网络请求,可以加个 suspend 函数(kt 怎么还不支持 suspend 属性), 或者在 ContactOrBot 初始化的时候拿

这个方法拿到的图片并不是gif,只是个预览图

@Kazusa1412
Copy link

这个方法拿到的图片并不是gif,只是个预览图

还是能拿到的,不过这个 s 的值有点迷,不同的值结果都不一样,我这样有个例子

http://q1.qlogo.cn/g?b=qq&k=JulcCUMH2XMwb8JFvtcBEg&s=0 默认企鹅
http://q1.qlogo.cn/g?b=qq&k=JulcCUMH2XMwb8JFvtcBEg&s=1 预览图
http://q1.qlogo.cn/g?b=qq&k=JulcCUMH2XMwb8JFvtcBEg&s=4 gif
http://q1.qlogo.cn/g?b=qq&k=JulcCUMH2XMwb8JFvtcBEg&s=14 请求错误 400
http://q1.qlogo.cn/g?b=qq&k=JulcCUMH2XMwb8JFvtcBEg&s=40 预览图
http://q1.qlogo.cn/g?b=qq&k=JulcCUMH2XMwb8JFvtcBEg&s=140 gif

@4o4E
Copy link
Author

4o4E commented Sep 29, 2021

@Kazusa1412
Copy link

ok了,感谢

我发现原来的s用140也能拿到了

http://q1.qlogo.cn/g?b=qq&nk=uin&s=140

@cssxsh
Copy link
Contributor

cssxsh commented Dec 9, 2021

q.qlogo.cn
q1.qlogo.cn
q2.qlogo.cn
这些域名应该是等价的
除了 q.qlogo.cn/g 接口
还有接口 q.qlogo.cn/headimg_dl

https://q.qlogo.cn/headimg_dl?dst_uin=${qq}&spec=${level}
spec 是图片规格(大小)等级 0, 40, 41, 100, 140, 640, 0是原图
gif 在等级比较高的情况下可能会失效,需要尝试较低的等级
spec=640
spec_5
spec=140
spec_4
spec=100
spec_3
spec=41
spec_2
spec=40
spec_1
很奇怪的是原图也会失效,但目前没有对更多的gif头像做测试
spec=0
spec_0

with https://blog.csdn.net/COCO56/article/details/101563707

cssxsh added a commit to SkyNet1748/mirai that referenced this issue Dec 9, 2021
@Him188 Him188 linked a pull request Dec 10, 2021 that will close this issue
@Him188 Him188 added the s:core 子系统: mirai-core label Jan 4, 2022
Him188 pushed a commit that referenced this issue Apr 24, 2022
* Add getAvatarUrl(spec: Int) fix (#1557)

* Add api dump

* Add AvatarSpec

* Add api dump

* fix: docs

* rename: getAvatarUrl
@Him188 Him188 modified the milestones: Backlog, 2.11.0-RC Apr 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
N 优先级: 一般 s:core 子系统: mirai-core t:problem 类型: 不容易归类为特性或 bug 的综合问题 x:question 标签: 需要更多信息
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants