mirror of
https://github.com/mamoe/mirai.git
synced 2026-08-19 12:43:32 +08:00
Fix #318
This commit is contained in:
@@ -717,9 +717,16 @@ internal abstract class QQAndroidBotBase constructor(
|
||||
override suspend fun queryImageUrl(image: Image): String = when (image) {
|
||||
is OnlineFriendImageImpl -> image.originUrl
|
||||
is OnlineGroupImageImpl -> image.originUrl
|
||||
is OfflineGroupImage -> "http://gchat.qpic.cn/gchatpic_new/${id}/0-0-${image.imageId.substring(1..36).replace("-", "")}/0?term=2"
|
||||
is OfflineFriendImage -> "http://c2cpicdw.qpic.cn/offpic_new/${id}/${image.imageId}/0?term=2"
|
||||
else -> error("unsupported image class: ${image::class.simpleName}")
|
||||
is OfflineGroupImage -> constructOfflineImageUrl(image)
|
||||
is OfflineFriendImage -> constructOfflineImageUrl(image)
|
||||
else -> error("Internal error: unsupported image class: ${image::class.simpleName}")
|
||||
}
|
||||
|
||||
private fun constructOfflineImageUrl(image: Image): String = when (image) {
|
||||
is GroupImage -> "http://gchat.qpic.cn/gchatpic_new/${id}/0-0-${image.imageId.substring(1..36)
|
||||
.replace("-", "")}/0?term=2"
|
||||
is FriendImage -> "http://c2cpicdw.qpic.cn/offpic_new/${id}/${image.imageId}/0?term=2"
|
||||
else -> error("Internal error: unsupported image class: ${image::class.simpleName}")
|
||||
}
|
||||
|
||||
override fun constructMessageSource(
|
||||
|
||||
@@ -20,7 +20,10 @@ internal class OnlineGroupImageImpl(
|
||||
OnlineGroupImage() {
|
||||
override val imageId: String = ExternalImage.generateImageId(delegate.md5)
|
||||
override val originUrl: String
|
||||
get() = "http://gchat.qpic.cn" + delegate.origUrl
|
||||
get() = if (delegate.origUrl.isBlank()) {
|
||||
"http://gchat.qpic.cn/gchatpic_new/0/0-0-${imageId.substring(1..36)
|
||||
.replace("-", "")}/0?term=2"
|
||||
} else "http://gchat.qpic.cn" + delegate.origUrl
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
return other is OnlineGroupImageImpl && other.imageId == this.imageId
|
||||
@@ -37,7 +40,7 @@ internal class OnlineFriendImageImpl(
|
||||
OnlineFriendImage() {
|
||||
override val imageId: String get() = delegate.resId
|
||||
override val originUrl: String
|
||||
get() = if (delegate.origUrl.isNotEmpty()) {
|
||||
get() = if (delegate.origUrl.isNotBlank()) {
|
||||
"http://c2cpicdw.qpic.cn" + this.delegate.origUrl
|
||||
} else {
|
||||
"http://c2cpicdw.qpic.cn/offpic_new/0/" + delegate.resId + "/0?term=2"
|
||||
|
||||
@@ -92,8 +92,6 @@ expect interface Image : Message, MessageContent {
|
||||
/**
|
||||
* 群图片.
|
||||
*
|
||||
* 群拖
|
||||
*
|
||||
* @property imageId 形如 `{01E9451B-70ED-EAE3-B37C-101F1EEBF5B5}.mirai` (后缀一定为 `".mirai"`)
|
||||
* @see Image 查看更多说明
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user