Him188 5 rokov pred
rodič
commit
f7533e3cd6

+ 10 - 3
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.common.kt

@@ -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(

+ 5 - 2
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/message/imagesImpl.kt

@@ -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"

+ 0 - 2
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/Image.kt

@@ -92,8 +92,6 @@ expect interface Image : Message, MessageContent {
 /**
  * 群图片.
  *
- * 群拖
- *
  * @property imageId 形如 `{01E9451B-70ED-EAE3-B37C-101F1EEBF5B5}.mirai` (后缀一定为 `".mirai"`)
  * @see Image 查看更多说明
  */