mirror of
https://github.com/mamoe/mirai.git
synced 2025-02-08 01:42:28 +08:00
Fix fixToUHex
This commit is contained in:
parent
bd74907f68
commit
9694ba0c5a
@ -102,7 +102,7 @@ internal object GroupImagePacket : SessionPacketFactory<GroupImageResponse>() {
|
||||
@SerialId(2) val bot: Int,
|
||||
@SerialId(3) val const1: Byte = 0,
|
||||
@SerialId(4) val md5: ByteArray,
|
||||
@SerialId(5) val const2: Short = 0x0E2D,
|
||||
@SerialId(5) val const2: Short = 0x0F2D,
|
||||
@SerialId(6) val const3: ByteArray = constValue3,
|
||||
@SerialId(7) val const4: Byte = 1,
|
||||
// 8 is missing
|
||||
|
@ -103,7 +103,7 @@ internal object GroupPacket : SessionPacketFactory<GroupPacket.GroupPacketRespon
|
||||
|
||||
internal interface GroupPacketResponse : Packet
|
||||
|
||||
@NoLog
|
||||
//@NoLog
|
||||
internal object MessageResponse : Packet, GroupPacketResponse {
|
||||
override fun toString(): String = "GroupPacket.MessageResponse"
|
||||
}
|
||||
|
@ -11,7 +11,11 @@ import io.ktor.http.content.OutgoingContent
|
||||
import io.ktor.http.userAgent
|
||||
import kotlinx.coroutines.io.ByteWriteChannel
|
||||
import kotlinx.io.core.Input
|
||||
import kotlinx.io.core.readAvailable
|
||||
import kotlinx.io.pool.useInstance
|
||||
import net.mamoe.mirai.contact.GroupId
|
||||
import net.mamoe.mirai.utils.io.ByteArrayPool
|
||||
import net.mamoe.mirai.utils.io.debugPrint
|
||||
|
||||
|
||||
@Suppress("SpellCheckingInspection")
|
||||
@ -32,7 +36,7 @@ internal suspend inline fun HttpClient.postImage(
|
||||
parameters["htcmd"] = htcmd
|
||||
parameters["uin"] = uin.toString()
|
||||
|
||||
if (groupId != null) parameters["groupcode"] = groupId.value.toLong().toString()
|
||||
if (groupId != null) parameters["groupcode"] = groupId.value.toString()
|
||||
|
||||
parameters["term"] = "pc"
|
||||
parameters["ver"] = "5603"
|
||||
@ -41,17 +45,20 @@ internal suspend inline fun HttpClient.postImage(
|
||||
parameters["ukey"] = uKeyHex
|
||||
|
||||
userAgent("QQClient")
|
||||
|
||||
buildString().debugPrint("URL")
|
||||
}
|
||||
|
||||
body = object : OutgoingContent.WriteChannelContent() {
|
||||
override val contentType: ContentType = ContentType.Image.PNG
|
||||
override val contentType: ContentType = ContentType.Image.Any
|
||||
override val contentLength: Long = inputSize
|
||||
|
||||
override suspend fun writeTo(channel: ByteWriteChannel) {
|
||||
val buffer = byteArrayOf(1)
|
||||
repeat(contentLength.toInt()) {
|
||||
imageInput.readFully(buffer, 0, 1)
|
||||
channel.writeFully(buffer, 0, 1)
|
||||
ByteArrayPool.useInstance { buffer: ByteArray ->
|
||||
var size: Int
|
||||
while (imageInput.readAvailable(buffer).also { size = it } != 0) {
|
||||
channel.writeFully(buffer, 0, size)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -64,6 +64,9 @@ internal object MemberMuteEventPacketParserAndHandler : KnownEventParserAndHandl
|
||||
}
|
||||
|
||||
0x11u -> debugPrintIfFail("解析禁言包(0x02DC)时"){ // 猜测这个失败是撤回??
|
||||
// 00 0A 00 04 01 00 00 00 00 0C 00 05 00 01 00 01 01 27 0B 60 E7 11 00 33 08 07 20 E7 C1 AD B8 02 5A 29 08 A6 FE C0 A4 0A 1A 19 08 BC 15 10 C1 95 BC F0 05 18 CA CA 8F DE 04 20 00 28 00 30 A6 FE C0 A4 0A 2A 02 08 00 30 00 38 00
|
||||
// 失败
|
||||
|
||||
discardExact(15)
|
||||
discardExact(2)
|
||||
val group = bot.getGroup(readQQ())
|
||||
|
@ -95,7 +95,7 @@ fun Byte.fixToUHex(): String = this.toUByte().fixToUHex()
|
||||
/**
|
||||
* 转无符号十六进制表示, 并补充首位 `0`.
|
||||
*/
|
||||
fun UByte.fixToUHex(): String = if (this.toInt() in 0..9) "0${this.toString(16).toUpperCase()}" else this.toString(16).toUpperCase()
|
||||
fun UByte.fixToUHex(): String = if (this.toInt() in 0..15) "0${this.toString(16).toUpperCase()}" else this.toString(16).toUpperCase()
|
||||
|
||||
/**
|
||||
* 将无符号 Hex 转为 [ByteArray], 有根据 hex 的 [hashCode] 建立的缓存.
|
||||
|
Loading…
Reference in New Issue
Block a user