mirror of
https://github.com/mamoe/mirai.git
synced 2025-03-26 07:20:09 +08:00
Use io.ktor.utils.io
than kotlinx.io
This commit is contained in:
parent
4018545d9e
commit
6a85769e0d
mirai-core-qqandroid/src
commonMain/kotlin/net/mamoe/mirai/qqandroid
ContactImpl.kt
io/serialization
message
network
commonTest/kotlin/test
jvmTest/kotlin
mirai-core/src
androidMain/kotlin/net/mamoe/mirai/utils
commonMain/kotlin/net.mamoe.mirai
jvmMain/kotlin/net/mamoe/mirai
@ -9,9 +9,9 @@
|
||||
|
||||
package net.mamoe.mirai.qqandroid
|
||||
|
||||
import io.ktor.utils.io.core.Closeable
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withTimeoutOrNull
|
||||
import kotlinx.io.core.Closeable
|
||||
import net.mamoe.mirai.contact.*
|
||||
import net.mamoe.mirai.data.*
|
||||
import net.mamoe.mirai.event.broadcast
|
||||
|
@ -9,8 +9,8 @@
|
||||
|
||||
package net.mamoe.mirai.qqandroid.io.serialization
|
||||
|
||||
import kotlinx.io.charsets.Charset
|
||||
import kotlinx.io.core.*
|
||||
import io.ktor.utils.io.charsets.Charset
|
||||
import io.ktor.utils.io.core.*
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.internal.*
|
||||
import kotlinx.serialization.modules.EmptyModule
|
||||
|
@ -12,7 +12,10 @@
|
||||
|
||||
package net.mamoe.mirai.qqandroid.io.serialization
|
||||
|
||||
import kotlinx.io.core.*
|
||||
import io.ktor.utils.io.core.BytePacketBuilder
|
||||
import io.ktor.utils.io.core.ByteReadPacket
|
||||
import io.ktor.utils.io.core.readBytes
|
||||
import io.ktor.utils.io.core.writeFully
|
||||
import kotlinx.serialization.DeserializationStrategy
|
||||
import kotlinx.serialization.SerialDescriptor
|
||||
import kotlinx.serialization.SerializationStrategy
|
||||
|
@ -9,10 +9,7 @@
|
||||
|
||||
package net.mamoe.mirai.qqandroid.message
|
||||
|
||||
import kotlinx.io.core.buildPacket
|
||||
import kotlinx.io.core.discardExact
|
||||
import kotlinx.io.core.readBytes
|
||||
import kotlinx.io.core.readUInt
|
||||
import io.ktor.utils.io.core.*
|
||||
import net.mamoe.mirai.contact.Member
|
||||
import net.mamoe.mirai.message.data.*
|
||||
import net.mamoe.mirai.qqandroid.network.protocol.data.proto.ImMsgBody
|
||||
|
@ -9,12 +9,12 @@
|
||||
|
||||
package net.mamoe.mirai.qqandroid.network
|
||||
|
||||
import io.ktor.utils.io.core.*
|
||||
import kotlinx.atomicfu.AtomicRef
|
||||
import kotlinx.atomicfu.atomic
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.sync.Mutex
|
||||
import kotlinx.coroutines.sync.withLock
|
||||
import kotlinx.io.core.*
|
||||
import net.mamoe.mirai.data.MultiPacket
|
||||
import net.mamoe.mirai.data.Packet
|
||||
import net.mamoe.mirai.event.*
|
||||
@ -128,9 +128,7 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler
|
||||
|
||||
is WtLogin.Login.LoginPacketResponse.Captcha -> when (response) {
|
||||
is WtLogin.Login.LoginPacketResponse.Captcha.Picture -> {
|
||||
var result = response.data.withUse {
|
||||
bot.configuration.loginSolver.onSolvePicCaptcha(bot, this.readBytes())
|
||||
}
|
||||
var result = bot.configuration.loginSolver.onSolvePicCaptcha(bot, response.data)
|
||||
if (result == null || result.length != 4) {
|
||||
//refresh captcha
|
||||
result = "ABCD"
|
||||
|
@ -11,9 +11,9 @@
|
||||
|
||||
package net.mamoe.mirai.qqandroid.network
|
||||
|
||||
import io.ktor.utils.io.core.*
|
||||
import kotlinx.atomicfu.AtomicInt
|
||||
import kotlinx.atomicfu.atomic
|
||||
import kotlinx.io.core.*
|
||||
import net.mamoe.mirai.BotAccount
|
||||
import net.mamoe.mirai.RawAccountIdUse
|
||||
import net.mamoe.mirai.data.OnlineStatus
|
||||
@ -313,7 +313,7 @@ internal class Pt4Token(data: ByteArray, creationTime: Long, expireTime: Long) :
|
||||
internal typealias PSKeyMap = MutableMap<String, PSKey>
|
||||
internal typealias Pt4TokenMap = MutableMap<String, Pt4Token>
|
||||
|
||||
internal inline fun Input.readUShortLVString(): String = kotlinx.io.core.String(this.readUShortLVByteArray())
|
||||
internal inline fun Input.readUShortLVString(): String = io.ktor.utils.io.core.String(this.readUShortLVByteArray())
|
||||
|
||||
internal inline fun Input.readUShortLVByteArray(): ByteArray = this.readBytes(this.readUShort().toInt())
|
||||
|
||||
|
@ -18,14 +18,14 @@ import io.ktor.http.content.OutgoingContent
|
||||
import io.ktor.http.userAgent
|
||||
import io.ktor.utils.io.ByteReadChannel
|
||||
import io.ktor.utils.io.copyAndClose
|
||||
import io.ktor.utils.io.core.Input
|
||||
import io.ktor.utils.io.core.readAvailable
|
||||
import io.ktor.utils.io.core.readInt
|
||||
import io.ktor.utils.io.core.use
|
||||
import io.ktor.utils.io.pool.useInstance
|
||||
import kotlinx.coroutines.InternalCoroutinesApi
|
||||
import kotlinx.coroutines.flow.collect
|
||||
import kotlinx.io.InputStream
|
||||
import kotlinx.io.core.Input
|
||||
import kotlinx.io.core.discardExact
|
||||
import kotlinx.io.core.readAvailable
|
||||
import kotlinx.io.core.use
|
||||
import kotlinx.io.pool.useInstance
|
||||
import net.mamoe.mirai.qqandroid.io.serialization.readProtoBuf
|
||||
import net.mamoe.mirai.qqandroid.network.QQAndroidClient
|
||||
import net.mamoe.mirai.qqandroid.network.protocol.data.proto.CSDataHighwayHead
|
||||
|
@ -12,10 +12,10 @@
|
||||
package net.mamoe.mirai.qqandroid.network.highway
|
||||
|
||||
import io.ktor.utils.io.ByteReadChannel
|
||||
import io.ktor.utils.io.core.*
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.io.InputStream
|
||||
import kotlinx.io.core.*
|
||||
import net.mamoe.mirai.qqandroid.io.serialization.toByteArray
|
||||
import net.mamoe.mirai.qqandroid.network.QQAndroidClient
|
||||
import net.mamoe.mirai.qqandroid.network.protocol.data.proto.CSDataHighwayHead
|
||||
|
@ -9,11 +9,9 @@
|
||||
|
||||
package net.mamoe.mirai.qqandroid.network.protocol.data.jce
|
||||
|
||||
import kotlinx.io.core.toByteArray
|
||||
import kotlinx.serialization.SerialId
|
||||
import kotlinx.serialization.Serializable
|
||||
import net.mamoe.mirai.qqandroid.io.JceStruct
|
||||
import net.mamoe.mirai.qqandroid.network.protocol.packet.EMPTY_BYTE_ARRAY
|
||||
|
||||
@Serializable
|
||||
internal class ModifyGroupCardReq(
|
||||
|
@ -0,0 +1,408 @@
|
||||
/*
|
||||
* Copyright 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("SpellCheckingInspection")
|
||||
|
||||
package net.mamoe.mirai.qqandroid.network.protocol.data.proto
|
||||
|
||||
import kotlinx.serialization.SerialId
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.protobuf.ProtoNumberType
|
||||
import kotlinx.serialization.protobuf.ProtoType
|
||||
import net.mamoe.mirai.qqandroid.io.ProtoBuf
|
||||
import net.mamoe.mirai.qqandroid.network.protocol.packet.EMPTY_BYTE_ARRAY
|
||||
|
||||
class GroupOpenSysMsg : ProtoBuf {
|
||||
@Serializable
|
||||
class LightApp(
|
||||
@SerialId(1) val app: String = "",
|
||||
@SerialId(2) val view: String = "",
|
||||
@SerialId(3) val desc: String = "",
|
||||
@SerialId(4) val prompt: String = "",
|
||||
@SerialId(5) val ver: String = "",
|
||||
@SerialId(6) val meta: String = "",
|
||||
@SerialId(7) val config: String = "",
|
||||
@SerialId(8) val source: Source? = null
|
||||
) : ProtoBuf
|
||||
|
||||
@Serializable
|
||||
class RichMsg(
|
||||
@SerialId(1) val title: String = "",
|
||||
@SerialId(2) val desc: String = "",
|
||||
@SerialId(3) val brief: String = "",
|
||||
@SerialId(4) val cover: String = "",
|
||||
@SerialId(5) val url: String = "",
|
||||
@SerialId(6) val source: Source? = null
|
||||
) : ProtoBuf
|
||||
|
||||
@Serializable
|
||||
class Sender(
|
||||
@SerialId(1) val uin: Long = 0L,
|
||||
@SerialId(2) val nick: String = "",
|
||||
@SerialId(3) val avatar: String = "",
|
||||
@SerialId(4) val url: String = ""
|
||||
) : ProtoBuf
|
||||
|
||||
@Serializable
|
||||
class Source(
|
||||
@SerialId(1) val name: String = "",
|
||||
@SerialId(2) val icon: String = "",
|
||||
@SerialId(3) val url: String = ""
|
||||
) : ProtoBuf
|
||||
|
||||
@Serializable
|
||||
class SysMsgBody(
|
||||
@SerialId(1) val groupId: Long = 0L,
|
||||
@SerialId(2) val appid: Long = 0L,
|
||||
@SerialId(3) val sender: Sender? = null,
|
||||
@SerialId(4) val msgType: Int = 0,
|
||||
@SerialId(5) val content: String = "",
|
||||
@SerialId(6) val richMsg: RichMsg? = null,
|
||||
@SerialId(7) val lightApp: LightApp? = null
|
||||
) : ProtoBuf
|
||||
}
|
||||
|
||||
@Serializable
|
||||
class TroopTips0x857 : ProtoBuf {
|
||||
@Serializable
|
||||
class AIOGrayTipsInfo(
|
||||
@SerialId(1) val optUint32ShowLastest: Int = 0,
|
||||
@SerialId(2) val optBytesContent: ByteArray = EMPTY_BYTE_ARRAY,
|
||||
@SerialId(3) val optUint32Remind: Int = 0,
|
||||
@SerialId(4) val optBytesBrief: ByteArray = EMPTY_BYTE_ARRAY,
|
||||
@SerialId(5) val receiverUin: Long = 0L,
|
||||
@SerialId(6) val reliaoAdminOpt: Int = 0,
|
||||
@SerialId(7) val robotGroupOpt: Int = 0
|
||||
) : ProtoBuf
|
||||
|
||||
@Serializable
|
||||
class AIOTopTipsInfo(
|
||||
@SerialId(1) val optBytesContent: ByteArray = EMPTY_BYTE_ARRAY,
|
||||
@SerialId(2) val optUint32Icon: Int = 0,
|
||||
@SerialId(3) val optEnumAction: Int /* enum */ = 1,
|
||||
@SerialId(4) val optBytesUrl: ByteArray = EMPTY_BYTE_ARRAY,
|
||||
@SerialId(5) val optBytesData: ByteArray = EMPTY_BYTE_ARRAY,
|
||||
@SerialId(6) val optBytesDataI: ByteArray = EMPTY_BYTE_ARRAY,
|
||||
@SerialId(7) val optBytesDataA: ByteArray = EMPTY_BYTE_ARRAY,
|
||||
@SerialId(8) val optBytesDataP: ByteArray = EMPTY_BYTE_ARRAY
|
||||
) : ProtoBuf
|
||||
|
||||
@Serializable
|
||||
class FloatedTipsInfo(
|
||||
@SerialId(1) val optBytesContent: ByteArray = EMPTY_BYTE_ARRAY
|
||||
) : ProtoBuf
|
||||
|
||||
@Serializable
|
||||
class GeneralGrayTipInfo(
|
||||
@SerialId(1) val busiType: Long = 0L,
|
||||
@SerialId(2) val busiId: Long = 0L,
|
||||
@SerialId(3) val ctrlFlag: Int = 0,
|
||||
@SerialId(4) val c2cType: Int = 0,
|
||||
@SerialId(5) val serviceType: Int = 0,
|
||||
@SerialId(6) val templId: Long = 0L,
|
||||
@SerialId(7) val msgTemplParam: List<TemplParam>? = null,
|
||||
@SerialId(8) val content: ByteArray = EMPTY_BYTE_ARRAY,
|
||||
@SerialId(10) val tipsSeqId: Long = 0L,
|
||||
@SerialId(100) val pbReserv: ByteArray = EMPTY_BYTE_ARRAY
|
||||
) : ProtoBuf
|
||||
|
||||
@Serializable
|
||||
class GoldMsgTipsElem(
|
||||
@SerialId(1) val type: Int = 0,
|
||||
@SerialId(2) val billno: String = "",
|
||||
@SerialId(3) val result: Int = 0,
|
||||
@SerialId(4) val amount: Int = 0,
|
||||
@SerialId(5) val total: Int = 0,
|
||||
@SerialId(6) val interval: Int = 0,
|
||||
@SerialId(7) val finish: Int = 0,
|
||||
@SerialId(8) val uin: List<Long>? = null,
|
||||
@SerialId(9) val action: Int = 0
|
||||
) : ProtoBuf
|
||||
|
||||
@Serializable
|
||||
class GroupInfoChange(
|
||||
@SerialId(1) val groupHonorSwitch: Int = 0
|
||||
) : ProtoBuf
|
||||
|
||||
@Serializable
|
||||
class GroupNotifyInfo(
|
||||
@SerialId(1) val optUint32AutoPullFlag: Int = 0,
|
||||
@SerialId(2) val optBytesFeedsId: ByteArray = EMPTY_BYTE_ARRAY
|
||||
) : ProtoBuf
|
||||
|
||||
@Serializable
|
||||
class InstCtrl(
|
||||
@SerialId(1) val msgSendToInst: List<InstInfo>? = null,
|
||||
@SerialId(2) val msgExcludeInst: List<InstInfo>? = null,
|
||||
@SerialId(3) val msgFromInst: InstInfo? = null
|
||||
) : ProtoBuf
|
||||
|
||||
@Serializable
|
||||
class InstInfo(
|
||||
@SerialId(1) val apppid: Int = 0,
|
||||
@SerialId(2) val instid: Int = 0,
|
||||
@SerialId(3) val platform: Int = 0,
|
||||
@SerialId(4) val openAppid: Int = 0,
|
||||
@SerialId(5) val productid: Int = 0,
|
||||
@SerialId(6) val ssoBid: Int = 0,
|
||||
@SerialId(7) val guid: ByteArray = EMPTY_BYTE_ARRAY,
|
||||
@SerialId(8) val verMin: Int = 0,
|
||||
@SerialId(9) val verMax: Int = 0
|
||||
) : ProtoBuf
|
||||
|
||||
@Serializable
|
||||
class LbsShareChangePushInfo(
|
||||
@SerialId(1) val msgType: Int = 0,
|
||||
@SerialId(2) val msgInfo: ByteArray = EMPTY_BYTE_ARRAY,
|
||||
@SerialId(3) val versionCtrl: ByteArray = EMPTY_BYTE_ARRAY,
|
||||
@SerialId(4) val groupId: Long = 0L,
|
||||
@SerialId(5) val operUin: Long = 0L,
|
||||
@SerialId(6) val grayTips: ByteArray = EMPTY_BYTE_ARRAY,
|
||||
@SerialId(7) val msgSeq: Long = 0L,
|
||||
@SerialId(8) val joinNums: Int = 0,
|
||||
@SerialId(99) val pushType: Int = 0,
|
||||
@SerialId(100) val extInfo: ByteArray = EMPTY_BYTE_ARRAY
|
||||
) : ProtoBuf
|
||||
|
||||
@Serializable
|
||||
class LuckyBagNotify(
|
||||
@SerialId(1) val msgTips: ByteArray = EMPTY_BYTE_ARRAY
|
||||
) : ProtoBuf
|
||||
|
||||
@Serializable
|
||||
class MediaChangePushInfo(
|
||||
@SerialId(1) val msgType: Int = 0,
|
||||
@SerialId(2) val msgInfo: ByteArray = EMPTY_BYTE_ARRAY,
|
||||
@SerialId(3) val versionCtrl: ByteArray = EMPTY_BYTE_ARRAY,
|
||||
@SerialId(4) val groupId: Long = 0L,
|
||||
@SerialId(5) val operUin: Long = 0L,
|
||||
@SerialId(6) val grayTips: ByteArray = EMPTY_BYTE_ARRAY,
|
||||
@SerialId(7) val msgSeq: Long = 0L,
|
||||
@SerialId(8) val joinNums: Int = 0,
|
||||
@SerialId(9) val msgPerSetting: PersonalSetting? = null,
|
||||
@SerialId(10) val playMode: Int = 0,
|
||||
@SerialId(99) val mediaType: Int = 0,
|
||||
@SerialId(100) val extInfo: ByteArray = EMPTY_BYTE_ARRAY
|
||||
) : ProtoBuf {
|
||||
@Serializable
|
||||
class PersonalSetting(
|
||||
@SerialId(1) val themeId: Int = 0,
|
||||
@SerialId(2) val playerId: Int = 0,
|
||||
@SerialId(3) val fontId: Int = 0
|
||||
) : ProtoBuf
|
||||
}
|
||||
|
||||
@Serializable
|
||||
class MessageBoxInfo(
|
||||
@SerialId(1) val optBytesContent: ByteArray = EMPTY_BYTE_ARRAY,
|
||||
@SerialId(2) val optBytesTitle: ByteArray = EMPTY_BYTE_ARRAY,
|
||||
@SerialId(3) val optBytesButton: ByteArray = EMPTY_BYTE_ARRAY
|
||||
) : ProtoBuf
|
||||
|
||||
@Serializable
|
||||
class MessageRecallReminder(
|
||||
@SerialId(1) val uin: Long = 0L,
|
||||
@SerialId(2) val nickname: ByteArray = EMPTY_BYTE_ARRAY,
|
||||
@SerialId(3) val recalledMsgList: List<MessageMeta> = listOf(),
|
||||
@SerialId(4) val reminderContent: ByteArray = EMPTY_BYTE_ARRAY,
|
||||
@SerialId(5) val userdef: ByteArray = EMPTY_BYTE_ARRAY,
|
||||
@SerialId(6) val groupType: Int = 0,
|
||||
@SerialId(7) val opType: Int = 0
|
||||
) : ProtoBuf {
|
||||
@Serializable
|
||||
class MessageMeta(
|
||||
@SerialId(1) val seq: Int = 0,
|
||||
@SerialId(2) val time: Int = 0,
|
||||
@SerialId(3) val msgRandom: Int = 0,
|
||||
@SerialId(4) val msgType: Int = 0,
|
||||
@SerialId(5) val msgFlag: Int = 0,
|
||||
@SerialId(6) val authorUin: Long = 0L
|
||||
) : ProtoBuf
|
||||
}
|
||||
|
||||
@Serializable
|
||||
class MiniAppNotify(
|
||||
@SerialId(1) val msg: ByteArray = EMPTY_BYTE_ARRAY
|
||||
) : ProtoBuf
|
||||
|
||||
@Serializable
|
||||
class NotifyMsgBody(
|
||||
@SerialId(1) val optEnumType: Int /* enum */ = 1,
|
||||
@SerialId(2) val optUint64MsgTime: Long = 0L,
|
||||
@SerialId(3) val optUint64MsgExpires: Long = 0L,
|
||||
@SerialId(4) val optUint64GroupCode: Long = 0L,
|
||||
@SerialId(5) val optMsgGraytips: AIOGrayTipsInfo? = null,
|
||||
@SerialId(6) val optMsgMessagebox: MessageBoxInfo? = null,
|
||||
@SerialId(7) val optMsgFloatedtips: FloatedTipsInfo? = null,
|
||||
@SerialId(8) val optMsgToptips: AIOTopTipsInfo? = null,
|
||||
@SerialId(9) val optMsgRedtips: RedGrayTipsInfo? = null,
|
||||
@SerialId(10) val optMsgGroupNotify: GroupNotifyInfo? = null,
|
||||
@SerialId(11) val optMsgRecall: MessageRecallReminder? = null,
|
||||
@SerialId(12) val optMsgThemeNotify: ThemeStateNotify? = null,
|
||||
@SerialId(13) val serviceType: Int = 0,
|
||||
@SerialId(14) val optMsgObjmsgUpdate: NotifyObjmsgUpdate? = null,
|
||||
@SerialId(15) val optMsgWerewolfPush: WereWolfPush? = null,
|
||||
// @SerialId(16) val optStcmGameState: ApolloGameStatus.STCMGameMessage? = null,
|
||||
// @SerialId(17) val aplloMsgPush: ApolloPushMsgInfo.STPushMsgElem? = null,
|
||||
@SerialId(18) val optMsgGoldtips: GoldMsgTipsElem? = null,
|
||||
@SerialId(20) val optMsgMiniappNotify: MiniAppNotify? = null,
|
||||
@SerialId(21) val optUint64SenderUin: Long = 0L,
|
||||
@SerialId(22) val optMsgLuckybagNotify: LuckyBagNotify? = null,
|
||||
@SerialId(23) val optMsgTroopformtipsPush: TroopFormGrayTipsInfo? = null,
|
||||
@SerialId(24) val optMsgMediaPush: MediaChangePushInfo? = null,
|
||||
@SerialId(26) val optGeneralGrayTip: GeneralGrayTipInfo? = null,
|
||||
@SerialId(27) val optMsgVideoPush: VideoChangePushInfo? = null,
|
||||
@SerialId(28) val optLbsShareChangePlusInfo: LbsShareChangePushInfo? = null,
|
||||
@SerialId(29) val optMsgSingPush: SingChangePushInfo? = null,
|
||||
@SerialId(30) val optMsgGroupInfoChange: GroupInfoChange? = null
|
||||
) : ProtoBuf
|
||||
|
||||
@Serializable
|
||||
class NotifyObjmsgUpdate(
|
||||
@SerialId(1) val objmsgId: ByteArray = EMPTY_BYTE_ARRAY,
|
||||
@SerialId(2) val updateType: Int = 0,
|
||||
@SerialId(3) val extMsg: ByteArray = EMPTY_BYTE_ARRAY
|
||||
) : ProtoBuf
|
||||
|
||||
@Serializable
|
||||
class RedGrayTipsInfo(
|
||||
@SerialId(1) val optUint32ShowLastest: Int = 0,
|
||||
@SerialId(2) val senderUin: Long = 0L,
|
||||
@SerialId(3) val receiverUin: Long = 0L,
|
||||
@SerialId(4) val senderRichContent: ByteArray = EMPTY_BYTE_ARRAY,
|
||||
@SerialId(5) val receiverRichContent: ByteArray = EMPTY_BYTE_ARRAY,
|
||||
@SerialId(6) val authkey: ByteArray = EMPTY_BYTE_ARRAY,
|
||||
@ProtoType(ProtoNumberType.SIGNED) @SerialId(7) val sint32Msgtype: Int = 0,
|
||||
@SerialId(8) val luckyFlag: Int = 0,
|
||||
@SerialId(9) val hideFlag: Int = 0,
|
||||
@SerialId(10) val pcBody: ByteArray = EMPTY_BYTE_ARRAY,
|
||||
@SerialId(11) val icon: Int = 0,
|
||||
@SerialId(12) val luckyUin: Long = 0L,
|
||||
@SerialId(13) val time: Int = 0,
|
||||
@SerialId(14) val random: Int = 0,
|
||||
@SerialId(15) val broadcastRichContent: ByteArray = EMPTY_BYTE_ARRAY,
|
||||
@SerialId(16) val idiom: ByteArray = EMPTY_BYTE_ARRAY,
|
||||
@SerialId(17) val idiomSeq: Int = 0,
|
||||
@SerialId(18) val idiomAlpha: ByteArray = EMPTY_BYTE_ARRAY,
|
||||
@SerialId(19) val jumpurl: ByteArray = EMPTY_BYTE_ARRAY
|
||||
) : ProtoBuf
|
||||
|
||||
@Serializable
|
||||
class ReqBody(
|
||||
@SerialId(1) val optUint64GroupCode: Long = 0L,
|
||||
@SerialId(2) val uint64Memberuins: List<Long>? = null,
|
||||
@SerialId(3) val optUint32Offline: Int = 0,
|
||||
@SerialId(4) val msgInstCtrl: InstCtrl? = null,
|
||||
@SerialId(5) val optBytesMsg: ByteArray = EMPTY_BYTE_ARRAY,
|
||||
@SerialId(6) val optUint32BusiType: Int = 0
|
||||
) : ProtoBuf
|
||||
|
||||
@Serializable
|
||||
class RspBody(
|
||||
@SerialId(1) val optUint64GroupCode: Long = 0L
|
||||
) : ProtoBuf
|
||||
|
||||
@Serializable
|
||||
class SingChangePushInfo(
|
||||
@SerialId(1) val seq: Long = 0L,
|
||||
@SerialId(2) val actionType: Int = 0,
|
||||
@SerialId(3) val groupId: Long = 0L,
|
||||
@SerialId(4) val operUin: Long = 0L,
|
||||
@SerialId(5) val grayTips: ByteArray = EMPTY_BYTE_ARRAY,
|
||||
@SerialId(6) val joinNums: Int = 0
|
||||
) : ProtoBuf
|
||||
|
||||
@Serializable
|
||||
class TemplParam(
|
||||
@SerialId(1) val name: ByteArray = EMPTY_BYTE_ARRAY,
|
||||
@SerialId(2) val value: ByteArray = EMPTY_BYTE_ARRAY
|
||||
) : ProtoBuf
|
||||
|
||||
@Serializable
|
||||
class ThemeStateNotify(
|
||||
@SerialId(1) val state: Int = 0,
|
||||
@SerialId(2) val feedsId: ByteArray = EMPTY_BYTE_ARRAY,
|
||||
@SerialId(3) val themeName: ByteArray = EMPTY_BYTE_ARRAY,
|
||||
@SerialId(4) val actionUin: Long = 0L,
|
||||
@SerialId(5) val createUin: Long = 0L
|
||||
) : ProtoBuf
|
||||
|
||||
@Serializable
|
||||
class TroopFormGrayTipsInfo(
|
||||
@SerialId(1) val writerUin: Long = 0L,
|
||||
@SerialId(2) val creatorUin: Long = 0L,
|
||||
@SerialId(3) val richContent: ByteArray = EMPTY_BYTE_ARRAY,
|
||||
@SerialId(4) val optBytesUrl: ByteArray = EMPTY_BYTE_ARRAY,
|
||||
@SerialId(5) val creatorNick: ByteArray = EMPTY_BYTE_ARRAY
|
||||
) : ProtoBuf
|
||||
|
||||
@Serializable
|
||||
class VideoChangePushInfo(
|
||||
@SerialId(1) val seq: Long = 0L,
|
||||
@SerialId(2) val actionType: Int = 0,
|
||||
@SerialId(3) val groupId: Long = 0L,
|
||||
@SerialId(4) val operUin: Long = 0L,
|
||||
@SerialId(5) val grayTips: ByteArray = EMPTY_BYTE_ARRAY,
|
||||
@SerialId(6) val joinNums: Int = 0,
|
||||
@SerialId(100) val extInfo: ByteArray = EMPTY_BYTE_ARRAY
|
||||
) : ProtoBuf
|
||||
|
||||
@Serializable
|
||||
class WereWolfPush(
|
||||
@SerialId(1) val pushType: Int = 0,
|
||||
@SerialId(2) val gameRoom: Long = 0L,
|
||||
@SerialId(3) val enumGameState: Int = 0,
|
||||
@SerialId(4) val gameRound: Int = 0,
|
||||
@SerialId(5) val roles: List<Role>? = null,
|
||||
@SerialId(6) val speaker: Long = 0L,
|
||||
@SerialId(7) val judgeUin: Long = 0L,
|
||||
@SerialId(8) val judgeWords: ByteArray = EMPTY_BYTE_ARRAY,
|
||||
@SerialId(9) val enumOperation: Int = 0,
|
||||
@SerialId(10) val srcUser: Long = 0L,
|
||||
@SerialId(11) val dstUser: Long = 0L,
|
||||
@SerialId(12) val deadUsers: List<Long>? = null,
|
||||
@SerialId(13) val gameResult: Int = 0,
|
||||
@SerialId(14) val timeoutSec: Int = 0,
|
||||
@SerialId(15) val killConfirmed: Int = 0,
|
||||
@SerialId(16) val judgeNickname: ByteArray = EMPTY_BYTE_ARRAY,
|
||||
@SerialId(17) val votedTieUsers: List<Long>? = null
|
||||
) : ProtoBuf {
|
||||
@Serializable
|
||||
class GameRecord(
|
||||
@SerialId(1) val total: Int = 0,
|
||||
@SerialId(2) val win: Int = 0,
|
||||
@SerialId(3) val lose: Int = 0,
|
||||
@SerialId(4) val draw: Int = 0
|
||||
) : ProtoBuf
|
||||
|
||||
@Serializable
|
||||
class Role(
|
||||
@SerialId(1) val uin: Long = 0L,
|
||||
@SerialId(2) val enumType: Int = 0,
|
||||
@SerialId(3) val enumState: Int = 0,
|
||||
@SerialId(4) val canSpeak: Int = 0,
|
||||
@SerialId(5) val canListen: Int = 0,
|
||||
@SerialId(6) val position: Int = 0,
|
||||
@SerialId(7) val canVote: Int = 0,
|
||||
@SerialId(8) val canVoted: Int = 0,
|
||||
@SerialId(9) val alreadyChecked: Int = 0,
|
||||
@SerialId(10) val alreadySaved: Int = 0,
|
||||
@SerialId(11) val alreadyPoisoned: Int = 0,
|
||||
@SerialId(12) val playerState: Int = 0,
|
||||
@SerialId(13) val enumDeadOp: Int = 0,
|
||||
@SerialId(14) val enumOperation: Int = 0,
|
||||
@SerialId(15) val dstUser: Long = 0L,
|
||||
@SerialId(16) val operationRound: Int = 0,
|
||||
@SerialId(17) val msgGameRecord: GameRecord? = null,
|
||||
@SerialId(18) val isWerewolf: Int = 0,
|
||||
@SerialId(19) val defendedUser: Long = 0L,
|
||||
@SerialId(20) val isSheriff: Int = 0
|
||||
) : ProtoBuf
|
||||
}
|
||||
}
|
@ -9,10 +9,7 @@
|
||||
|
||||
package net.mamoe.mirai.qqandroid.network.protocol.packet
|
||||
|
||||
import kotlinx.io.core.BytePacketBuilder
|
||||
import kotlinx.io.core.ByteReadPacket
|
||||
import kotlinx.io.core.buildPacket
|
||||
import kotlinx.io.core.writeFully
|
||||
import io.ktor.utils.io.core.*
|
||||
import net.mamoe.mirai.qqandroid.network.QQAndroidClient
|
||||
import net.mamoe.mirai.utils.cryptor.ECDH
|
||||
import net.mamoe.mirai.utils.cryptor.ECDHKeyPair
|
||||
|
@ -10,10 +10,7 @@
|
||||
package net.mamoe.mirai.qqandroid.network.protocol.packet
|
||||
|
||||
|
||||
import kotlinx.io.core.BytePacketBuilder
|
||||
import kotlinx.io.core.ByteReadPacket
|
||||
import kotlinx.io.core.buildPacket
|
||||
import kotlinx.io.core.writeFully
|
||||
import io.ktor.utils.io.core.*
|
||||
import net.mamoe.mirai.qqandroid.network.QQAndroidClient
|
||||
import net.mamoe.mirai.utils.MiraiInternalAPI
|
||||
import net.mamoe.mirai.utils.io.encryptAndWrite
|
||||
@ -57,7 +54,7 @@ internal inline fun OutgoingPacketFactory<*>.buildOutgoingPacket(
|
||||
writeByte(0)
|
||||
client.uin.toString().let {
|
||||
writeInt(it.length + 4)
|
||||
writeStringUtf8(it)
|
||||
writeText(it)
|
||||
}
|
||||
encryptAndWrite(key) {
|
||||
body(sequenceId)
|
||||
@ -78,6 +75,7 @@ internal inline fun OutgoingPacketFactory<*>.buildOutgoingUniPacket(
|
||||
body: BytePacketBuilder.(sequenceId: Int) -> Unit
|
||||
): OutgoingPacket {
|
||||
|
||||
@Suppress("DuplicatedCode")
|
||||
return OutgoingPacket(name, commandName, sequenceId, buildPacket {
|
||||
writeIntLVPacket(lengthOffset = { it + 4 }) {
|
||||
writeInt(0x0B)
|
||||
@ -86,7 +84,7 @@ internal inline fun OutgoingPacketFactory<*>.buildOutgoingUniPacket(
|
||||
writeByte(0)
|
||||
client.uin.toString().let {
|
||||
writeInt(it.length + 4)
|
||||
writeStringUtf8(it)
|
||||
writeText(it)
|
||||
}
|
||||
encryptAndWrite(key) {
|
||||
writeUniPacket(commandName, client.outgoingPacketSessionId, extraData) {
|
||||
@ -109,6 +107,7 @@ internal inline fun IncomingPacketFactory<*>.buildResponseUniPacket(
|
||||
sequenceId: Int = client.nextSsoSequenceId(),
|
||||
body: BytePacketBuilder.(sequenceId: Int) -> Unit
|
||||
): OutgoingPacket {
|
||||
@Suppress("DuplicatedCode")
|
||||
return OutgoingPacket(name, commandName, sequenceId, buildPacket {
|
||||
writeIntLVPacket(lengthOffset = { it + 4 }) {
|
||||
writeInt(0x0B)
|
||||
@ -117,7 +116,7 @@ internal inline fun IncomingPacketFactory<*>.buildResponseUniPacket(
|
||||
writeByte(0)
|
||||
client.uin.toString().let {
|
||||
writeInt(it.length + 4)
|
||||
writeStringUtf8(it)
|
||||
writeText(it)
|
||||
}
|
||||
encryptAndWrite(key) {
|
||||
writeUniPacket(commandName, client.outgoingPacketSessionId, extraData) {
|
||||
@ -138,7 +137,7 @@ internal inline fun BytePacketBuilder.writeUniPacket(
|
||||
writeIntLVPacket(lengthOffset = { it + 4 }) {
|
||||
commandName.let {
|
||||
writeInt(it.length + 4)
|
||||
writeStringUtf8(it)
|
||||
writeText(it)
|
||||
}
|
||||
|
||||
writeInt(4 + 4)
|
||||
@ -185,7 +184,7 @@ internal inline fun OutgoingPacketFactory<*>.buildLoginOutgoingPacket(
|
||||
|
||||
client.uin.toString().let {
|
||||
writeInt(it.length + 4)
|
||||
writeStringUtf8(it)
|
||||
writeText(it)
|
||||
}
|
||||
|
||||
if (key === NO_ENCRYPT) {
|
||||
@ -240,7 +239,7 @@ internal inline fun BytePacketBuilder.writeSsoPacket(
|
||||
}
|
||||
commandName.let {
|
||||
writeInt(it.length + 4)
|
||||
writeStringUtf8(it)
|
||||
writeText(it)
|
||||
}
|
||||
|
||||
writeInt(4 + 4)
|
||||
@ -248,7 +247,7 @@ internal inline fun BytePacketBuilder.writeSsoPacket(
|
||||
|
||||
client.device.imei.let {
|
||||
writeInt(it.length + 4)
|
||||
writeStringUtf8(it)
|
||||
writeText(it)
|
||||
}
|
||||
|
||||
writeInt(4)
|
||||
|
@ -9,8 +9,8 @@
|
||||
|
||||
package net.mamoe.mirai.qqandroid.network.protocol.packet
|
||||
|
||||
import kotlinx.io.core.*
|
||||
import kotlinx.io.pool.useInstance
|
||||
import io.ktor.utils.io.core.*
|
||||
import io.ktor.utils.io.pool.useInstance
|
||||
import net.mamoe.mirai.data.Packet
|
||||
import net.mamoe.mirai.event.Event
|
||||
import net.mamoe.mirai.qqandroid.QQAndroidBot
|
||||
|
@ -9,10 +9,7 @@
|
||||
|
||||
package net.mamoe.mirai.qqandroid.network.protocol.packet
|
||||
|
||||
import kotlinx.io.core.BytePacketBuilder
|
||||
import kotlinx.io.core.ByteReadPacket
|
||||
import kotlinx.io.core.toByteArray
|
||||
import kotlinx.io.core.writeFully
|
||||
import io.ktor.utils.io.core.*
|
||||
import net.mamoe.mirai.qqandroid.network.protocol.LoginType
|
||||
import net.mamoe.mirai.qqandroid.utils.NetworkType
|
||||
import net.mamoe.mirai.utils.currentTimeMillis
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
package net.mamoe.mirai.qqandroid.network.protocol.packet.chat
|
||||
|
||||
import kotlinx.io.core.ByteReadPacket
|
||||
import io.ktor.utils.io.core.ByteReadPacket
|
||||
import net.mamoe.mirai.data.Packet
|
||||
import net.mamoe.mirai.qqandroid.QQAndroidBot
|
||||
import net.mamoe.mirai.qqandroid.io.serialization.readProtoBuf
|
||||
|
@ -9,11 +9,7 @@
|
||||
|
||||
package net.mamoe.mirai.qqandroid.network.protocol.packet.chat
|
||||
|
||||
import kotlinx.io.core.ByteReadPacket
|
||||
import kotlinx.io.core.buildPacket
|
||||
import kotlinx.io.core.readBytes
|
||||
import kotlinx.io.core.toByteArray
|
||||
import kotlinx.serialization.toUtf8Bytes
|
||||
import io.ktor.utils.io.core.*
|
||||
import net.mamoe.mirai.contact.Group
|
||||
import net.mamoe.mirai.contact.Member
|
||||
import net.mamoe.mirai.data.Packet
|
||||
@ -379,7 +375,7 @@ internal class TroopManagement {
|
||||
OutgoingPacketFactory<EditGroupNametag.Response>("friendlist.ModifyGroupCardReq") {
|
||||
object Response : Packet
|
||||
|
||||
override suspend fun ByteReadPacket.decode(bot: QQAndroidBot): EditGroupNametag.Response {
|
||||
override suspend fun ByteReadPacket.decode(bot: QQAndroidBot): Response {
|
||||
return Response
|
||||
}
|
||||
|
||||
|
@ -9,8 +9,7 @@
|
||||
|
||||
package net.mamoe.mirai.qqandroid.network.protocol.packet.chat.image
|
||||
|
||||
import io.ktor.client.HttpClient
|
||||
import kotlinx.io.core.ByteReadPacket
|
||||
import io.ktor.utils.io.core.ByteReadPacket
|
||||
import net.mamoe.mirai.data.Packet
|
||||
import net.mamoe.mirai.qqandroid.QQAndroidBot
|
||||
import net.mamoe.mirai.qqandroid.io.serialization.readProtoBuf
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
package net.mamoe.mirai.qqandroid.network.protocol.packet.chat.image
|
||||
|
||||
import kotlinx.io.core.ByteReadPacket
|
||||
import io.ktor.utils.io.core.ByteReadPacket
|
||||
import net.mamoe.mirai.data.Packet
|
||||
import net.mamoe.mirai.qqandroid.QQAndroidBot
|
||||
import net.mamoe.mirai.qqandroid.io.serialization.readProtoBuf
|
||||
|
@ -9,11 +9,10 @@
|
||||
|
||||
package net.mamoe.mirai.qqandroid.network.protocol.packet.chat.receive
|
||||
|
||||
import io.ktor.utils.io.core.ByteReadPacket
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Deferred
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.io.core.ByteReadPacket
|
||||
import kotlinx.io.core.discardExact
|
||||
import net.mamoe.mirai.contact.Group
|
||||
import net.mamoe.mirai.contact.MemberPermission
|
||||
import net.mamoe.mirai.data.MemberInfo
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
package net.mamoe.mirai.qqandroid.network.protocol.packet.list
|
||||
|
||||
import kotlinx.io.core.ByteReadPacket
|
||||
import io.ktor.utils.io.core.ByteReadPacket
|
||||
import net.mamoe.mirai.data.Packet
|
||||
import net.mamoe.mirai.qqandroid.QQAndroidBot
|
||||
import net.mamoe.mirai.qqandroid.io.serialization.decodeUniPacket
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
package net.mamoe.mirai.qqandroid.network.protocol.packet.login
|
||||
|
||||
import kotlinx.io.core.ByteReadPacket
|
||||
import io.ktor.utils.io.core.ByteReadPacket
|
||||
import net.mamoe.mirai.qqandroid.QQAndroidBot
|
||||
import net.mamoe.mirai.qqandroid.io.serialization.JceCharset
|
||||
import net.mamoe.mirai.qqandroid.io.serialization.decodeUniPacket
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
package net.mamoe.mirai.qqandroid.network.protocol.packet.login
|
||||
|
||||
import kotlinx.io.core.ByteReadPacket
|
||||
import io.ktor.utils.io.core.ByteReadPacket
|
||||
import net.mamoe.mirai.data.Packet
|
||||
import net.mamoe.mirai.qqandroid.QQAndroidBot
|
||||
import net.mamoe.mirai.qqandroid.network.QQAndroidClient
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
package net.mamoe.mirai.qqandroid.network.protocol.packet.login
|
||||
|
||||
import kotlinx.io.core.ByteReadPacket
|
||||
import io.ktor.utils.io.core.ByteReadPacket
|
||||
import net.mamoe.mirai.data.Packet
|
||||
import net.mamoe.mirai.qqandroid.QQAndroidBot
|
||||
import net.mamoe.mirai.qqandroid.io.serialization.*
|
||||
|
@ -11,7 +11,7 @@ package net.mamoe.mirai.qqandroid.network.protocol.packet.login
|
||||
|
||||
|
||||
import io.ktor.util.InternalAPI
|
||||
import kotlinx.io.core.*
|
||||
import io.ktor.utils.io.core.*
|
||||
import net.mamoe.mirai.data.Packet
|
||||
import net.mamoe.mirai.qqandroid.QQAndroidBot
|
||||
import net.mamoe.mirai.qqandroid.network.*
|
||||
@ -282,7 +282,7 @@ internal class WtLogin {
|
||||
}
|
||||
|
||||
class Picture(
|
||||
val data: IoBuffer,
|
||||
val data: ByteArray,
|
||||
val sign: ByteArray
|
||||
) : Captcha() {
|
||||
override fun toString(): String = "LoginPacketResponse.Captcha.Picture"
|
||||
@ -378,11 +378,8 @@ internal class WtLogin {
|
||||
imageData.discardExact(2)//image Length
|
||||
val sign = imageData.readBytes(signInfoLength.toInt())
|
||||
|
||||
|
||||
val buffer = IoBuffer.Pool.borrow()
|
||||
imageData.readAvailable(buffer)
|
||||
return LoginPacketResponse.Captcha.Picture(
|
||||
data = buffer,
|
||||
data = imageData.readBytes(),
|
||||
sign = sign
|
||||
)
|
||||
// } else error("UNKNOWN CAPTCHA QUESTION: ${question.toUHexString()}, tlvMap=" + tlvMap.contentToString())
|
||||
|
@ -11,11 +11,11 @@
|
||||
|
||||
package test
|
||||
|
||||
import kotlinx.io.core.ByteReadPacket
|
||||
import kotlinx.io.core.Input
|
||||
import kotlinx.io.core.readAvailable
|
||||
import kotlinx.io.core.use
|
||||
import kotlinx.io.pool.useInstance
|
||||
import io.ktor.utils.io.core.ByteReadPacket
|
||||
import io.ktor.utils.io.core.Input
|
||||
import io.ktor.utils.io.core.readAvailable
|
||||
import io.ktor.utils.io.core.use
|
||||
import io.ktor.utils.io.pool.useInstance
|
||||
import net.mamoe.mirai.utils.DefaultLogger
|
||||
import net.mamoe.mirai.utils.MiraiInternalAPI
|
||||
import net.mamoe.mirai.utils.MiraiLoggerWithSwitch
|
||||
|
@ -11,7 +11,7 @@ package net.mamoe.mirai.qqandroid.io.serialization
|
||||
|
||||
/*
|
||||
|
||||
import kotlinx.io.core.readBytes
|
||||
import io.ktor.utils.io.core.readBytes
|
||||
import kotlinx.serialization.SerialId
|
||||
import kotlinx.serialization.Serializable
|
||||
import net.mamoe.mirai.qqandroid.io.JceOutput
|
||||
|
@ -25,7 +25,7 @@ fun main() {
|
||||
println(
|
||||
File(
|
||||
"""
|
||||
E:\Projects\QQAndroidFF\app\src\main\java\tencent\im\msgrevoke
|
||||
E:\Projects\QQAndroidFF\app\src\main\java\tencent\im\oidb\cmd0x857
|
||||
""".trimIndent()
|
||||
)
|
||||
.generateUnarrangedClasses().toMutableList().arrangeClasses().joinToString("\n\n")
|
||||
|
@ -41,7 +41,6 @@ fun File.toExternalImage(): ExternalImage {
|
||||
md5 = this.inputStream().use { it.md5() },
|
||||
imageFormat = this.nameWithoutExtension,
|
||||
input = this.inputStream(),
|
||||
inputSize = this.length(),
|
||||
filename = this.name
|
||||
)
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ import android.annotation.SuppressLint
|
||||
import android.net.wifi.WifiManager
|
||||
import android.os.Build
|
||||
import android.telephony.TelephonyManager
|
||||
import kotlinx.io.core.toByteArray
|
||||
import io.ktor.utils.io.core.toByteArray
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.Transient
|
||||
import kotlinx.serialization.UnstableDefault
|
||||
|
@ -9,10 +9,10 @@
|
||||
|
||||
package net.mamoe.mirai.utils.io
|
||||
|
||||
import io.ktor.utils.io.core.ByteReadPacket
|
||||
import io.ktor.utils.io.core.Closeable
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
import kotlinx.io.core.ByteReadPacket
|
||||
import kotlinx.io.core.Closeable
|
||||
import kotlinx.io.nio.readPacketAtMost
|
||||
import kotlinx.io.nio.writePacket
|
||||
import java.net.InetSocketAddress
|
||||
|
@ -9,13 +9,13 @@
|
||||
|
||||
package net.mamoe.mirai.utils.io
|
||||
|
||||
import io.ktor.utils.io.core.ByteReadPacket
|
||||
import io.ktor.utils.io.core.Closeable
|
||||
import io.ktor.utils.io.core.ExperimentalIoApi
|
||||
import io.ktor.utils.io.streams.readPacketAtMost
|
||||
import io.ktor.utils.io.streams.writePacket
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
import kotlinx.io.core.ByteReadPacket
|
||||
import kotlinx.io.core.Closeable
|
||||
import kotlinx.io.core.ExperimentalIoApi
|
||||
import kotlinx.io.streams.readPacketAtMost
|
||||
import kotlinx.io.streams.writePacket
|
||||
import net.mamoe.mirai.utils.MiraiInternalAPI
|
||||
import java.io.BufferedInputStream
|
||||
import java.io.BufferedOutputStream
|
||||
|
@ -12,7 +12,7 @@ package net.mamoe.mirai.utils
|
||||
import io.ktor.client.HttpClient
|
||||
import io.ktor.client.engine.cio.CIO
|
||||
import io.ktor.util.KtorExperimentalAPI
|
||||
import kotlinx.io.pool.useInstance
|
||||
import io.ktor.utils.io.pool.useInstance
|
||||
import net.mamoe.mirai.utils.io.ByteArrayPool
|
||||
import java.io.ByteArrayOutputStream
|
||||
import java.io.DataInput
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
package net.mamoe.mirai
|
||||
|
||||
import kotlinx.io.core.toByteArray
|
||||
import io.ktor.utils.io.core.toByteArray
|
||||
import net.mamoe.mirai.utils.MiraiInternalAPI
|
||||
import net.mamoe.mirai.utils.md5
|
||||
import kotlin.annotation.AnnotationTarget.*
|
||||
|
@ -10,9 +10,8 @@
|
||||
package net.mamoe.mirai.data
|
||||
|
||||
import io.ktor.client.request.get
|
||||
import io.ktor.util.KtorExperimentalAPI
|
||||
import kotlinx.io.core.ByteReadPacket
|
||||
import kotlinx.io.core.readBytes
|
||||
import io.ktor.utils.io.core.ByteReadPacket
|
||||
import io.ktor.utils.io.core.readBytes
|
||||
import net.mamoe.mirai.utils.Http
|
||||
|
||||
interface ImageLink {
|
||||
|
@ -21,6 +21,7 @@ import net.mamoe.mirai.event.events.ImageUploadEvent.Failed
|
||||
import net.mamoe.mirai.event.events.ImageUploadEvent.Succeed
|
||||
import net.mamoe.mirai.message.data.Image
|
||||
import net.mamoe.mirai.message.data.MessageChain
|
||||
import net.mamoe.mirai.message.data.MessageSource
|
||||
import net.mamoe.mirai.utils.ExternalImage
|
||||
import net.mamoe.mirai.utils.MiraiExperimentalAPI
|
||||
|
||||
@ -56,7 +57,8 @@ sealed class BotOfflineEvent : BotEvent {
|
||||
/**
|
||||
* 被挤下线
|
||||
*/
|
||||
data class Force(override val bot: Bot, val title: String, val message: String) : BotOfflineEvent(), Packet, BotPassiveEvent
|
||||
data class Force(override val bot: Bot, val title: String, val message: String) : BotOfflineEvent(), Packet,
|
||||
BotPassiveEvent
|
||||
|
||||
/**
|
||||
* 被服务器断开或因网络问题而掉线
|
||||
@ -92,6 +94,47 @@ sealed class MessageSendEvent : BotEvent, BotActiveEvent, AbstractCancellableEve
|
||||
) : MessageSendEvent(), CancellableEvent
|
||||
}
|
||||
|
||||
/**
|
||||
* 消息撤回事件. 可是任意消息被任意人撤回.
|
||||
*/
|
||||
sealed class MessageRecallEvent : BotEvent {
|
||||
/**
|
||||
* 消息原发送人
|
||||
*/
|
||||
abstract val authorId: Long
|
||||
|
||||
/**
|
||||
* 消息 id.
|
||||
* @see MessageSource.id
|
||||
*/
|
||||
abstract val messageId: Long
|
||||
|
||||
/**
|
||||
* 原发送时间
|
||||
*/
|
||||
abstract val messageTime: Int // seconds
|
||||
|
||||
data class ByBot(
|
||||
override val bot: Bot,
|
||||
override val authorId: Long,
|
||||
override val messageId: Long,
|
||||
override val messageTime: Int
|
||||
) : MessageRecallEvent(), BotActiveEvent, CancellableEvent {
|
||||
override val isCancelled: Boolean get() = cancelled
|
||||
private var cancelled: Boolean = false // 无法多继承
|
||||
override fun cancel() {
|
||||
cancelled = true
|
||||
}
|
||||
}
|
||||
|
||||
data class ByOthers(
|
||||
override val bot: Bot,
|
||||
override val authorId: Long,
|
||||
override val messageId: Long,
|
||||
override val messageTime: Int
|
||||
) : MessageRecallEvent(), BotPassiveEvent, Packet
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
// region 图片
|
||||
|
@ -12,9 +12,9 @@
|
||||
package net.mamoe.mirai.utils
|
||||
|
||||
import io.ktor.utils.io.ByteReadChannel
|
||||
import io.ktor.utils.io.core.ByteReadPacket
|
||||
import io.ktor.utils.io.core.Input
|
||||
import kotlinx.io.InputStream
|
||||
import kotlinx.io.core.ByteReadPacket
|
||||
import kotlinx.io.core.Input
|
||||
import net.mamoe.mirai.contact.Contact
|
||||
import net.mamoe.mirai.contact.Group
|
||||
import net.mamoe.mirai.contact.QQ
|
||||
|
@ -15,10 +15,11 @@ package net.mamoe.mirai.utils
|
||||
|
||||
|
||||
import io.ktor.utils.io.ByteReadChannel
|
||||
import io.ktor.utils.io.core.Output
|
||||
import io.ktor.utils.io.core.writeFully
|
||||
import io.ktor.utils.io.pool.useInstance
|
||||
import io.ktor.utils.io.readAvailable
|
||||
import kotlinx.io.OutputStream
|
||||
import kotlinx.io.core.Output
|
||||
import kotlinx.io.pool.useInstance
|
||||
import net.mamoe.mirai.utils.io.ByteArrayPool
|
||||
import kotlin.jvm.JvmMultifileClass
|
||||
import kotlin.jvm.JvmName
|
||||
|
@ -9,8 +9,9 @@
|
||||
|
||||
package net.mamoe.mirai.utils.cryptor
|
||||
|
||||
import kotlinx.io.core.ByteReadPacket
|
||||
import kotlinx.io.pool.useInstance
|
||||
import io.ktor.utils.io.core.ByteReadPacket
|
||||
import io.ktor.utils.io.core.readFully
|
||||
import io.ktor.utils.io.pool.useInstance
|
||||
import net.mamoe.mirai.utils.MiraiInternalAPI
|
||||
import net.mamoe.mirai.utils.io.ByteArrayPool
|
||||
import net.mamoe.mirai.utils.io.toByteArray
|
||||
|
@ -11,8 +11,7 @@
|
||||
|
||||
package net.mamoe.mirai.utils.io
|
||||
|
||||
import kotlinx.io.pool.DefaultPool
|
||||
import kotlinx.io.pool.ObjectPool
|
||||
import io.ktor.utils.io.pool.DefaultPool
|
||||
import net.mamoe.mirai.utils.MiraiInternalAPI
|
||||
|
||||
/**
|
||||
|
@ -9,8 +9,8 @@
|
||||
|
||||
package net.mamoe.mirai.utils.io
|
||||
|
||||
import kotlinx.io.core.ByteReadPacket
|
||||
import kotlinx.io.core.Closeable
|
||||
import io.ktor.utils.io.core.ByteReadPacket
|
||||
import io.ktor.utils.io.core.Closeable
|
||||
import net.mamoe.mirai.utils.MiraiInternalAPI
|
||||
|
||||
/**
|
||||
|
@ -9,8 +9,8 @@
|
||||
|
||||
package net.mamoe.mirai.utils.io
|
||||
|
||||
import kotlinx.io.core.ByteReadPacket
|
||||
import kotlinx.io.core.Closeable
|
||||
import io.ktor.utils.io.core.ByteReadPacket
|
||||
import io.ktor.utils.io.core.Closeable
|
||||
import net.mamoe.mirai.utils.MiraiInternalAPI
|
||||
|
||||
/**
|
||||
|
@ -13,11 +13,11 @@
|
||||
|
||||
package net.mamoe.mirai.utils.io
|
||||
|
||||
import kotlinx.io.charsets.Charset
|
||||
import kotlinx.io.charsets.Charsets
|
||||
import kotlinx.io.core.ByteReadPacket
|
||||
import kotlinx.io.core.String
|
||||
import kotlinx.io.core.use
|
||||
import io.ktor.utils.io.charsets.Charset
|
||||
import io.ktor.utils.io.charsets.Charsets
|
||||
import io.ktor.utils.io.core.ByteReadPacket
|
||||
import io.ktor.utils.io.core.String
|
||||
import io.ktor.utils.io.core.use
|
||||
import net.mamoe.mirai.utils.checkOffsetAndLength
|
||||
import kotlin.contracts.ExperimentalContracts
|
||||
import kotlin.contracts.InvocationKind
|
||||
|
@ -10,14 +10,16 @@
|
||||
package net.mamoe.mirai.utils.io
|
||||
|
||||
import io.ktor.utils.io.ByteReadChannel
|
||||
import io.ktor.utils.io.core.ByteReadPacket
|
||||
import io.ktor.utils.io.core.Input
|
||||
import io.ktor.utils.io.core.isNotEmpty
|
||||
import io.ktor.utils.io.core.readAvailable
|
||||
import io.ktor.utils.io.pool.useInstance
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.flow
|
||||
import kotlinx.coroutines.flow.flowOf
|
||||
import kotlinx.io.InputStream
|
||||
import kotlinx.io.core.ByteReadPacket
|
||||
import kotlinx.io.core.Input
|
||||
import kotlinx.io.pool.useInstance
|
||||
import net.mamoe.mirai.utils.MiraiInternalAPI
|
||||
|
||||
|
||||
|
@ -11,8 +11,6 @@
|
||||
|
||||
package net.mamoe.mirai.utils.io
|
||||
|
||||
import kotlinx.io.core.IoBuffer
|
||||
import kotlinx.io.pool.ObjectPool
|
||||
import kotlin.random.Random
|
||||
import kotlin.random.nextInt
|
||||
|
||||
@ -202,13 +200,3 @@ fun ByteArray.toInt(): Int =
|
||||
(this[0].toInt().and(255) shl 24) + (this[1].toInt().and(255) shl 16) + (this[2].toInt().and(255) shl 8) + (this[3].toInt().and(
|
||||
255
|
||||
) shl 0)
|
||||
|
||||
/**
|
||||
* 从 [IoBuffer.Pool] [borrow][ObjectPool.borrow] 一个 [IoBuffer] 然后将 [this] 写入.
|
||||
* 注意回收 ([ObjectPool.recycle])
|
||||
*/
|
||||
fun ByteArray.toIoBuffer(
|
||||
offset: Int = 0,
|
||||
length: Int = this.size - offset,
|
||||
pool: ObjectPool<IoBuffer> = IoBuffer.Pool
|
||||
): IoBuffer = pool.borrow().let { it.writeFully(this, offset, length); it }
|
@ -13,11 +13,11 @@
|
||||
|
||||
package net.mamoe.mirai.utils.io
|
||||
|
||||
import io.ktor.utils.io.charsets.Charset
|
||||
import io.ktor.utils.io.charsets.Charsets
|
||||
import io.ktor.utils.io.core.*
|
||||
import io.ktor.utils.io.pool.useInstance
|
||||
import kotlinx.io.OutputStream
|
||||
import kotlinx.io.charsets.Charset
|
||||
import kotlinx.io.charsets.Charsets
|
||||
import kotlinx.io.core.*
|
||||
import kotlinx.io.pool.useInstance
|
||||
import net.mamoe.mirai.utils.MiraiDebugAPI
|
||||
import net.mamoe.mirai.utils.MiraiInternalAPI
|
||||
import kotlin.jvm.JvmMultifileClass
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
package net.mamoe.mirai.utils.io
|
||||
|
||||
import kotlinx.io.core.*
|
||||
import io.ktor.utils.io.core.*
|
||||
import net.mamoe.mirai.utils.MiraiInternalAPI
|
||||
import net.mamoe.mirai.utils.coerceAtMostOrFail
|
||||
import net.mamoe.mirai.utils.cryptor.TEA
|
||||
|
@ -12,7 +12,7 @@
|
||||
package net.mamoe.mirai.utils
|
||||
|
||||
import io.ktor.client.HttpClient
|
||||
import kotlinx.io.core.toByteArray
|
||||
import io.ktor.utils.io.core.toByteArray
|
||||
|
||||
/**
|
||||
* 时间戳
|
||||
|
@ -11,8 +11,8 @@
|
||||
|
||||
package net.mamoe.mirai.message
|
||||
|
||||
import kotlinx.io.core.Input
|
||||
import kotlinx.io.core.use
|
||||
import io.ktor.utils.io.core.Input
|
||||
import io.ktor.utils.io.core.use
|
||||
import net.mamoe.mirai.contact.Contact
|
||||
import net.mamoe.mirai.contact.QQ
|
||||
import net.mamoe.mirai.message.data.Image
|
||||
|
@ -11,9 +11,9 @@
|
||||
|
||||
package net.mamoe.mirai.message
|
||||
|
||||
import io.ktor.utils.io.core.Input
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
import kotlinx.io.core.Input
|
||||
import net.mamoe.mirai.contact.Contact
|
||||
import net.mamoe.mirai.message.data.Image
|
||||
import net.mamoe.mirai.utils.OverFileSizeMaxException
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
package net.mamoe.mirai.utils
|
||||
|
||||
import io.ktor.utils.io.core.use
|
||||
import kotlinx.coroutines.CoroutineName
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
@ -20,7 +21,6 @@ import kotlinx.coroutines.io.writeFully
|
||||
import kotlinx.coroutines.sync.Mutex
|
||||
import kotlinx.coroutines.sync.withLock
|
||||
import kotlinx.coroutines.withContext
|
||||
import kotlinx.io.core.use
|
||||
import net.mamoe.mirai.Bot
|
||||
import net.mamoe.mirai.network.BotNetworkHandler
|
||||
import java.awt.Image
|
||||
|
@ -12,13 +12,13 @@
|
||||
package net.mamoe.mirai.utils
|
||||
|
||||
import io.ktor.utils.io.ByteReadChannel
|
||||
import io.ktor.utils.io.core.Input
|
||||
import io.ktor.utils.io.core.buildPacket
|
||||
import io.ktor.utils.io.core.copyTo
|
||||
import io.ktor.utils.io.errors.IOException
|
||||
import io.ktor.utils.io.streams.asOutput
|
||||
import kotlinx.coroutines.Dispatchers.IO
|
||||
import kotlinx.coroutines.withContext
|
||||
import kotlinx.io.core.Input
|
||||
import kotlinx.io.core.buildPacket
|
||||
import kotlinx.io.core.copyTo
|
||||
import kotlinx.io.errors.IOException
|
||||
import kotlinx.io.streams.asOutput
|
||||
import net.mamoe.mirai.utils.io.getRandomString
|
||||
import java.awt.image.BufferedImage
|
||||
import java.io.File
|
||||
|
@ -13,7 +13,7 @@ package net.mamoe.mirai.utils
|
||||
|
||||
import io.ktor.client.HttpClient
|
||||
import io.ktor.client.engine.cio.CIO
|
||||
import kotlinx.io.pool.useInstance
|
||||
import io.ktor.utils.io.pool.useInstance
|
||||
import net.mamoe.mirai.utils.io.ByteArrayPool
|
||||
import java.io.*
|
||||
import java.net.InetAddress
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
package net.mamoe.mirai.utils
|
||||
|
||||
import kotlinx.io.core.toByteArray
|
||||
import io.ktor.utils.io.core.toByteArray
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.Transient
|
||||
import kotlinx.serialization.UnstableDefault
|
||||
|
@ -9,13 +9,13 @@
|
||||
|
||||
package net.mamoe.mirai.utils.io
|
||||
|
||||
import io.ktor.utils.io.core.ByteReadPacket
|
||||
import io.ktor.utils.io.core.Closeable
|
||||
import io.ktor.utils.io.core.ExperimentalIoApi
|
||||
import io.ktor.utils.io.streams.readPacketAtMost
|
||||
import io.ktor.utils.io.streams.writePacket
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
import kotlinx.io.core.ByteReadPacket
|
||||
import kotlinx.io.core.Closeable
|
||||
import kotlinx.io.core.ExperimentalIoApi
|
||||
import kotlinx.io.streams.readPacketAtMost
|
||||
import kotlinx.io.streams.writePacket
|
||||
import net.mamoe.mirai.utils.MiraiInternalAPI
|
||||
import java.io.BufferedInputStream
|
||||
import java.io.BufferedOutputStream
|
||||
|
@ -9,12 +9,12 @@
|
||||
|
||||
package net.mamoe.mirai.utils.io
|
||||
|
||||
import io.ktor.utils.io.core.ByteReadPacket
|
||||
import io.ktor.utils.io.core.Closeable
|
||||
import io.ktor.utils.io.nio.readPacketAtMost
|
||||
import io.ktor.utils.io.nio.writePacket
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
import kotlinx.io.core.ByteReadPacket
|
||||
import kotlinx.io.core.Closeable
|
||||
import kotlinx.io.nio.readPacketAtMost
|
||||
import kotlinx.io.nio.writePacket
|
||||
import java.net.InetSocketAddress
|
||||
import java.nio.channels.DatagramChannel
|
||||
import java.nio.channels.ReadableByteChannel
|
||||
|
Loading…
Reference in New Issue
Block a user