-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d6ced13
commit 4d65bf0
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
...ot-component-onebot-v11/simbot-component-onebot-v11-core/src/jvmTest/kotlin/GetFileApi.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<GetFileResult> { | ||
|
||
override val action: String | ||
get() = ACTION | ||
|
||
override val resultDeserializer: DeserializationStrategy<GetFileResult> | ||
get() = GetFileResult.serializer() | ||
|
||
override val apiResultDeserializer: DeserializationStrategy<OneBotApiResult<GetFileResult>> | ||
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 = "", | ||
) |