mirror of
https://github.com/whitechi73/OpenShamrock.git
synced 2024-08-14 05:12:17 +00:00
Compare commits
2 Commits
f030104ff2
...
0cf10eabd6
Author | SHA1 | Date | |
---|---|---|---|
0cf10eabd6 | |||
8c33267887 |
@ -9,13 +9,14 @@ import moe.fuqiuluo.shamrock.utils.FileUtils
|
||||
import moe.fuqiuluo.symbols.OneBotHandler
|
||||
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 {
|
||||
val file = session.getString("file")
|
||||
.replace(regex = "[{}\\-]".toRegex(), replacement = "")
|
||||
.replace(" ", "")
|
||||
.split(".")[0].lowercase()
|
||||
val fileType = session.getString("file_type")
|
||||
val fileType = session.getStringOrNull("file_type") ?: "base64"
|
||||
return invoke(file, fileType, session.echo)
|
||||
}
|
||||
|
||||
@ -23,7 +24,7 @@ import java.util.Base64
|
||||
val targetFile = FileUtils.getFileByMd5(file)
|
||||
return if (targetFile.exists()) {
|
||||
when (fileType) {
|
||||
"base64" -> ok(
|
||||
"base64", "" -> ok(
|
||||
OutResourceByBase64(
|
||||
"/res/${targetFile.nameWithoutExtension}",
|
||||
Base64.getEncoder()
|
||||
@ -40,5 +41,5 @@ import java.util.Base64
|
||||
}
|
||||
}
|
||||
|
||||
override val requiredParams: Array<String> = arrayOf("file", "file_type")
|
||||
}
|
||||
override val requiredParams: Array<String> = arrayOf("file")
|
||||
}
|
||||
|
Reference in New Issue
Block a user