Image uploading

This commit is contained in:
Him188 2019-10-20 21:37:34 +08:00
parent 28b47f9603
commit bc57001e36
4 changed files with 11 additions and 11 deletions

View File

@ -182,6 +182,11 @@ internal class TIMBotNetworkHandler internal constructor(private val bot: Bot) :
}
packet.use {
val name = packet::class.simpleName
if (name != null && !name.endsWith("Encrypted") && !name.endsWith("Raw")) {
bot.logCyan("Packet received: $packet")
}
//coz removeIf is not inline
handlersLock.withLock {
temporaryPacketHandlers.removeIfInlined {
@ -189,11 +194,6 @@ internal class TIMBotNetworkHandler internal constructor(private val bot: Bot) :
}
}
val name = packet::class.simpleName
if (name != null && !name.endsWith("Encrypted") && !name.endsWith("Raw")) {
bot.logCyan("Packet received: $packet")
}
if (packet is ServerEventPacket) {
//no need to sync acknowledgement packets
NetworkScope.launch {

View File

@ -16,7 +16,7 @@ import net.mamoe.mirai.utils.*
*/
suspend fun QQ.uploadImage(image: PlatformImage): ImageId = with(bot.network.session) {
//SubmitImageFilenamePacket(account, account, "sdiovaoidsa.png", sessionKey).sendAndExpect<ServerSubmitImageFilenameResponsePacket>().join()
DebugLogger.logPurple("正在上传好友图片, md5=${image.md5.toUHexString()}")
return FriendImageIdRequestPacket(account, sessionKey, account, image).sendAndExpect<FriendImageIdRequestPacket.Response, ImageId> {
if (it.uKey != null) {
require(httpPostFriendImage(

View File

@ -195,11 +195,11 @@ class GroupImageIdRequestPacket(
//if (readUByte() != UByte.MIN_VALUE) {
//服务器还没有
discardExact(remaining - 128)
uKey = readBytes(128)
discardExact(remaining - 128 - 14)
uKey = readBytes(128)
//} else {
// println("服务器已经有了这个图片")
// println("后文 = ${readRemainingBytes().toUHexString()}")
//println("后文 = ${readRemainingBytes().toUHexString()}")
//}

View File

@ -73,7 +73,7 @@ actual suspend fun httpPostFriendImage(
"&range=" + "0" +
"&uin=" + botNumber.toLong()).openConnection() as HttpURLConnection
conn.setRequestProperty("User-Agent", "QQClient")
conn.setRequestProperty("Content-Length", "" + fileSize)
conn.setRequestProperty("Content-Length", imageData.toString())
conn.setRequestProperty("Connection", "Keep-Alive")
conn.requestMethod = "POST"
conn.doOutput = true
@ -98,7 +98,7 @@ actual suspend fun httpPostGroupImage(uKeyHex: String, fileSize: Long, imageData
"&term=pc" +
"&ver=5603" +
"&ukey=" + uKeyHex.replace(" ", "")).openConnection() as HttpURLConnection
conn.setRequestProperty("Content-Length", fileSize.toString())
conn.setRequestProperty("Content-Length", imageData.remaining.toString())
conn.setRequestProperty("Connection", "Keep-Alive")
conn.requestMethod = "POST"
conn.doOutput = true