Shamrock: fix #252

Signed-off-by: 白池 <whitechi73@outlook.com>
This commit is contained in:
白池 2024-02-25 03:38:09 +08:00
parent 720313124c
commit 6b1147d065
3 changed files with 38 additions and 6 deletions

View File

@ -1,6 +1,8 @@
package moe.fuqiuluo.qqinterface.servlet.transfile package moe.fuqiuluo.qqinterface.servlet.transfile
import kotlinx.atomicfu.atomic import kotlinx.atomicfu.atomic
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlinx.serialization.protobuf.ProtoNumber import kotlinx.serialization.protobuf.ProtoNumber
import moe.fuqiuluo.qqinterface.servlet.BaseSvc import moe.fuqiuluo.qqinterface.servlet.BaseSvc
import moe.fuqiuluo.qqinterface.servlet.TicketSvc import moe.fuqiuluo.qqinterface.servlet.TicketSvc
@ -214,11 +216,12 @@ internal object NtV2RichMediaSvc: BaseSvc() {
} }
} }
@Serializable
data class TryUpPicData( data class TryUpPicData(
val uKey: ByteArray, @SerialName("ukey") val uKey: ByteArray,
val exist: Boolean, @SerialName("exist") val exist: Boolean,
val fileId: ULong, @SerialName("file_id") val fileId: ULong,
var upIp: ArrayList<Long>? = null, @SerialName("up_ip") var upIp: ArrayList<Long>? = null,
var upPort: ArrayList<Int>? = null, @SerialName("up_port") var upPort: ArrayList<Int>? = null,
) )
} }

View File

@ -104,7 +104,7 @@ internal object RichProtoSvc: BaseSvc() {
val domain = if (!result.download_file_rsp.str_download_dns.has()) val domain = if (!result.download_file_rsp.str_download_dns.has())
("https://" + result.download_file_rsp.str_download_ip.get()) ("https://" + result.download_file_rsp.str_download_ip.get())
else ("http://" + result.download_file_rsp.str_download_dns.get()) else ("http://" + result.download_file_rsp.str_download_dns.get().toByteArray().decodeToString())
val downloadUrl = result.download_file_rsp.bytes_download_url.get().toByteArray().toHexString() val downloadUrl = result.download_file_rsp.bytes_download_url.get().toByteArray().toHexString()
val appId = MobileQQ.getMobileQQ().appId val appId = MobileQQ.getMobileQQ().appId
val version = PlatformUtils.getQQVersion(MobileQQ.getContext()) val version = PlatformUtils.getQQVersion(MobileQQ.getContext())

View File

@ -0,0 +1,29 @@
package moe.fuqiuluo.shamrock.remote.action.handlers
import moe.fuqiuluo.qqinterface.servlet.transfile.NtV2RichMediaSvc
import moe.fuqiuluo.shamrock.remote.action.ActionSession
import moe.fuqiuluo.shamrock.remote.action.IActionHandler
import moe.fuqiuluo.symbols.OneBotHandler
@OneBotHandler("request_upload_group_image")
internal object RequestUploadGroupImage: IActionHandler() {
override suspend fun internalHandle(session: ActionSession): String {
val md5 = session.getString("md5").uppercase()
val fileSize = session.getLong("file_size")
val width = session.getInt("width")
val height = session.getInt("height")
val groupId = session.getString("group_id")
NtV2RichMediaSvc.requestUploadGroupPic(
groupId.toULong(),
md5,
fileSize.toULong(),
width.toUInt(),
height.toUInt()
).onSuccess {
return ok(it, session.echo)
}.onFailure {
return error(it.message ?: it.toString(), session.echo)
}
return logic("request_upload_group_image failed", session.echo)
}
}