mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-27 17:00:14 +08:00
Move utilities to mirai-core-utils
This commit is contained in:
parent
3b87f1fb31
commit
73954130f8
@ -31,7 +31,7 @@ mirai 欢迎一切形式的代码贡献。你可以通过以下几种途径向 m
|
||||
### 注意事项
|
||||
- 尽量不要引用新的库
|
||||
- 遵守 Kotlin 官方代码规范(提交前使用 IDE 格式化代码 (commit 时勾选 'Reformat code'))
|
||||
- 不要手动拆解数据包. 请一定使用 `kotlinx.serialization` 拆解 ProtoBuf, 使用 `net.mamoe.mirai.internal.utils.io.serialization.Tars` 拆解 Tars 数据包, 使用 `kotlinx.serialization` 拆解 Json 数据.
|
||||
- 不要手动拆解数据包. 请一定使用 `kotlinx.serialization` 拆解 ProtoBuf, 使用 `net.mamoe.mirai.utils.serialization.Tars` 拆解 Tars 数据包, 使用 `kotlinx.serialization` 拆解 Json 数据.
|
||||
|
||||
## 社区
|
||||
|
||||
|
@ -21,7 +21,7 @@ import org.gradle.api.attributes.Attribute
|
||||
*/
|
||||
|
||||
object Versions {
|
||||
const val project = "2.0-M2-dev-5"
|
||||
const val project = "2.0-M2-dev-7"
|
||||
|
||||
const val kotlinCompiler = "1.4.21"
|
||||
const val kotlinStdlib = "1.4.21"
|
||||
|
@ -80,12 +80,8 @@ kotlin {
|
||||
|
||||
implementation1(`kotlinx-atomicfu`)
|
||||
|
||||
api1(`ktor-client-cio`)
|
||||
api1(`ktor-client-core`)
|
||||
api1(`ktor-network`)
|
||||
|
||||
compileOnly(`log4j-api`)
|
||||
compileOnly(slf4j)
|
||||
}
|
||||
}
|
||||
|
||||
@ -101,8 +97,6 @@ kotlin {
|
||||
|
||||
val jvmTest by getting {
|
||||
dependencies {
|
||||
api("org.pcap4j:pcap4j-distribution:1.8.2")
|
||||
|
||||
runtimeOnly(files("build/classes/kotlin/jvm/test")) // classpath is not properly set by IDE
|
||||
}
|
||||
}
|
||||
|
@ -9,9 +9,16 @@
|
||||
|
||||
@file:JvmMultifileClass
|
||||
@file:JvmName("MiraiUtils")
|
||||
@file:Suppress("NOTHING_TO_INLINE")
|
||||
|
||||
package net.mamoe.mirai.utils
|
||||
|
||||
import kotlinx.io.charsets.Charset
|
||||
import kotlinx.io.core.ByteReadPacket
|
||||
import java.util.*
|
||||
import kotlin.contracts.InvocationKind
|
||||
import kotlin.contracts.contract
|
||||
|
||||
|
||||
@JvmOverloads
|
||||
public fun generateImageId(md5: ByteArray, format: String = "mirai"): String {
|
||||
@ -23,7 +30,7 @@ public fun generateUUID(md5: ByteArray): String {
|
||||
}
|
||||
|
||||
@JvmSynthetic
|
||||
internal operator fun ByteArray.get(rangeStart: Int, rangeEnd: Int): String = buildString {
|
||||
public operator fun ByteArray.get(rangeStart: Int, rangeEnd: Int): String = buildString {
|
||||
for (it in rangeStart..rangeEnd) {
|
||||
append(this@get[it].fixToString())
|
||||
}
|
||||
@ -65,4 +72,64 @@ public fun ByteArray.checkOffsetAndLength(offset: Int, length: Int) {
|
||||
require(offset >= 0) { "offset shouldn't be negative: $offset" }
|
||||
require(length >= 0) { "length shouldn't be negative: $length" }
|
||||
require(offset + length <= this.size) { "offset ($offset) + length ($length) > array.size (${this.size})" }
|
||||
}
|
||||
|
||||
|
||||
@JvmOverloads
|
||||
@Suppress("DuplicatedCode") // false positive. foreach is not common to UByteArray and ByteArray
|
||||
public fun List<Byte>.toUHexString(separator: String = " ", offset: Int = 0, length: Int = this.size - offset): String {
|
||||
require(offset >= 0) { "offset shouldn't be negative: $offset" }
|
||||
require(length >= 0) { "length shouldn't be negative: $length" }
|
||||
require(offset + length <= this.size) { "offset ($offset) + length ($length) > array.size (${this.size})" }
|
||||
|
||||
if (length == 0) {
|
||||
return ""
|
||||
}
|
||||
val lastIndex = offset + length
|
||||
return buildString(length * 2) {
|
||||
this@toUHexString.forEachIndexed { index, it ->
|
||||
if (index in offset until lastIndex) {
|
||||
var ret = it.toUByte().toString(16).toUpperCase()
|
||||
if (ret.length == 1) ret = "0$ret"
|
||||
append(ret)
|
||||
if (index < lastIndex - 1) append(separator)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@JvmSynthetic
|
||||
@Suppress("DuplicatedCode") // false positive. foreach is not common to UByteArray and ByteArray
|
||||
@ExperimentalUnsignedTypes
|
||||
public fun UByteArray.toUHexString(separator: String = " ", offset: Int = 0, length: Int = this.size - offset): String {
|
||||
if (length == 0) {
|
||||
return ""
|
||||
}
|
||||
val lastIndex = offset + length
|
||||
return buildString(length * 2) {
|
||||
this@toUHexString.forEachIndexed { index, it ->
|
||||
if (index in offset until lastIndex) {
|
||||
var ret = it.toByte().toUByte().toString(16).toUpperCase()
|
||||
if (ret.length == 1) ret = "0$ret"
|
||||
append(ret)
|
||||
if (index < lastIndex - 1) append(separator)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public inline fun ByteArray.encodeToString(offset: Int = 0, charset: Charset = Charsets.UTF_8): String =
|
||||
kotlinx.io.core.String(this, charset = charset, offset = offset, length = this.size - offset)
|
||||
|
||||
public inline fun ByteArray.encodeToBase64(): String =
|
||||
Base64.getEncoder().encodeToString(this)
|
||||
|
||||
public inline fun ByteArray.toReadPacket(offset: Int = 0, length: Int = this.size - offset): ByteReadPacket =
|
||||
ByteReadPacket(this, offset = offset, length = length)
|
||||
|
||||
public inline fun <R> ByteArray.read(t: ByteReadPacket.() -> R): R {
|
||||
contract {
|
||||
callsInPlace(t, InvocationKind.EXACTLY_ONCE)
|
||||
}
|
||||
return this.toReadPacket().withUse(t)
|
||||
}
|
@ -7,23 +7,20 @@
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@file:Suppress("EXPERIMENTAL_API_USAGE", "EXPERIMENTAL_UNSIGNED_LITERALS", "NOTHING_TO_INLINE")
|
||||
@file:JvmMultifileClass
|
||||
@file:JvmName("Utils")
|
||||
@file:JvmName("MiraiUtils")
|
||||
|
||||
package net.mamoe.mirai.internal.utils.io
|
||||
@file:Suppress("NOTHING_TO_INLINE")
|
||||
|
||||
import kotlinx.io.charsets.Charset
|
||||
import kotlinx.io.charsets.Charsets
|
||||
package net.mamoe.mirai.utils
|
||||
|
||||
import io.ktor.utils.io.charsets.*
|
||||
import kotlinx.io.core.*
|
||||
import net.mamoe.mirai.internal.utils.toReadPacket
|
||||
import net.mamoe.mirai.utils.ByteArrayPool
|
||||
import net.mamoe.mirai.utils.toUHexString
|
||||
import kotlin.contracts.InvocationKind
|
||||
import kotlin.contracts.contract
|
||||
import kotlin.text.Charsets
|
||||
|
||||
|
||||
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
||||
internal inline fun <R> ByteReadPacket.useBytes(
|
||||
public inline fun <R> ByteReadPacket.useBytes(
|
||||
n: Int = remaining.toInt(),//not that safe but adequate
|
||||
block: (data: ByteArray, length: Int) -> R
|
||||
): R = ByteArrayPool.useInstance(n) {
|
||||
@ -31,35 +28,27 @@ internal inline fun <R> ByteReadPacket.useBytes(
|
||||
block(it, n)
|
||||
}
|
||||
|
||||
internal inline fun ByteReadPacket.readPacketExact(
|
||||
public inline fun ByteReadPacket.readPacketExact(
|
||||
n: Int = remaining.toInt()//not that safe but adequate
|
||||
): ByteReadPacket = this.readBytes(n).toReadPacket()
|
||||
|
||||
internal inline fun <C : Closeable, R> C.withUse(block: C.() -> R): R {
|
||||
contract {
|
||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
||||
}
|
||||
return use(block)
|
||||
}
|
||||
|
||||
private inline fun <R> inline(block: () -> R): R = block()
|
||||
public typealias TlvMap = MutableMap<Int, ByteArray>
|
||||
|
||||
internal typealias TlvMap = MutableMap<Int, ByteArray>
|
||||
|
||||
internal inline fun TlvMap.getOrFail(tag: Int): ByteArray {
|
||||
public inline fun TlvMap.getOrFail(tag: Int): ByteArray {
|
||||
return this[tag] ?: error("cannot find tlv 0x${tag.toUHexString("")}($tag)")
|
||||
}
|
||||
|
||||
internal inline fun TlvMap.getOrFail(tag: Int, lazyMessage: (tag: Int) -> String): ByteArray {
|
||||
public inline fun TlvMap.getOrFail(tag: Int, lazyMessage: (tag: Int) -> String): ByteArray {
|
||||
return this[tag] ?: error(lazyMessage(tag))
|
||||
}
|
||||
|
||||
@Suppress("FunctionName")
|
||||
internal inline fun Input._readTLVMap(tagSize: Int = 2, suppressDuplication: Boolean = true): TlvMap =
|
||||
public inline fun Input._readTLVMap(tagSize: Int = 2, suppressDuplication: Boolean = true): TlvMap =
|
||||
_readTLVMap(true, tagSize, suppressDuplication)
|
||||
|
||||
@Suppress("DuplicatedCode", "FunctionName")
|
||||
internal fun Input._readTLVMap(
|
||||
public fun Input._readTLVMap(
|
||||
expectingEOF: Boolean = true,
|
||||
tagSize: Int,
|
||||
suppressDuplication: Boolean = true
|
||||
@ -67,7 +56,7 @@ internal fun Input._readTLVMap(
|
||||
val map = mutableMapOf<Int, ByteArray>()
|
||||
var key = 0
|
||||
|
||||
while (inline {
|
||||
while (kotlin.run {
|
||||
try {
|
||||
key = when (tagSize) {
|
||||
1 -> readUByte().toInt()
|
||||
@ -120,18 +109,18 @@ internal fun Input._readTLVMap(
|
||||
return map
|
||||
}
|
||||
|
||||
internal inline fun Input.readString(length: Int, charset: Charset = Charsets.UTF_8): String =
|
||||
public inline fun Input.readString(length: Int, charset: Charset = Charsets.UTF_8): String =
|
||||
String(this.readBytes(length), charset = charset)
|
||||
|
||||
internal inline fun Input.readString(length: Long, charset: Charset = Charsets.UTF_8): String =
|
||||
public inline fun Input.readString(length: Long, charset: Charset = Charsets.UTF_8): String =
|
||||
String(this.readBytes(length.toInt()), charset = charset)
|
||||
|
||||
internal inline fun Input.readString(length: Short, charset: Charset = Charsets.UTF_8): String =
|
||||
public inline fun Input.readString(length: Short, charset: Charset = Charsets.UTF_8): String =
|
||||
String(this.readBytes(length.toInt()), charset = charset)
|
||||
|
||||
@JvmSynthetic
|
||||
internal inline fun Input.readString(length: UShort, charset: Charset = Charsets.UTF_8): String =
|
||||
public inline fun Input.readString(length: UShort, charset: Charset = Charsets.UTF_8): String =
|
||||
String(this.readBytes(length.toInt()), charset = charset)
|
||||
|
||||
internal inline fun Input.readString(length: Byte, charset: Charset = Charsets.UTF_8): String =
|
||||
public inline fun Input.readString(length: Byte, charset: Charset = Charsets.UTF_8): String =
|
||||
String(this.readBytes(length.toInt()), charset = charset)
|
@ -13,7 +13,6 @@
|
||||
package net.mamoe.mirai.utils
|
||||
|
||||
import io.ktor.client.*
|
||||
import io.ktor.client.engine.cio.*
|
||||
import kotlinx.io.core.Input
|
||||
import kotlinx.io.core.readAvailable
|
||||
import java.io.*
|
||||
@ -30,7 +29,7 @@ public object MiraiPlatformUtils {
|
||||
/**
|
||||
* Ktor HttpClient. 不同平台使用不同引擎.
|
||||
*/
|
||||
public val Http: HttpClient = HttpClient(CIO)
|
||||
public val Http: HttpClient = HttpClient()
|
||||
}
|
||||
|
||||
@JvmOverloads
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
package net.mamoe.mirai.internal
|
||||
|
||||
import io.ktor.client.engine.cio.*
|
||||
import io.ktor.client.request.*
|
||||
import io.ktor.client.request.forms.*
|
||||
import kotlinx.coroutines.SupervisorJob
|
||||
@ -23,15 +24,12 @@ import net.mamoe.mirai.event.events.NewFriendRequestEvent
|
||||
import net.mamoe.mirai.internal.contact.*
|
||||
import net.mamoe.mirai.internal.message.*
|
||||
import net.mamoe.mirai.internal.network.highway.HighwayHelper
|
||||
import net.mamoe.mirai.internal.network.protocol.data.jce.toOtherClientInfo
|
||||
import net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody
|
||||
import net.mamoe.mirai.internal.network.protocol.data.proto.LongMsg
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.chat.*
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.chat.voice.PttStore
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.list.FriendList
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.login.StatSvc
|
||||
import net.mamoe.mirai.internal.utils.encodeToString
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.toByteArray
|
||||
import net.mamoe.mirai.message.MessageReceipt
|
||||
import net.mamoe.mirai.message.action.Nudge
|
||||
import net.mamoe.mirai.message.data.*
|
||||
@ -40,6 +38,7 @@ import net.mamoe.mirai.message.data.Image.Key.FRIEND_IMAGE_ID_REGEX_2
|
||||
import net.mamoe.mirai.message.data.Image.Key.GROUP_IMAGE_ID_REGEX
|
||||
import net.mamoe.mirai.utils.*
|
||||
import net.mamoe.mirai.utils.ExternalResource.Companion.toExternalResource
|
||||
import net.mamoe.mirai.utils.serialization.toByteArray
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
import kotlin.math.absoluteValue
|
||||
import kotlin.random.Random
|
||||
@ -50,6 +49,7 @@ internal open class MiraiImpl : IMirai, LowLevelApiAccessor {
|
||||
companion object INSTANCE : MiraiImpl() {
|
||||
@Suppress("ObjectPropertyName", "unused")
|
||||
private val _init = Mirai.let {
|
||||
CIO // init
|
||||
Message.Serializer.registerSerializer(OfflineGroupImage::class, OfflineGroupImage.serializer())
|
||||
Message.Serializer.registerSerializer(OfflineFriendImage::class, OfflineFriendImage.serializer())
|
||||
Message.Serializer.registerSerializer(MarketFaceImpl::class, MarketFaceImpl.serializer())
|
||||
|
@ -20,10 +20,10 @@ import net.mamoe.mirai.internal.network.highway.postImage
|
||||
import net.mamoe.mirai.internal.network.highway.sizeToString
|
||||
import net.mamoe.mirai.internal.network.protocol.data.proto.Cmd0x352
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.chat.image.LongConn
|
||||
import net.mamoe.mirai.internal.utils.toUHexString
|
||||
import net.mamoe.mirai.message.data.Image
|
||||
import net.mamoe.mirai.utils.ExternalResource
|
||||
import net.mamoe.mirai.utils.MiraiPlatformUtils
|
||||
import net.mamoe.mirai.utils.toUHexString
|
||||
import net.mamoe.mirai.utils.verbose
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
import kotlin.math.roundToInt
|
||||
|
@ -13,11 +13,11 @@ package net.mamoe.mirai.internal.message
|
||||
|
||||
import net.mamoe.mirai.internal.network.protocol.data.proto.HummerCommelem
|
||||
import net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.toByteArray
|
||||
import net.mamoe.mirai.message.data.FlashImage
|
||||
import net.mamoe.mirai.message.data.isFriendImage
|
||||
import net.mamoe.mirai.message.data.isGroupImage
|
||||
import net.mamoe.mirai.message.data.md5
|
||||
import net.mamoe.mirai.utils.serialization.toByteArray
|
||||
|
||||
|
||||
internal fun FlashImage.toJceData(): ImMsgBody.Elem {
|
||||
|
@ -24,13 +24,10 @@ import net.mamoe.mirai.contact.Group
|
||||
import net.mamoe.mirai.internal.network.protocol.data.proto.*
|
||||
import net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody
|
||||
import net.mamoe.mirai.internal.utils.*
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.loadAs
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.toByteArray
|
||||
import net.mamoe.mirai.message.data.*
|
||||
import net.mamoe.mirai.utils.hexToBytes
|
||||
import net.mamoe.mirai.utils.safeCast
|
||||
import net.mamoe.mirai.utils.unzip
|
||||
import net.mamoe.mirai.utils.zip
|
||||
import net.mamoe.mirai.utils.*
|
||||
import net.mamoe.mirai.utils.serialization.loadAs
|
||||
import net.mamoe.mirai.utils.serialization.toByteArray
|
||||
import kotlin.contracts.ExperimentalContracts
|
||||
import kotlin.contracts.InvocationKind
|
||||
import kotlin.contracts.contract
|
||||
|
@ -14,12 +14,12 @@ import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.Transient
|
||||
import net.mamoe.mirai.internal.network.protocol.data.proto.HummerCommelem
|
||||
import net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.toByteArray
|
||||
import net.mamoe.mirai.message.code.internal.appendAsMiraiCode
|
||||
import net.mamoe.mirai.message.data.Face
|
||||
import net.mamoe.mirai.message.data.MarketFace
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalApi
|
||||
import net.mamoe.mirai.utils.hexToBytes
|
||||
import net.mamoe.mirai.utils.serialization.toByteArray
|
||||
import net.mamoe.mirai.utils.toByteArray
|
||||
|
||||
internal val FACE_BUF = "00 01 00 04 52 CC F5 D0".hexToBytes()
|
||||
|
@ -21,14 +21,14 @@ import net.mamoe.mirai.internal.network.protocol.data.proto.MsgComm
|
||||
import net.mamoe.mirai.internal.network.protocol.data.proto.SourceMsg
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.EMPTY_BYTE_ARRAY
|
||||
import net.mamoe.mirai.internal.utils._miraiContentToString
|
||||
import net.mamoe.mirai.internal.utils.encodeToBase64
|
||||
import net.mamoe.mirai.internal.utils.encodeToString
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.toByteArray
|
||||
import net.mamoe.mirai.message.data.Message
|
||||
import net.mamoe.mirai.message.data.MessageChain
|
||||
import net.mamoe.mirai.message.data.MessageSource
|
||||
import net.mamoe.mirai.message.data.OnlineMessageSource
|
||||
import net.mamoe.mirai.utils.encodeToBase64
|
||||
import net.mamoe.mirai.utils.encodeToString
|
||||
import net.mamoe.mirai.utils.mapToIntArray
|
||||
import net.mamoe.mirai.utils.serialization.toByteArray
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
|
||||
internal interface MessageSourceInternal {
|
||||
|
@ -15,11 +15,11 @@ import net.mamoe.mirai.internal.network.protocol.data.proto.ImMsgBody
|
||||
import net.mamoe.mirai.internal.network.protocol.data.proto.MsgComm
|
||||
import net.mamoe.mirai.internal.network.protocol.data.proto.SourceMsg
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.EMPTY_BYTE_ARRAY
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.loadAs
|
||||
import net.mamoe.mirai.message.data.MessageChain
|
||||
import net.mamoe.mirai.message.data.MessageSourceKind
|
||||
import net.mamoe.mirai.message.data.OfflineMessageSource
|
||||
import net.mamoe.mirai.utils.mapToIntArray
|
||||
import net.mamoe.mirai.utils.serialization.loadAs
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
|
||||
|
||||
|
@ -26,10 +26,10 @@ import net.mamoe.mirai.internal.network.protocol.data.proto.MsgComm
|
||||
import net.mamoe.mirai.internal.network.protocol.data.proto.SourceMsg
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.chat.receive.OnlinePushPbPushGroupMsg.SendGroupMessageReceipt
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.chat.toLongUnsigned
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.toByteArray
|
||||
import net.mamoe.mirai.message.data.MessageChain
|
||||
import net.mamoe.mirai.message.data.MessageSource
|
||||
import net.mamoe.mirai.message.data.OnlineMessageSource
|
||||
import net.mamoe.mirai.utils.serialization.toByteArray
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
|
||||
|
||||
|
@ -42,7 +42,6 @@ import net.mamoe.mirai.internal.network.protocol.packet.login.Heartbeat
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.login.StatSvc
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.login.WtLogin
|
||||
import net.mamoe.mirai.internal.utils.*
|
||||
import net.mamoe.mirai.internal.utils.io.readPacketExact
|
||||
import net.mamoe.mirai.network.*
|
||||
import net.mamoe.mirai.utils.*
|
||||
import java.util.concurrent.ConcurrentLinkedQueue
|
||||
|
@ -27,11 +27,10 @@ import net.mamoe.mirai.internal.network.protocol.packet.EMPTY_BYTE_ARRAY
|
||||
import net.mamoe.mirai.internal.utils.PlatformSocket
|
||||
import net.mamoe.mirai.internal.utils.SocketException
|
||||
import net.mamoe.mirai.internal.utils.addSuppressedMirai
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.readProtoBuf
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.toByteArray
|
||||
import net.mamoe.mirai.internal.utils.io.withUse
|
||||
import net.mamoe.mirai.internal.utils.toIpV4AddressString
|
||||
import net.mamoe.mirai.utils.*
|
||||
import net.mamoe.mirai.utils.serialization.readProtoBuf
|
||||
import net.mamoe.mirai.utils.serialization.toByteArray
|
||||
import java.io.InputStream
|
||||
import kotlin.math.roundToInt
|
||||
import kotlin.time.ExperimentalTime
|
||||
|
@ -11,9 +11,8 @@ package net.mamoe.mirai.internal.network.protocol.data.jce
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import net.mamoe.mirai.internal.network.Packet
|
||||
import net.mamoe.mirai.internal.utils.io.JceStruct
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.tars.TarsId
|
||||
import kotlin.jvm.JvmField
|
||||
import net.mamoe.mirai.utils.JceStruct
|
||||
import net.mamoe.mirai.utils.serialization.tars.TarsId
|
||||
|
||||
@Serializable
|
||||
internal class BigDataChannel(
|
||||
|
@ -9,8 +9,8 @@
|
||||
package net.mamoe.mirai.internal.network.protocol.data.jce
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import net.mamoe.mirai.internal.utils.io.JceStruct
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.tars.TarsId
|
||||
import net.mamoe.mirai.utils.JceStruct
|
||||
import net.mamoe.mirai.utils.serialization.tars.TarsId
|
||||
|
||||
@Serializable
|
||||
internal class DeviceItemDes(
|
||||
|
@ -10,9 +10,8 @@
|
||||
package net.mamoe.mirai.internal.network.protocol.data.jce
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import net.mamoe.mirai.internal.utils.io.JceStruct
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.tars.TarsId
|
||||
import kotlin.jvm.JvmField
|
||||
import net.mamoe.mirai.utils.JceStruct
|
||||
import net.mamoe.mirai.utils.serialization.tars.TarsId
|
||||
|
||||
@Serializable
|
||||
internal class ModifyGroupCardReq(
|
||||
|
@ -10,9 +10,8 @@
|
||||
package net.mamoe.mirai.internal.network.protocol.data.jce
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import net.mamoe.mirai.internal.utils.io.JceStruct
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.tars.TarsId
|
||||
import kotlin.jvm.JvmField
|
||||
import net.mamoe.mirai.utils.JceStruct
|
||||
import net.mamoe.mirai.utils.serialization.tars.TarsId
|
||||
|
||||
@Serializable
|
||||
internal class GroupMngReqJce(
|
||||
|
@ -11,8 +11,8 @@ package net.mamoe.mirai.internal.network.protocol.data.jce
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import net.mamoe.mirai.contact.ClientKind
|
||||
import net.mamoe.mirai.internal.utils.io.JceStruct
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.tars.TarsId
|
||||
import net.mamoe.mirai.utils.JceStruct
|
||||
import net.mamoe.mirai.utils.serialization.tars.TarsId
|
||||
|
||||
@Serializable
|
||||
internal data class InstanceInfo(
|
||||
|
@ -11,9 +11,8 @@ package net.mamoe.mirai.internal.network.protocol.data.jce
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.EMPTY_BYTE_ARRAY
|
||||
import net.mamoe.mirai.internal.utils.io.JceStruct
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.tars.TarsId
|
||||
import kotlin.jvm.JvmField
|
||||
import net.mamoe.mirai.utils.JceStruct
|
||||
import net.mamoe.mirai.utils.serialization.tars.TarsId
|
||||
|
||||
@Serializable
|
||||
internal class AddGroup(
|
||||
|
@ -10,9 +10,8 @@
|
||||
package net.mamoe.mirai.internal.network.protocol.data.jce
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import net.mamoe.mirai.internal.utils.io.JceStruct
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.tars.TarsId
|
||||
import kotlin.jvm.JvmField
|
||||
import net.mamoe.mirai.utils.JceStruct
|
||||
import net.mamoe.mirai.utils.serialization.tars.TarsId
|
||||
|
||||
internal class OnlinePushPack {
|
||||
@Serializable
|
||||
|
@ -12,8 +12,8 @@ package net.mamoe.mirai.internal.network.protocol.data.jce
|
||||
import kotlinx.serialization.Serializable
|
||||
import net.mamoe.mirai.internal.network.Packet
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.EMPTY_BYTE_ARRAY
|
||||
import net.mamoe.mirai.internal.utils.io.JceStruct
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.tars.TarsId
|
||||
import net.mamoe.mirai.utils.JceStruct
|
||||
import net.mamoe.mirai.utils.serialization.tars.TarsId
|
||||
|
||||
@Suppress("ArrayInDataClass")
|
||||
@Serializable
|
||||
|
@ -10,9 +10,8 @@
|
||||
package net.mamoe.mirai.internal.network.protocol.data.jce
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import net.mamoe.mirai.internal.utils.io.JceStruct
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.tars.TarsId
|
||||
import kotlin.jvm.JvmField
|
||||
import net.mamoe.mirai.utils.JceStruct
|
||||
import net.mamoe.mirai.utils.serialization.tars.TarsId
|
||||
|
||||
@Serializable
|
||||
internal class RequestMSFForceOffline(
|
||||
|
@ -11,8 +11,8 @@ package net.mamoe.mirai.internal.network.protocol.data.jce
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.EMPTY_BYTE_ARRAY
|
||||
import net.mamoe.mirai.internal.utils.io.JceStruct
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.tars.TarsId
|
||||
import net.mamoe.mirai.utils.JceStruct
|
||||
import net.mamoe.mirai.utils.serialization.tars.TarsId
|
||||
|
||||
private val EMPTY_MAP = mapOf<String, String>()
|
||||
|
||||
|
@ -10,9 +10,8 @@
|
||||
package net.mamoe.mirai.internal.network.protocol.data.jce
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import net.mamoe.mirai.internal.utils.io.JceStruct
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.tars.TarsId
|
||||
import kotlin.jvm.JvmField
|
||||
import net.mamoe.mirai.utils.JceStruct
|
||||
import net.mamoe.mirai.utils.serialization.tars.TarsId
|
||||
|
||||
@Serializable
|
||||
internal class RequestPushForceOffline(
|
||||
|
@ -12,8 +12,8 @@ package net.mamoe.mirai.internal.network.protocol.data.jce
|
||||
import kotlinx.serialization.Serializable
|
||||
import net.mamoe.mirai.contact.OtherClientInfo
|
||||
import net.mamoe.mirai.contact.Platform
|
||||
import net.mamoe.mirai.internal.utils.io.JceStruct
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.tars.TarsId
|
||||
import net.mamoe.mirai.utils.JceStruct
|
||||
import net.mamoe.mirai.utils.serialization.tars.TarsId
|
||||
|
||||
@Serializable
|
||||
internal data class SvcDevLoginInfo(
|
||||
|
@ -10,8 +10,8 @@
|
||||
package net.mamoe.mirai.internal.network.protocol.data.jce
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import net.mamoe.mirai.internal.utils.io.JceStruct
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.tars.TarsId
|
||||
import net.mamoe.mirai.utils.JceStruct
|
||||
import net.mamoe.mirai.utils.serialization.tars.TarsId
|
||||
|
||||
// ANDROID PHONE QQ
|
||||
|
||||
|
@ -10,9 +10,8 @@
|
||||
package net.mamoe.mirai.internal.network.protocol.data.jce
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import net.mamoe.mirai.internal.utils.io.JceStruct
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.tars.TarsId
|
||||
import kotlin.jvm.JvmField
|
||||
import net.mamoe.mirai.utils.JceStruct
|
||||
import net.mamoe.mirai.utils.serialization.tars.TarsId
|
||||
|
||||
@Serializable
|
||||
internal class SvcReqRegister(
|
||||
|
@ -12,8 +12,8 @@
|
||||
package net.mamoe.mirai.internal.network.protocol.data.jce
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import net.mamoe.mirai.internal.utils.io.JceStruct
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.tars.TarsId
|
||||
import net.mamoe.mirai.utils.JceStruct
|
||||
import net.mamoe.mirai.utils.serialization.tars.TarsId
|
||||
|
||||
@Serializable
|
||||
internal class SvcRequestPushReadedNotify(
|
||||
|
@ -10,8 +10,8 @@
|
||||
package net.mamoe.mirai.internal.network.protocol.data.jce
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import net.mamoe.mirai.internal.utils.io.JceStruct
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.tars.TarsId
|
||||
import net.mamoe.mirai.utils.JceStruct
|
||||
import net.mamoe.mirai.utils.serialization.tars.TarsId
|
||||
|
||||
|
||||
@Serializable
|
||||
|
@ -10,8 +10,8 @@
|
||||
package net.mamoe.mirai.internal.network.protocol.data.jce
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import net.mamoe.mirai.internal.utils.io.JceStruct
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.tars.TarsId
|
||||
import net.mamoe.mirai.utils.JceStruct
|
||||
import net.mamoe.mirai.utils.serialization.tars.TarsId
|
||||
|
||||
@Serializable
|
||||
internal class SvcRspGetDevLoginInfo(
|
||||
|
@ -10,9 +10,8 @@
|
||||
package net.mamoe.mirai.internal.network.protocol.data.jce
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import net.mamoe.mirai.internal.utils.io.JceStruct
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.tars.TarsId
|
||||
import kotlin.jvm.JvmField
|
||||
import net.mamoe.mirai.utils.JceStruct
|
||||
import net.mamoe.mirai.utils.serialization.tars.TarsId
|
||||
|
||||
@Serializable
|
||||
internal class GetTroopListReqV2Simplify(
|
||||
|
@ -12,8 +12,7 @@ package net.mamoe.mirai.internal.network.protocol.data.proto
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.protobuf.ProtoNumber
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.EMPTY_BYTE_ARRAY
|
||||
import net.mamoe.mirai.internal.utils.io.ProtoBuf
|
||||
import kotlin.jvm.JvmField
|
||||
import net.mamoe.mirai.utils.ProtoBuf
|
||||
|
||||
@Serializable
|
||||
internal class Cmd0x352 : ProtoBuf {
|
||||
|
@ -12,8 +12,7 @@ package net.mamoe.mirai.internal.network.protocol.data.proto
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.protobuf.ProtoNumber
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.EMPTY_BYTE_ARRAY
|
||||
import net.mamoe.mirai.internal.utils.io.ProtoBuf
|
||||
import kotlin.jvm.JvmField
|
||||
import net.mamoe.mirai.utils.ProtoBuf
|
||||
|
||||
@Serializable
|
||||
internal class Cmd0x388 : ProtoBuf {
|
||||
|
@ -16,8 +16,7 @@ import kotlinx.serialization.protobuf.ProtoIntegerType
|
||||
import kotlinx.serialization.protobuf.ProtoNumber
|
||||
import kotlinx.serialization.protobuf.ProtoType
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.EMPTY_BYTE_ARRAY
|
||||
import net.mamoe.mirai.internal.utils.io.ProtoBuf
|
||||
import kotlin.jvm.JvmField
|
||||
import net.mamoe.mirai.utils.ProtoBuf
|
||||
|
||||
internal class GroupOpenSysMsg : ProtoBuf {
|
||||
@Serializable
|
||||
|
@ -16,8 +16,7 @@ import kotlinx.serialization.protobuf.ProtoIntegerType
|
||||
import kotlinx.serialization.protobuf.ProtoNumber
|
||||
import kotlinx.serialization.protobuf.ProtoType
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.EMPTY_BYTE_ARRAY
|
||||
import net.mamoe.mirai.internal.utils.io.ProtoBuf
|
||||
import kotlin.jvm.JvmField
|
||||
import net.mamoe.mirai.utils.ProtoBuf
|
||||
|
||||
@Serializable
|
||||
internal class Oidb0x858 : ProtoBuf {
|
||||
|
@ -12,8 +12,7 @@ package net.mamoe.mirai.internal.network.protocol.data.proto
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.protobuf.ProtoNumber
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.EMPTY_BYTE_ARRAY
|
||||
import net.mamoe.mirai.internal.utils.io.ProtoBuf
|
||||
import kotlin.jvm.JvmField
|
||||
import net.mamoe.mirai.utils.ProtoBuf
|
||||
|
||||
internal class Common : ProtoBuf {
|
||||
@Serializable
|
||||
|
@ -14,8 +14,7 @@ package net.mamoe.mirai.internal.network.protocol.data.proto
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.protobuf.ProtoNumber
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.EMPTY_BYTE_ARRAY
|
||||
import net.mamoe.mirai.internal.utils.io.ProtoBuf
|
||||
import kotlin.jvm.JvmField
|
||||
import net.mamoe.mirai.utils.ProtoBuf
|
||||
|
||||
@Serializable
|
||||
internal class Vec0xd50 : ProtoBuf {
|
||||
|
@ -12,8 +12,7 @@ package net.mamoe.mirai.internal.network.protocol.data.proto
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.protobuf.ProtoNumber
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.EMPTY_BYTE_ARRAY
|
||||
import net.mamoe.mirai.internal.utils.io.ProtoBuf
|
||||
import kotlin.jvm.JvmField
|
||||
import net.mamoe.mirai.utils.ProtoBuf
|
||||
|
||||
@Serializable
|
||||
internal class GroupLabel : ProtoBuf {
|
||||
|
@ -14,8 +14,7 @@ import kotlinx.serialization.protobuf.ProtoIntegerType
|
||||
import kotlinx.serialization.protobuf.ProtoNumber
|
||||
import kotlinx.serialization.protobuf.ProtoType
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.EMPTY_BYTE_ARRAY
|
||||
import net.mamoe.mirai.internal.utils.io.ProtoBuf
|
||||
import kotlin.jvm.JvmField
|
||||
import net.mamoe.mirai.utils.ProtoBuf
|
||||
|
||||
@Serializable
|
||||
internal class BdhExtinfo : ProtoBuf {
|
||||
|
@ -12,7 +12,7 @@ package net.mamoe.mirai.internal.network.protocol.data.proto
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.protobuf.ProtoNumber
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.EMPTY_BYTE_ARRAY
|
||||
import net.mamoe.mirai.internal.utils.io.ProtoBuf
|
||||
import net.mamoe.mirai.utils.ProtoBuf
|
||||
|
||||
internal class HummerCommelem : ProtoBuf {
|
||||
@Serializable
|
||||
|
@ -13,7 +13,7 @@ package net.mamoe.mirai.internal.network.protocol.data.proto
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.protobuf.ProtoNumber
|
||||
import net.mamoe.mirai.internal.utils.io.ProtoBuf
|
||||
import net.mamoe.mirai.utils.ProtoBuf
|
||||
|
||||
@Serializable
|
||||
internal class MarketFaceExtPb : ProtoBuf {
|
||||
|
@ -14,7 +14,7 @@ package net.mamoe.mirai.internal.network.protocol.data.proto
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.protobuf.ProtoNumber
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.EMPTY_BYTE_ARRAY
|
||||
import net.mamoe.mirai.internal.utils.io.ProtoBuf
|
||||
import net.mamoe.mirai.utils.ProtoBuf
|
||||
|
||||
@Serializable
|
||||
internal class HummerResv21 : ProtoBuf {
|
||||
|
@ -11,7 +11,7 @@ package net.mamoe.mirai.internal.network.protocol.data.proto
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.protobuf.ProtoNumber
|
||||
import net.mamoe.mirai.internal.utils.io.ProtoBuf
|
||||
import net.mamoe.mirai.utils.ProtoBuf
|
||||
import net.mamoe.mirai.utils.currentTimeSeconds
|
||||
|
||||
internal interface ImgReq : ProtoBuf
|
||||
|
@ -12,8 +12,7 @@ package net.mamoe.mirai.internal.network.protocol.data.proto
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.protobuf.ProtoNumber
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.EMPTY_BYTE_ARRAY
|
||||
import net.mamoe.mirai.internal.utils.io.ProtoBuf
|
||||
import kotlin.jvm.JvmField
|
||||
import net.mamoe.mirai.utils.ProtoBuf
|
||||
|
||||
internal class LongMsg : ProtoBuf {
|
||||
@Serializable
|
||||
|
@ -14,8 +14,8 @@ import kotlinx.serialization.protobuf.ProtoIntegerType
|
||||
import kotlinx.serialization.protobuf.ProtoNumber
|
||||
import kotlinx.serialization.protobuf.ProtoType
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.EMPTY_BYTE_ARRAY
|
||||
import net.mamoe.mirai.internal.utils.io.ProtoBuf
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.toByteArray
|
||||
import net.mamoe.mirai.utils.ProtoBuf
|
||||
import net.mamoe.mirai.utils.serialization.toByteArray
|
||||
|
||||
@Serializable
|
||||
internal class ImCommon : ProtoBuf {
|
||||
|
@ -12,8 +12,7 @@ package net.mamoe.mirai.internal.network.protocol.data.proto
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.protobuf.ProtoNumber
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.EMPTY_BYTE_ARRAY
|
||||
import net.mamoe.mirai.internal.utils.io.ProtoBuf
|
||||
import kotlin.jvm.JvmField
|
||||
import net.mamoe.mirai.utils.ProtoBuf
|
||||
|
||||
/**
|
||||
* msf.msgcomm.msg_comm
|
||||
|
@ -11,8 +11,7 @@ package net.mamoe.mirai.internal.network.protocol.data.proto
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.protobuf.ProtoNumber
|
||||
import net.mamoe.mirai.internal.utils.io.ProtoBuf
|
||||
import kotlin.jvm.JvmField
|
||||
import net.mamoe.mirai.utils.ProtoBuf
|
||||
|
||||
internal class MsgRevokeUserDef : ProtoBuf {
|
||||
@Serializable
|
||||
|
@ -13,8 +13,7 @@ import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.protobuf.ProtoNumber
|
||||
import net.mamoe.mirai.internal.network.Packet
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.EMPTY_BYTE_ARRAY
|
||||
import net.mamoe.mirai.internal.utils.io.ProtoBuf
|
||||
import kotlin.jvm.JvmField
|
||||
import net.mamoe.mirai.utils.ProtoBuf
|
||||
|
||||
@Serializable
|
||||
internal class MsgSvc : ProtoBuf {
|
||||
|
@ -12,8 +12,7 @@ package net.mamoe.mirai.internal.network.protocol.data.proto
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.protobuf.ProtoNumber
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.EMPTY_BYTE_ARRAY
|
||||
import net.mamoe.mirai.internal.utils.io.ProtoBuf
|
||||
import kotlin.jvm.JvmField
|
||||
import net.mamoe.mirai.utils.ProtoBuf
|
||||
|
||||
internal class MsgTransmit : ProtoBuf {
|
||||
@Serializable
|
||||
|
@ -12,8 +12,7 @@ package net.mamoe.mirai.internal.network.protocol.data.proto
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.protobuf.ProtoNumber
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.EMPTY_BYTE_ARRAY
|
||||
import net.mamoe.mirai.internal.utils.io.ProtoBuf
|
||||
import kotlin.jvm.JvmField
|
||||
import net.mamoe.mirai.utils.ProtoBuf
|
||||
|
||||
@Serializable
|
||||
internal class MultiMsg : ProtoBuf {
|
||||
|
@ -12,8 +12,7 @@ package net.mamoe.mirai.internal.network.protocol.data.proto
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.protobuf.ProtoNumber
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.EMPTY_BYTE_ARRAY
|
||||
import net.mamoe.mirai.internal.utils.io.ProtoBuf
|
||||
import kotlin.jvm.JvmField
|
||||
import net.mamoe.mirai.utils.ProtoBuf
|
||||
|
||||
@Serializable
|
||||
internal class Oidb0x8a0 : ProtoBuf {
|
||||
|
@ -14,7 +14,7 @@ package net.mamoe.mirai.internal.network.protocol.data.proto
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.protobuf.ProtoNumber
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.EMPTY_BYTE_ARRAY
|
||||
import net.mamoe.mirai.internal.utils.io.ProtoBuf
|
||||
import net.mamoe.mirai.utils.ProtoBuf
|
||||
|
||||
@Serializable
|
||||
internal class Oidb0x769 : ProtoBuf {
|
||||
|
@ -12,8 +12,7 @@ package net.mamoe.mirai.internal.network.protocol.data.proto
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.protobuf.ProtoNumber
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.EMPTY_BYTE_ARRAY
|
||||
import net.mamoe.mirai.internal.utils.io.ProtoBuf
|
||||
import kotlin.jvm.JvmField
|
||||
import net.mamoe.mirai.utils.ProtoBuf
|
||||
|
||||
@Serializable
|
||||
internal class MsgOnlinePush {
|
||||
|
@ -12,7 +12,7 @@ package net.mamoe.mirai.internal.network.protocol.data.proto
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.protobuf.ProtoNumber
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.EMPTY_BYTE_ARRAY
|
||||
import net.mamoe.mirai.internal.utils.io.ProtoBuf
|
||||
import net.mamoe.mirai.utils.ProtoBuf
|
||||
|
||||
internal class Generalflags : ProtoBuf {
|
||||
@Serializable
|
||||
|
@ -11,8 +11,7 @@ package net.mamoe.mirai.internal.network.protocol.data.proto
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.protobuf.ProtoNumber
|
||||
import net.mamoe.mirai.internal.utils.io.ProtoBuf
|
||||
import kotlin.jvm.JvmField
|
||||
import net.mamoe.mirai.utils.ProtoBuf
|
||||
|
||||
internal class StatSvcGetOnline {
|
||||
@Serializable
|
||||
|
@ -12,8 +12,7 @@ package net.mamoe.mirai.internal.network.protocol.data.proto
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.protobuf.ProtoNumber
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.EMPTY_BYTE_ARRAY
|
||||
import net.mamoe.mirai.internal.utils.io.ProtoBuf
|
||||
import kotlin.jvm.JvmField
|
||||
import net.mamoe.mirai.utils.ProtoBuf
|
||||
|
||||
internal class QPayReminderMsg : ProtoBuf {
|
||||
@Serializable
|
||||
|
@ -11,8 +11,7 @@ package net.mamoe.mirai.internal.network.protocol.data.proto
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.protobuf.ProtoNumber
|
||||
import net.mamoe.mirai.internal.utils.io.ProtoBuf
|
||||
import kotlin.jvm.JvmField
|
||||
import net.mamoe.mirai.utils.ProtoBuf
|
||||
import kotlin.math.absoluteValue
|
||||
import kotlin.random.Random
|
||||
|
||||
|
@ -16,8 +16,7 @@ import kotlinx.serialization.protobuf.ProtoIntegerType
|
||||
import kotlinx.serialization.protobuf.ProtoNumber
|
||||
import kotlinx.serialization.protobuf.ProtoType
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.EMPTY_BYTE_ARRAY
|
||||
import net.mamoe.mirai.internal.utils.io.ProtoBuf
|
||||
import kotlin.jvm.JvmField
|
||||
import net.mamoe.mirai.utils.ProtoBuf
|
||||
|
||||
@Serializable
|
||||
internal class SubMsgType0x43 : ProtoBuf {
|
||||
|
@ -16,7 +16,7 @@ import kotlinx.serialization.protobuf.ProtoIntegerType
|
||||
import kotlinx.serialization.protobuf.ProtoNumber
|
||||
import kotlinx.serialization.protobuf.ProtoType
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.EMPTY_BYTE_ARRAY
|
||||
import net.mamoe.mirai.internal.utils.io.ProtoBuf
|
||||
import net.mamoe.mirai.utils.ProtoBuf
|
||||
|
||||
|
||||
@Serializable
|
||||
|
@ -16,8 +16,8 @@ import kotlinx.io.core.writeFully
|
||||
import net.mamoe.mirai.internal.network.QQAndroidClient
|
||||
import net.mamoe.mirai.internal.utils.crypto.ECDH
|
||||
import net.mamoe.mirai.internal.utils.crypto.ECDHKeyPair
|
||||
import net.mamoe.mirai.internal.utils.io.encryptAndWrite
|
||||
import net.mamoe.mirai.internal.utils.io.writeShortLVByteArray
|
||||
import net.mamoe.mirai.utils.encryptAndWrite
|
||||
import net.mamoe.mirai.utils.writeShortLVByteArray
|
||||
|
||||
internal interface EncryptMethod {
|
||||
val id: Int
|
||||
|
@ -15,9 +15,9 @@ import kotlinx.io.core.ByteReadPacket
|
||||
import kotlinx.io.core.buildPacket
|
||||
import kotlinx.io.core.writeFully
|
||||
import net.mamoe.mirai.internal.network.QQAndroidClient
|
||||
import net.mamoe.mirai.internal.utils.io.encryptAndWrite
|
||||
import net.mamoe.mirai.internal.utils.io.writeHex
|
||||
import net.mamoe.mirai.internal.utils.io.writeIntLVPacket
|
||||
import net.mamoe.mirai.utils.encryptAndWrite
|
||||
import net.mamoe.mirai.utils.writeHex
|
||||
import net.mamoe.mirai.utils.writeIntLVPacket
|
||||
|
||||
internal class OutgoingPacket constructor(
|
||||
name: String?,
|
||||
|
@ -27,12 +27,6 @@ import net.mamoe.mirai.internal.network.protocol.packet.login.WtLogin
|
||||
import net.mamoe.mirai.internal.network.readUShortLVByteArray
|
||||
import net.mamoe.mirai.internal.utils.crypto.TEA
|
||||
import net.mamoe.mirai.internal.utils.crypto.adjustToPublicKey
|
||||
import net.mamoe.mirai.internal.utils.io.readPacketExact
|
||||
import net.mamoe.mirai.internal.utils.io.readString
|
||||
import net.mamoe.mirai.internal.utils.io.useBytes
|
||||
import net.mamoe.mirai.internal.utils.io.withUse
|
||||
import net.mamoe.mirai.internal.utils.toReadPacket
|
||||
import net.mamoe.mirai.internal.utils.toUHexString
|
||||
import net.mamoe.mirai.utils.*
|
||||
|
||||
internal sealed class PacketFactory<TPacket : Packet?> {
|
||||
|
@ -17,10 +17,7 @@ import kotlinx.io.core.toByteArray
|
||||
import kotlinx.io.core.writeFully
|
||||
import net.mamoe.mirai.internal.network.protocol.LoginType
|
||||
import net.mamoe.mirai.internal.utils.NetworkType
|
||||
import net.mamoe.mirai.internal.utils.io.*
|
||||
import net.mamoe.mirai.utils.currentTimeMillis
|
||||
import net.mamoe.mirai.utils.md5
|
||||
import net.mamoe.mirai.utils.toByteArray
|
||||
import net.mamoe.mirai.utils.*
|
||||
import kotlin.random.Random
|
||||
|
||||
/**
|
||||
|
@ -27,13 +27,13 @@ import net.mamoe.mirai.internal.network.protocol.packet.OutgoingPacketFactory
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.PacketLogger
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.buildOutgoingUniPacket
|
||||
import net.mamoe.mirai.internal.utils._miraiContentToString
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.readProtoBuf
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.toByteArray
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.writeProtoBuf
|
||||
import net.mamoe.mirai.message.data.ForwardMessage
|
||||
import net.mamoe.mirai.message.data.asMessageChain
|
||||
import net.mamoe.mirai.utils.gzip
|
||||
import net.mamoe.mirai.utils.md5
|
||||
import net.mamoe.mirai.utils.serialization.readProtoBuf
|
||||
import net.mamoe.mirai.utils.serialization.toByteArray
|
||||
import net.mamoe.mirai.utils.serialization.writeProtoBuf
|
||||
|
||||
internal class MessageValidationData(
|
||||
val data: ByteArray,
|
||||
|
@ -25,8 +25,8 @@ import net.mamoe.mirai.internal.network.protocol.data.proto.Structmsg
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.OutgoingPacketFactory
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.buildOutgoingUniPacket
|
||||
import net.mamoe.mirai.internal.utils._miraiContentToString
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.loadAs
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.writeProtoBuf
|
||||
import net.mamoe.mirai.utils.serialization.loadAs
|
||||
import net.mamoe.mirai.utils.serialization.writeProtoBuf
|
||||
|
||||
internal class NewContact {
|
||||
|
||||
|
@ -19,9 +19,9 @@ import net.mamoe.mirai.internal.network.protocol.data.proto.OidbSso
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.OutgoingPacket
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.OutgoingPacketFactory
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.buildOutgoingUniPacket
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.loadAs
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.toByteArray
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.writeProtoBuf
|
||||
import net.mamoe.mirai.utils.serialization.loadAs
|
||||
import net.mamoe.mirai.utils.serialization.toByteArray
|
||||
import net.mamoe.mirai.utils.serialization.writeProtoBuf
|
||||
|
||||
internal object NudgePacket : OutgoingPacketFactory<NudgePacket.Response>("OidbSvc.0xed3") {
|
||||
override suspend fun ByteReadPacket.decode(bot: QQAndroidBot): Response {
|
||||
|
@ -20,10 +20,10 @@ import net.mamoe.mirai.internal.network.protocol.data.proto.MsgSvc
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.OutgoingPacket
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.OutgoingPacketFactory
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.buildOutgoingUniPacket
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.readProtoBuf
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.toByteArray
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.writeProtoBuf
|
||||
import net.mamoe.mirai.utils.hexToBytes
|
||||
import net.mamoe.mirai.utils.serialization.readProtoBuf
|
||||
import net.mamoe.mirai.utils.serialization.toByteArray
|
||||
import net.mamoe.mirai.utils.serialization.writeProtoBuf
|
||||
|
||||
internal class PbMessageSvc {
|
||||
object PbMsgWithDraw : OutgoingPacketFactory<PbMsgWithDraw.Response>(
|
||||
|
@ -26,8 +26,8 @@ import net.mamoe.mirai.internal.network.protocol.data.proto.*
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.OutgoingPacket
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.OutgoingPacketFactory
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.buildOutgoingUniPacket
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.*
|
||||
import net.mamoe.mirai.utils.daysToSeconds
|
||||
import net.mamoe.mirai.utils.serialization.*
|
||||
import net.mamoe.mirai.data.GroupInfo as MiraiGroupInfo
|
||||
|
||||
@OptIn(LowLevelApi::class)
|
||||
|
@ -18,8 +18,8 @@ import net.mamoe.mirai.internal.network.protocol.packet.OutgoingPacket
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.OutgoingPacketFactory
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.buildOutgoingUniPacket
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.chat.toLongUnsigned
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.readProtoBuf
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.writeProtoBuf
|
||||
import net.mamoe.mirai.utils.serialization.readProtoBuf
|
||||
import net.mamoe.mirai.utils.serialization.writeProtoBuf
|
||||
import kotlin.random.Random
|
||||
import kotlin.random.nextInt
|
||||
|
||||
|
@ -18,8 +18,8 @@ import net.mamoe.mirai.internal.network.protocol.data.proto.GetImgUrlReq
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.OutgoingPacket
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.OutgoingPacketFactory
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.buildOutgoingUniPacket
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.readProtoBuf
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.writeProtoBuf
|
||||
import net.mamoe.mirai.utils.serialization.readProtoBuf
|
||||
import net.mamoe.mirai.utils.serialization.writeProtoBuf
|
||||
|
||||
internal class LongConn {
|
||||
|
||||
|
@ -19,7 +19,7 @@ import net.mamoe.mirai.internal.network.protocol.data.proto.MsgComm
|
||||
import net.mamoe.mirai.internal.network.protocol.data.proto.MsgSvc
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.OutgoingPacketFactory
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.buildOutgoingUniPacket
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.writeProtoBuf
|
||||
import net.mamoe.mirai.utils.serialization.writeProtoBuf
|
||||
|
||||
internal object MessageSvcPbDeleteMsg : OutgoingPacketFactory<Nothing?>("MessageSvc.PbDeleteMsg") {
|
||||
|
||||
|
@ -46,15 +46,12 @@ import net.mamoe.mirai.internal.network.protocol.packet.chat.NewContact
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.chat.toLongUnsigned
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.list.FriendList
|
||||
import net.mamoe.mirai.internal.utils.*
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.loadAs
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.readProtoBuf
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.writeProtoBuf
|
||||
import net.mamoe.mirai.message.data.PlainText
|
||||
import net.mamoe.mirai.message.data.buildMessageChain
|
||||
import net.mamoe.mirai.utils.cast
|
||||
import net.mamoe.mirai.utils.debug
|
||||
import net.mamoe.mirai.utils.toInt
|
||||
import net.mamoe.mirai.utils.warning
|
||||
import net.mamoe.mirai.utils.*
|
||||
import net.mamoe.mirai.utils.serialization.loadAs
|
||||
import net.mamoe.mirai.utils.serialization.readProtoBuf
|
||||
import net.mamoe.mirai.utils.serialization.writeProtoBuf
|
||||
import kotlin.random.Random
|
||||
|
||||
|
||||
|
@ -32,10 +32,10 @@ import net.mamoe.mirai.internal.network.protocol.packet.EMPTY_BYTE_ARRAY
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.OutgoingPacket
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.OutgoingPacketFactory
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.buildOutgoingUniPacket
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.readProtoBuf
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.writeProtoBuf
|
||||
import net.mamoe.mirai.message.data.*
|
||||
import net.mamoe.mirai.utils.currentTimeSeconds
|
||||
import net.mamoe.mirai.utils.serialization.readProtoBuf
|
||||
import net.mamoe.mirai.utils.serialization.writeProtoBuf
|
||||
import java.util.concurrent.atomic.AtomicReference
|
||||
import kotlin.contracts.InvocationKind
|
||||
import kotlin.contracts.contract
|
||||
|
@ -14,7 +14,7 @@ import net.mamoe.mirai.event.events.BotOfflineEvent
|
||||
import net.mamoe.mirai.internal.QQAndroidBot
|
||||
import net.mamoe.mirai.internal.network.protocol.data.jce.RequestPushForceOffline
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.OutgoingPacketFactory
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.readUniPacket
|
||||
import net.mamoe.mirai.utils.serialization.readUniPacket
|
||||
|
||||
|
||||
/**
|
||||
|
@ -17,7 +17,7 @@ import net.mamoe.mirai.internal.network.protocol.data.jce.RequestPushNotify
|
||||
import net.mamoe.mirai.internal.network.protocol.data.proto.MsgSvc
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.IncomingPacketFactory
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.OutgoingPacket
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.readUniPacket
|
||||
import net.mamoe.mirai.utils.serialization.readUniPacket
|
||||
|
||||
|
||||
/**
|
||||
|
@ -33,11 +33,9 @@ import net.mamoe.mirai.internal.network.protocol.data.proto.MsgOnlinePush
|
||||
import net.mamoe.mirai.internal.network.protocol.data.proto.Oidb0x8fc
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.IncomingPacketFactory
|
||||
import net.mamoe.mirai.internal.utils._miraiContentToString
|
||||
import net.mamoe.mirai.internal.utils.encodeToBase64
|
||||
import net.mamoe.mirai.internal.utils.encodeToString
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.loadAs
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.readProtoBuf
|
||||
import net.mamoe.mirai.utils.warning
|
||||
import net.mamoe.mirai.utils.*
|
||||
import net.mamoe.mirai.utils.serialization.loadAs
|
||||
import net.mamoe.mirai.utils.serialization.readProtoBuf
|
||||
|
||||
/**
|
||||
* 接受群消息
|
||||
|
@ -36,8 +36,8 @@ import net.mamoe.mirai.internal.network.protocol.packet.IncomingPacketFactory
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.OutgoingPacket
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.buildResponseUniPacket
|
||||
import net.mamoe.mirai.internal.utils._miraiContentToString
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.readProtoBuf
|
||||
import net.mamoe.mirai.internal.utils.read
|
||||
import net.mamoe.mirai.utils.*
|
||||
import net.mamoe.mirai.utils.serialization.readProtoBuf
|
||||
|
||||
|
||||
internal object OnlinePushPbPushTransMsg :
|
||||
|
@ -45,13 +45,8 @@ import net.mamoe.mirai.internal.network.protocol.packet.IncomingPacketFactory
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.OutgoingPacket
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.buildResponseUniPacket
|
||||
import net.mamoe.mirai.internal.utils.*
|
||||
import net.mamoe.mirai.internal.utils.io.ProtoBuf
|
||||
import net.mamoe.mirai.internal.utils.io.readString
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.*
|
||||
import net.mamoe.mirai.utils.currentTimeSeconds
|
||||
import net.mamoe.mirai.utils.debug
|
||||
import net.mamoe.mirai.utils.mapToIntArray
|
||||
import net.mamoe.mirai.utils.toUHexString
|
||||
import net.mamoe.mirai.utils.*
|
||||
import net.mamoe.mirai.utils.serialization.*
|
||||
|
||||
|
||||
//0C 01 B1 89 BE 09 5E 3D 72 A6 00 01 73 68 FC 06 00 00 00 3C
|
||||
|
@ -18,9 +18,9 @@ import net.mamoe.mirai.internal.network.protocol.data.proto.Cmd0x388
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.OutgoingPacket
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.OutgoingPacketFactory
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.buildOutgoingUniPacket
|
||||
import net.mamoe.mirai.internal.utils.encodeToString
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.readProtoBuf
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.writeProtoBuf
|
||||
import net.mamoe.mirai.utils.encodeToString
|
||||
import net.mamoe.mirai.utils.serialization.readProtoBuf
|
||||
import net.mamoe.mirai.utils.serialization.writeProtoBuf
|
||||
|
||||
internal class PttStore {
|
||||
object GroupPttUp : OutgoingPacketFactory<GroupPttUp.Response>("PttStore.GroupPttUp") {
|
||||
|
@ -19,10 +19,10 @@ import net.mamoe.mirai.internal.network.protocol.packet.EMPTY_BYTE_ARRAY
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.OutgoingPacket
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.OutgoingPacketFactory
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.buildOutgoingUniPacket
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.jceRequestSBuffer
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.readUniPacket
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.toByteArray
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.writeJceStruct
|
||||
import net.mamoe.mirai.utils.serialization.jceRequestSBuffer
|
||||
import net.mamoe.mirai.utils.serialization.readUniPacket
|
||||
import net.mamoe.mirai.utils.serialization.toByteArray
|
||||
import net.mamoe.mirai.utils.serialization.writeJceStruct
|
||||
|
||||
|
||||
internal class FriendList {
|
||||
|
@ -19,9 +19,9 @@ import net.mamoe.mirai.internal.network.protocol.data.jce.RequestPacket
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.OutgoingPacket
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.OutgoingPacketFactory
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.buildOutgoingUniPacket
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.jceRequestSBuffer
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.readUniPacket
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.writeJceStruct
|
||||
import net.mamoe.mirai.utils.serialization.jceRequestSBuffer
|
||||
import net.mamoe.mirai.utils.serialization.readUniPacket
|
||||
import net.mamoe.mirai.utils.serialization.writeJceStruct
|
||||
import net.mamoe.mirai.utils.toByteArray
|
||||
|
||||
internal class ProfileService {
|
||||
|
@ -22,13 +22,8 @@ import net.mamoe.mirai.internal.network.protocol.data.jce.RequestPacket
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.IncomingPacketFactory
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.OutgoingPacket
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.buildResponseUniPacket
|
||||
import net.mamoe.mirai.internal.utils.io.ProtoBuf
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.*
|
||||
import net.mamoe.mirai.internal.utils.io.withUse
|
||||
import net.mamoe.mirai.internal.utils.toReadPacket
|
||||
import net.mamoe.mirai.utils.ByteArrayPool
|
||||
import net.mamoe.mirai.utils.hexToBytes
|
||||
import net.mamoe.mirai.utils.verbose
|
||||
import net.mamoe.mirai.utils.*
|
||||
import net.mamoe.mirai.utils.serialization.*
|
||||
import net.mamoe.mirai.internal.network.protocol.data.jce.PushReq as PushReqJceStruct
|
||||
|
||||
|
||||
|
@ -33,11 +33,11 @@ import net.mamoe.mirai.internal.network.protocol.data.proto.StatSvcGetOnline
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.*
|
||||
import net.mamoe.mirai.internal.utils.NetworkType
|
||||
import net.mamoe.mirai.internal.utils._miraiContentToString
|
||||
import net.mamoe.mirai.internal.utils.encodeToString
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.*
|
||||
import net.mamoe.mirai.utils.currentTimeMillis
|
||||
import net.mamoe.mirai.internal.utils.toReadPacket
|
||||
import net.mamoe.mirai.utils.encodeToString
|
||||
import net.mamoe.mirai.utils.localIpAddress
|
||||
import net.mamoe.mirai.utils.serialization.*
|
||||
import net.mamoe.mirai.utils.toReadPacket
|
||||
|
||||
@Suppress("EnumEntryName", "unused")
|
||||
internal enum class RegPushReason {
|
||||
|
@ -15,10 +15,11 @@ import net.mamoe.mirai.internal.QQAndroidBot
|
||||
import net.mamoe.mirai.internal.network.*
|
||||
import net.mamoe.mirai.internal.network.protocol.LoginType
|
||||
import net.mamoe.mirai.internal.network.protocol.packet.*
|
||||
import net.mamoe.mirai.internal.utils.*
|
||||
import net.mamoe.mirai.internal.utils.GuidSource
|
||||
import net.mamoe.mirai.internal.utils.MacOrAndroidIdChangeFlag
|
||||
import net.mamoe.mirai.internal.utils._miraiContentToString
|
||||
import net.mamoe.mirai.internal.utils.crypto.TEA
|
||||
import net.mamoe.mirai.internal.utils.guidFlag
|
||||
import net.mamoe.mirai.internal.utils.io.*
|
||||
import net.mamoe.mirai.utils.*
|
||||
|
||||
internal class WtLogin {
|
||||
|
@ -1,108 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019-2020 Mamoe Technologies and contributors.
|
||||
*
|
||||
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
|
||||
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
|
||||
*
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
@file:Suppress("EXPERIMENTAL_UNSIGNED_LITERALS", "NOTHING_TO_INLINE", "INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
||||
@file:JvmMultifileClass
|
||||
@file:JvmName("Utils")
|
||||
|
||||
package net.mamoe.mirai.internal.utils
|
||||
|
||||
import kotlinx.io.charsets.Charset
|
||||
import kotlinx.io.charsets.Charsets
|
||||
import kotlinx.io.core.ByteReadPacket
|
||||
import kotlinx.io.core.String
|
||||
import net.mamoe.mirai.internal.utils.io.withUse
|
||||
import net.mamoe.mirai.utils.checkOffsetAndLength
|
||||
import java.util.*
|
||||
import kotlin.contracts.InvocationKind
|
||||
import kotlin.contracts.contract
|
||||
|
||||
|
||||
@JvmOverloads
|
||||
@Suppress("DuplicatedCode") // false positive. foreach is not common to UByteArray and ByteArray
|
||||
internal fun List<Byte>.toUHexString(separator: String = " ", offset: Int = 0, length: Int = this.size - offset): String {
|
||||
require(offset >= 0) { "offset shouldn't be negative: $offset" }
|
||||
require(length >= 0) { "length shouldn't be negative: $length" }
|
||||
require(offset + length <= this.size) { "offset ($offset) + length ($length) > array.size (${this.size})" }
|
||||
|
||||
if (length == 0) {
|
||||
return ""
|
||||
}
|
||||
val lastIndex = offset + length
|
||||
return buildString(length * 2) {
|
||||
this@toUHexString.forEachIndexed { index, it ->
|
||||
if (index in offset until lastIndex) {
|
||||
var ret = it.toUByte().toString(16).toUpperCase()
|
||||
if (ret.length == 1) ret = "0$ret"
|
||||
append(ret)
|
||||
if (index < lastIndex - 1) append(separator)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@kotlin.internal.LowPriorityInOverloadResolution
|
||||
@JvmOverloads
|
||||
@Suppress("DuplicatedCode") // false positive. foreach is not common to UByteArray and ByteArray
|
||||
internal fun ByteArray.toUHexString(separator: String = " ", offset: Int = 0, length: Int = this.size - offset): String {
|
||||
this.checkOffsetAndLength(offset, length)
|
||||
if (length == 0) {
|
||||
return ""
|
||||
}
|
||||
val lastIndex = offset + length
|
||||
return buildString(length * 2) {
|
||||
this@toUHexString.forEachIndexed { index, it ->
|
||||
if (index in offset until lastIndex) {
|
||||
var ret = it.toUByte().toString(16).toUpperCase()
|
||||
if (ret.length == 1) ret = "0$ret"
|
||||
append(ret)
|
||||
if (index < lastIndex - 1) append(separator)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@JvmSynthetic
|
||||
@Suppress("DuplicatedCode") // false positive. foreach is not common to UByteArray and ByteArray
|
||||
@ExperimentalUnsignedTypes
|
||||
internal fun UByteArray.toUHexString(separator: String = " ", offset: Int = 0, length: Int = this.size - offset): String {
|
||||
if (length == 0) {
|
||||
return ""
|
||||
}
|
||||
val lastIndex = offset + length
|
||||
return buildString(length * 2) {
|
||||
this@toUHexString.forEachIndexed { index, it ->
|
||||
if (index in offset until lastIndex) {
|
||||
var ret = it.toByte().toUByte().toString(16).toUpperCase()
|
||||
if (ret.length == 1) ret = "0$ret"
|
||||
append(ret)
|
||||
if (index < lastIndex - 1) append(separator)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
internal inline fun ByteArray.encodeToString(offset: Int = 0, charset: Charset = Charsets.UTF_8): String =
|
||||
String(this, charset = charset, offset = offset, length = this.size - offset)
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
internal inline fun ByteArray.encodeToBase64(): String =
|
||||
Base64.getEncoder().encodeToString(this)
|
||||
|
||||
@PublishedApi
|
||||
internal inline fun ByteArray.toReadPacket(offset: Int = 0, length: Int = this.size - offset) =
|
||||
ByteReadPacket(this, offset = offset, length = length)
|
||||
|
||||
internal inline fun <R> ByteArray.read(t: ByteReadPacket.() -> R): R {
|
||||
contract {
|
||||
callsInPlace(t, InvocationKind.EXACTLY_ONCE)
|
||||
}
|
||||
return this.toReadPacket().withUse(t)
|
||||
}
|
@ -7,6 +7,6 @@
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
package net.mamoe.mirai.internal.utils.io
|
||||
package net.mamoe.mirai.utils
|
||||
|
||||
internal interface JceStruct
|
@ -7,7 +7,7 @@
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
package net.mamoe.mirai.internal.utils.io
|
||||
package net.mamoe.mirai.utils
|
||||
|
||||
/**
|
||||
* 仅有标示作用
|
||||
|
@ -11,7 +11,7 @@
|
||||
@file:JvmMultifileClass
|
||||
@file:JvmName("Utils")
|
||||
|
||||
package net.mamoe.mirai.internal.utils.io
|
||||
package net.mamoe.mirai.utils
|
||||
|
||||
import kotlinx.io.core.*
|
||||
import net.mamoe.mirai.internal.utils.coerceAtMostOrFail
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
@file:Suppress("DEPRECATION_ERROR")
|
||||
|
||||
package net.mamoe.mirai.internal.utils.io.serialization
|
||||
package net.mamoe.mirai.utils.serialization
|
||||
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.builtins.ByteArraySerializer
|
||||
@ -26,8 +26,8 @@ import kotlinx.serialization.modules.SerializersModule
|
||||
import kotlinx.serialization.protobuf.ProtoBuf
|
||||
import kotlinx.serialization.protobuf.ProtoIntegerType
|
||||
import kotlinx.serialization.protobuf.ProtoType
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.ProtoBufWithNullableSupport.Varint.encodeVarint
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.tars.TarsId
|
||||
import net.mamoe.mirai.utils.serialization.ProtoBufWithNullableSupport.Varint.encodeVarint
|
||||
import net.mamoe.mirai.utils.serialization.tars.TarsId
|
||||
import java.io.ByteArrayOutputStream
|
||||
import java.nio.ByteBuffer
|
||||
import java.nio.ByteOrder
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
@file:Suppress("MemberVisibilityCanBePrivate", "unused")
|
||||
|
||||
package net.mamoe.mirai.internal.utils.io.serialization.tars
|
||||
package net.mamoe.mirai.utils.serialization.tars
|
||||
|
||||
import kotlinx.io.charsets.Charset
|
||||
import kotlinx.io.charsets.Charsets
|
||||
@ -17,10 +17,9 @@ import kotlinx.io.core.*
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.modules.EmptySerializersModule
|
||||
import kotlinx.serialization.modules.SerializersModule
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.tars.internal.TarsDecoder
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.tars.internal.TarsInput
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.tars.internal.TarsOld
|
||||
import kotlin.jvm.JvmStatic
|
||||
import net.mamoe.mirai.utils.serialization.tars.internal.TarsDecoder
|
||||
import net.mamoe.mirai.utils.serialization.tars.internal.TarsInput
|
||||
import net.mamoe.mirai.utils.serialization.tars.internal.TarsOld
|
||||
|
||||
/**
|
||||
* The main entry point to work with Tars serialization.
|
||||
|
@ -7,7 +7,7 @@
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
package net.mamoe.mirai.internal.utils.io.serialization.tars
|
||||
package net.mamoe.mirai.utils.serialization.tars
|
||||
|
||||
import kotlinx.serialization.ExperimentalSerializationApi
|
||||
import kotlinx.serialization.SerialInfo
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
@file:Suppress("PrivatePropertyName")
|
||||
|
||||
package net.mamoe.mirai.internal.utils.io.serialization.tars.internal
|
||||
package net.mamoe.mirai.utils.serialization.tars.internal
|
||||
|
||||
import kotlinx.serialization.ExperimentalSerializationApi
|
||||
import kotlinx.serialization.InternalSerializationApi
|
||||
@ -18,8 +18,8 @@ import kotlinx.serialization.encoding.AbstractDecoder
|
||||
import kotlinx.serialization.encoding.CompositeDecoder
|
||||
import kotlinx.serialization.internal.TaggedDecoder
|
||||
import kotlinx.serialization.modules.SerializersModule
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.tars.Tars
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.tars.TarsId
|
||||
import net.mamoe.mirai.utils.serialization.tars.Tars
|
||||
import net.mamoe.mirai.utils.serialization.tars.TarsId
|
||||
|
||||
|
||||
@OptIn(InternalSerializationApi::class, ExperimentalSerializationApi::class)
|
||||
|
@ -7,11 +7,11 @@
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
package net.mamoe.mirai.internal.utils.io.serialization.tars.internal
|
||||
package net.mamoe.mirai.utils.serialization.tars.internal
|
||||
|
||||
import kotlinx.io.charsets.Charset
|
||||
import kotlinx.io.core.*
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.tars.Tars
|
||||
import net.mamoe.mirai.utils.serialization.tars.Tars
|
||||
|
||||
|
||||
/**
|
||||
|
@ -7,7 +7,7 @@
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
package net.mamoe.mirai.internal.utils.io.serialization.tars.internal
|
||||
package net.mamoe.mirai.utils.serialization.tars.internal
|
||||
|
||||
import kotlinx.io.charsets.Charset
|
||||
import kotlinx.io.charsets.Charsets
|
||||
@ -24,22 +24,22 @@ import kotlinx.serialization.internal.MapLikeSerializer
|
||||
import kotlinx.serialization.internal.TaggedEncoder
|
||||
import kotlinx.serialization.modules.EmptySerializersModule
|
||||
import kotlinx.serialization.modules.SerializersModule
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.tars.Tars.Companion.BYTE
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.tars.Tars.Companion.DOUBLE
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.tars.Tars.Companion.FLOAT
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.tars.Tars.Companion.INT
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.tars.Tars.Companion.LIST
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.tars.Tars.Companion.LONG
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.tars.Tars.Companion.MAP
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.tars.Tars.Companion.SHORT
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.tars.Tars.Companion.SIMPLE_LIST
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.tars.Tars.Companion.STRING1
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.tars.Tars.Companion.STRING4
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.tars.Tars.Companion.STRUCT_BEGIN
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.tars.Tars.Companion.STRUCT_END
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.tars.Tars.Companion.Tars_MAX_STRING_LENGTH
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.tars.Tars.Companion.ZERO_TYPE
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.tars.TarsId
|
||||
import net.mamoe.mirai.utils.serialization.tars.Tars.Companion.BYTE
|
||||
import net.mamoe.mirai.utils.serialization.tars.Tars.Companion.DOUBLE
|
||||
import net.mamoe.mirai.utils.serialization.tars.Tars.Companion.FLOAT
|
||||
import net.mamoe.mirai.utils.serialization.tars.Tars.Companion.INT
|
||||
import net.mamoe.mirai.utils.serialization.tars.Tars.Companion.LIST
|
||||
import net.mamoe.mirai.utils.serialization.tars.Tars.Companion.LONG
|
||||
import net.mamoe.mirai.utils.serialization.tars.Tars.Companion.MAP
|
||||
import net.mamoe.mirai.utils.serialization.tars.Tars.Companion.SHORT
|
||||
import net.mamoe.mirai.utils.serialization.tars.Tars.Companion.SIMPLE_LIST
|
||||
import net.mamoe.mirai.utils.serialization.tars.Tars.Companion.STRING1
|
||||
import net.mamoe.mirai.utils.serialization.tars.Tars.Companion.STRING4
|
||||
import net.mamoe.mirai.utils.serialization.tars.Tars.Companion.STRUCT_BEGIN
|
||||
import net.mamoe.mirai.utils.serialization.tars.Tars.Companion.STRUCT_END
|
||||
import net.mamoe.mirai.utils.serialization.tars.Tars.Companion.Tars_MAX_STRING_LENGTH
|
||||
import net.mamoe.mirai.utils.serialization.tars.Tars.Companion.ZERO_TYPE
|
||||
import net.mamoe.mirai.utils.serialization.tars.TarsId
|
||||
|
||||
@OptIn(ExperimentalSerializationApi::class)
|
||||
internal inline fun <reified A : Annotation> SerialDescriptor.findAnnotation(elementIndex: Int): A? {
|
||||
|
@ -7,12 +7,12 @@
|
||||
* https://github.com/mamoe/mirai/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
package net.mamoe.mirai.internal.utils.io.serialization.tars.internal
|
||||
package net.mamoe.mirai.utils.serialization.tars.internal
|
||||
|
||||
import kotlinx.io.core.Output
|
||||
import kotlinx.serialization.ExperimentalSerializationApi
|
||||
import kotlinx.serialization.descriptors.SerialDescriptor
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.tars.Tars
|
||||
import net.mamoe.mirai.utils.serialization.tars.Tars
|
||||
|
||||
|
||||
internal abstract class TarsTag {
|
||||
|
@ -10,7 +10,7 @@
|
||||
@file:JvmName("SerializationUtils")
|
||||
@file:JvmMultifileClass
|
||||
|
||||
package net.mamoe.mirai.internal.utils.io.serialization
|
||||
package net.mamoe.mirai.utils.serialization
|
||||
|
||||
import kotlinx.io.core.*
|
||||
import kotlinx.serialization.DeserializationStrategy
|
||||
@ -19,11 +19,11 @@ import kotlinx.serialization.descriptors.SerialDescriptor
|
||||
import net.mamoe.mirai.internal.network.protocol.data.jce.RequestDataVersion2
|
||||
import net.mamoe.mirai.internal.network.protocol.data.jce.RequestDataVersion3
|
||||
import net.mamoe.mirai.internal.network.protocol.data.jce.RequestPacket
|
||||
import net.mamoe.mirai.internal.utils.io.JceStruct
|
||||
import net.mamoe.mirai.internal.utils.io.ProtoBuf
|
||||
import net.mamoe.mirai.internal.utils.io.readPacketExact
|
||||
import net.mamoe.mirai.internal.utils.io.serialization.tars.Tars
|
||||
import net.mamoe.mirai.internal.utils.read
|
||||
import net.mamoe.mirai.utils.JceStruct
|
||||
import net.mamoe.mirai.utils.ProtoBuf
|
||||
import net.mamoe.mirai.utils.read
|
||||
import net.mamoe.mirai.utils.readPacketExact
|
||||
import net.mamoe.mirai.utils.serialization.tars.Tars
|
||||
|
||||
internal fun <T : JceStruct> ByteArray.loadWithUniPacket(
|
||||
deserializer: DeserializationStrategy<T>,
|
||||
|
@ -9,10 +9,7 @@
|
||||
package net.mamoe.mirai.internal.utils
|
||||
|
||||
import kotlinx.io.core.toByteArray
|
||||
import net.mamoe.mirai.utils.gzip
|
||||
import net.mamoe.mirai.utils.ungzip
|
||||
import net.mamoe.mirai.utils.unzip
|
||||
import net.mamoe.mirai.utils.zip
|
||||
import net.mamoe.mirai.utils.*
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user