From ea206faf4fbf2fcd0135223aa13d9867de5ea9be Mon Sep 17 00:00:00 2001 From: tuuz Date: Mon, 18 Mar 2024 04:07:11 +0800 Subject: [PATCH] =?UTF-8?q?get=5Frecord=E7=9A=84ws=E5=8A=A0=E5=85=A5?= =?UTF-8?q?=E5=8D=95=E7=8B=AC=E7=9A=84md5=E5=AD=97=E6=AE=B5=EF=BC=8C?= =?UTF-8?q?=E6=96=B9=E4=BE=BF=E5=90=8E=E7=BB=ADget=5Ffile=E6=8B=BF?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../shamrock/remote/action/handlers/GetRecord.kt | 13 ++++++------- .../shamrock/remote/service/data/ResourceData.kt | 5 ++++- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/xposed/src/main/java/moe/fuqiuluo/shamrock/remote/action/handlers/GetRecord.kt b/xposed/src/main/java/moe/fuqiuluo/shamrock/remote/action/handlers/GetRecord.kt index e5bb42e..47ace91 100644 --- a/xposed/src/main/java/moe/fuqiuluo/shamrock/remote/action/handlers/GetRecord.kt +++ b/xposed/src/main/java/moe/fuqiuluo/shamrock/remote/action/handlers/GetRecord.kt @@ -9,8 +9,7 @@ import moe.fuqiuluo.shamrock.tools.EmptyJsonString import moe.fuqiuluo.shamrock.utils.AudioUtils import moe.fuqiuluo.symbols.OneBotHandler -@OneBotHandler("get_record") -internal object GetRecord: IActionHandler() { +@OneBotHandler("get_record") internal object GetRecord : IActionHandler() { override suspend fun internalHandle(session: ActionSession): String { val file = session.getString("file") .replace(regex = "[{}\\-]".toRegex(), replacement = "") @@ -22,17 +21,17 @@ internal object GetRecord: IActionHandler() { operator fun invoke(file: String, format: String, echo: JsonElement = EmptyJsonString): String { val pttFile = LocalCacheHelper.getCachePttFile(file) - return if(pttFile.exists()) { + return if (pttFile.exists()) { val isSilk = AudioUtils.isSilk(pttFile) - val audioFile = when(format) { + val audioFile = when (format) { "amr" -> AudioUtils.audioToAmr(pttFile, isSilk) else -> AudioUtils.audioToFormat(pttFile, isSilk, format) } ok( OutResource( - audioFile.toString(), - url = "/res/${audioFile.nameWithoutExtension}" - ), echo) + audioFile.toString(), url = "/res/${audioFile.nameWithoutExtension}", md5 = audioFile.nameWithoutExtension + ), echo + ) } else { error("not found record file from cache", echo) } diff --git a/xposed/src/main/java/moe/fuqiuluo/shamrock/remote/service/data/ResourceData.kt b/xposed/src/main/java/moe/fuqiuluo/shamrock/remote/service/data/ResourceData.kt index 861d073..a060712 100644 --- a/xposed/src/main/java/moe/fuqiuluo/shamrock/remote/service/data/ResourceData.kt +++ b/xposed/src/main/java/moe/fuqiuluo/shamrock/remote/service/data/ResourceData.kt @@ -4,10 +4,13 @@ import kotlinx.serialization.Serializable import java.util.Base64 @Serializable internal data class OutResource( - val file: String, val url: String + val file: String, + val url: String, + val md5: String, ) @Serializable internal data class OutResourceByBase64( val file: String, val base64String: String, + val md5: String, ) \ No newline at end of file