Fix cross images downloading url; fix #1600

This commit is contained in:
Karlatemp 2021-10-16 16:52:06 +08:00
parent 07d5a6ca7d
commit ace32caa28
No known key found for this signature in database
GPG Key ID: 21FBDDF664FF06F8

View File

@ -58,10 +58,7 @@ internal class OnlineGroupImageImpl(
override val originUrl: String
get() = if (delegate.origUrl.isBlank()) {
"http://gchat.qpic.cn/gchatpic_new/0/0-0-${
imageId.substring(1..36)
.replace("-", "")
}/0?term=2"
gchatImageUrlByImageId(imageId)
} else "http://gchat.qpic.cn" + delegate.origUrl
override val isEmoji: Boolean by lazy {
@ -78,6 +75,13 @@ private fun <T : ImgExtPbResvAttrCommon> ByteArray.pbImageResv_checkIsEmoji(seri
}.getOrNull() ?: false
}
private fun gchatImageUrlByImageId(imageId: String) =
"http://gchat.qpic.cn/gchatpic_new/0/0-0-${
imageId.substring(1..36)
.replace("-", "")
}/0?term=2"
private val imageLogger: MiraiLogger by lazy { MiraiLogger.Factory.create(Image::class) }
internal val Image.Key.logger get() = imageLogger
@ -117,6 +121,9 @@ OnlineFriendImage() {
override val originUrl: String
get() = if (delegate.origUrl.isNotBlank()) {
"http://c2cpicdw.qpic.cn" + this.delegate.origUrl
} else if (delegate.resId.isNotEmpty() && delegate.resId[0] == '{') {
// https://github.com/mamoe/mirai/issues/1600
gchatImageUrlByImageId(imageId)
} else {
"http://c2cpicdw.qpic.cn/offpic_new/0/" + delegate.resId + "/0?term=2"
}