fix: set field file_type not required

This commit is contained in:
ikechan8370 2024-03-18 13:34:13 +08:00 committed by GitHub
parent 8c33267887
commit 0cf10eabd6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -9,13 +9,14 @@ import moe.fuqiuluo.shamrock.utils.FileUtils
import moe.fuqiuluo.symbols.OneBotHandler import moe.fuqiuluo.symbols.OneBotHandler
import java.util.Base64 import java.util.Base64
@OneBotHandler("get_file") internal object GetFile : IActionHandler() { @OneBotHandler("get_file")
internal object GetFile : IActionHandler() {
override suspend fun internalHandle(session: ActionSession): String { override suspend fun internalHandle(session: ActionSession): String {
val file = session.getString("file") val file = session.getString("file")
.replace(regex = "[{}\\-]".toRegex(), replacement = "") .replace(regex = "[{}\\-]".toRegex(), replacement = "")
.replace(" ", "") .replace(" ", "")
.split(".")[0].lowercase() .split(".")[0].lowercase()
val fileType = session.getString("file_type") val fileType = session.getStringOrNull("file_type") ?: "base64"
return invoke(file, fileType, session.echo) return invoke(file, fileType, session.echo)
} }
@ -40,5 +41,5 @@ import java.util.Base64
} }
} }
override val requiredParams: Array<String> = arrayOf("file", "file_type") override val requiredParams: Array<String> = arrayOf("file")
} }