mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-08 17:20:11 +08:00
Image uploading
This commit is contained in:
parent
28b47f9603
commit
bc57001e36
@ -182,6 +182,11 @@ internal class TIMBotNetworkHandler internal constructor(private val bot: Bot) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
packet.use {
|
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
|
//coz removeIf is not inline
|
||||||
handlersLock.withLock {
|
handlersLock.withLock {
|
||||||
temporaryPacketHandlers.removeIfInlined {
|
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) {
|
if (packet is ServerEventPacket) {
|
||||||
//no need to sync acknowledgement packets
|
//no need to sync acknowledgement packets
|
||||||
NetworkScope.launch {
|
NetworkScope.launch {
|
||||||
|
@ -16,7 +16,7 @@ import net.mamoe.mirai.utils.*
|
|||||||
*/
|
*/
|
||||||
suspend fun QQ.uploadImage(image: PlatformImage): ImageId = with(bot.network.session) {
|
suspend fun QQ.uploadImage(image: PlatformImage): ImageId = with(bot.network.session) {
|
||||||
//SubmitImageFilenamePacket(account, account, "sdiovaoidsa.png", sessionKey).sendAndExpect<ServerSubmitImageFilenameResponsePacket>().join()
|
//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> {
|
return FriendImageIdRequestPacket(account, sessionKey, account, image).sendAndExpect<FriendImageIdRequestPacket.Response, ImageId> {
|
||||||
if (it.uKey != null) {
|
if (it.uKey != null) {
|
||||||
require(httpPostFriendImage(
|
require(httpPostFriendImage(
|
||||||
|
@ -195,11 +195,11 @@ class GroupImageIdRequestPacket(
|
|||||||
|
|
||||||
//if (readUByte() != UByte.MIN_VALUE) {
|
//if (readUByte() != UByte.MIN_VALUE) {
|
||||||
//服务器还没有
|
//服务器还没有
|
||||||
discardExact(remaining - 128)
|
discardExact(remaining - 128 - 14)
|
||||||
uKey = readBytes(128)
|
uKey = readBytes(128)
|
||||||
//} else {
|
//} else {
|
||||||
// println("服务器已经有了这个图片")
|
// println("服务器已经有了这个图片")
|
||||||
// println("后文 = ${readRemainingBytes().toUHexString()}")
|
//println("后文 = ${readRemainingBytes().toUHexString()}")
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ actual suspend fun httpPostFriendImage(
|
|||||||
"&range=" + "0" +
|
"&range=" + "0" +
|
||||||
"&uin=" + botNumber.toLong()).openConnection() as HttpURLConnection
|
"&uin=" + botNumber.toLong()).openConnection() as HttpURLConnection
|
||||||
conn.setRequestProperty("User-Agent", "QQClient")
|
conn.setRequestProperty("User-Agent", "QQClient")
|
||||||
conn.setRequestProperty("Content-Length", "" + fileSize)
|
conn.setRequestProperty("Content-Length", imageData.toString())
|
||||||
conn.setRequestProperty("Connection", "Keep-Alive")
|
conn.setRequestProperty("Connection", "Keep-Alive")
|
||||||
conn.requestMethod = "POST"
|
conn.requestMethod = "POST"
|
||||||
conn.doOutput = true
|
conn.doOutput = true
|
||||||
@ -98,7 +98,7 @@ actual suspend fun httpPostGroupImage(uKeyHex: String, fileSize: Long, imageData
|
|||||||
"&term=pc" +
|
"&term=pc" +
|
||||||
"&ver=5603" +
|
"&ver=5603" +
|
||||||
"&ukey=" + uKeyHex.replace(" ", "")).openConnection() as HttpURLConnection
|
"&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.setRequestProperty("Connection", "Keep-Alive")
|
||||||
conn.requestMethod = "POST"
|
conn.requestMethod = "POST"
|
||||||
conn.doOutput = true
|
conn.doOutput = true
|
||||||
|
Loading…
Reference in New Issue
Block a user