Skip to content

Commit

Permalink
NapCat use size but not file_size
Browse files Browse the repository at this point in the history
  • Loading branch information
MrXiaoM committed Jan 13, 2025
1 parent c521744 commit 8a61fcc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions onebot/src/main/kotlin/sdk/util/JsonHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ fun JsonObject.longFromString(key: String): Long {
fun JsonObject.long(key: String): Long {
return this[key]?.asLong ?: throw JsonParseException("Can`t find `$key`")
}
fun JsonObject.long(vararg keys: String): Long {
for (key in keys) {
val value = this[key]?.asLong
if (value != null) return value
}
throw JsonParseException("Can't find any of `${keys.joinToString(separator = "`, `")}`")
}
fun JsonObject.ignorable(key: String, def: Float): Float {
return nullableFloat(key, def.nullable) ?: def
}
Expand Down
2 changes: 1 addition & 1 deletion onebot/src/main/kotlin/sdk/util/json/GroupFilesAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class GroupFilesAdapter {
fileId = obj.string("file_id")
fileName = obj.string("file_name")
busid = obj.int("busid")
fileSize = obj.long("file_size")
fileSize = obj.long("file_size", "size") // NapCat: size
uploadTime = obj.long("upload_time")
deadTime = obj.long("dead_time")
modifyTime = obj.long("modify_time")
Expand Down

0 comments on commit 8a61fcc

Please sign in to comment.