mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-20 22:37:05 +08:00
Correct format name of GroupImage
This commit is contained in:
parent
0897d0cd7e
commit
0a5d3097f7
@ -73,8 +73,9 @@ public class ExternalImage internal constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
@MiraiExperimentalApi
|
@MiraiExperimentalApi
|
||||||
public fun generateImageId(md5: ByteArray): String {
|
@JvmOverloads
|
||||||
return """{${generateUUID(md5)}}.$defaultFormatName"""
|
public fun generateImageId(md5: ByteArray, format: String = defaultFormatName): String {
|
||||||
|
return """{${generateUUID(md5)}}.$format"""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,7 +88,7 @@ public class ExternalImage internal constructor(
|
|||||||
return "ExternalImage(${generateUUID(md5)})"
|
return "ExternalImage(${generateUUID(md5)})"
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun calculateImageResourceId(): String = """{${generateUUID(md5)}}.$formatName"""
|
internal fun calculateImageResourceId(): String = generateImageId(md5, formatName)
|
||||||
|
|
||||||
private fun String.detectFormatName(): String = when {
|
private fun String.detectFormatName(): String = when {
|
||||||
startsWith("FFD8") -> "jpg"
|
startsWith("FFD8") -> "jpg"
|
||||||
|
@ -32,7 +32,10 @@ internal class OnlineGroupImageImpl(
|
|||||||
internal val delegate: ImMsgBody.CustomFace
|
internal val delegate: ImMsgBody.CustomFace
|
||||||
) : @Suppress("DEPRECATION")
|
) : @Suppress("DEPRECATION")
|
||||||
OnlineGroupImage() {
|
OnlineGroupImage() {
|
||||||
override val imageId: String = delegate.filePath.takeIf {
|
override val imageId: String = ExternalImage.generateImageId(
|
||||||
|
delegate.md5,
|
||||||
|
delegate.filePath.substringAfterLast('.')
|
||||||
|
).takeIf {
|
||||||
GROUP_IMAGE_ID_REGEX.matches(it)
|
GROUP_IMAGE_ID_REGEX.matches(it)
|
||||||
} ?: ExternalImage.generateImageId(delegate.md5)
|
} ?: ExternalImage.generateImageId(delegate.md5)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user