diff --git a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/jvmTest/kotlin/GetFileApi.kt b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/jvmTest/kotlin/GetFileApi.kt new file mode 100644 index 0000000..9fa5435 --- /dev/null +++ b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/jvmTest/kotlin/GetFileApi.kt @@ -0,0 +1,50 @@ +import kotlinx.serialization.DeserializationStrategy +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable +import love.forte.simbot.component.onebot.v11.core.api.OneBotApi +import love.forte.simbot.component.onebot.v11.core.api.OneBotApiResult + +// LLOneBot GetFile API + +class GetFileApi private constructor( + override val body: Any +) : OneBotApi { + + override val action: String + get() = ACTION + + override val resultDeserializer: DeserializationStrategy + get() = GetFileResult.serializer() + + override val apiResultDeserializer: DeserializationStrategy> + get() = RESULT_RES + + companion object { + private const val ACTION: String = "get_file" + private val RESULT_RES = OneBotApiResult.serializer(GetFileResult.serializer()) + + @JvmStatic + fun create(fileId: String): GetFileApi { + return GetFileApi(Body(fileId)) + } + } + + @Serializable + internal data class Body( + @SerialName("file_id") + internal val fileId: String, + ) +} + +@Serializable +data class GetFileResult( + /** + * 文件的绝对路径 + */ + val file: String, + @SerialName("file_name") + val fileName: String = "", + @SerialName("file_size") + val fileSize: Long = -1L, + val base64: String = "", +)