mirror of
https://github.com/mamoe/mirai.git
synced 2025-02-01 03:50:18 +08:00
OnlinePushPack JCEs
This commit is contained in:
parent
f18007f650
commit
6e6c1d813d
@ -15,4 +15,30 @@ internal class MsgOnlinePush {
|
||||
@SerialId(4) val pingFlag: Int = 0,
|
||||
@SerialId(9) val generalFlag: Int = 0
|
||||
) : ProtoBuf
|
||||
}
|
||||
|
||||
@Serializable
|
||||
class OnlinePushTrans : ProtoBuf {
|
||||
@Serializable
|
||||
class ExtGroupKeyInfo(
|
||||
@SerialId(1) val curMaxSeq: Int = 0,
|
||||
@SerialId(2) val curTime: Long = 0L
|
||||
) : ProtoBuf
|
||||
|
||||
@Serializable
|
||||
class PbMsgInfo(
|
||||
@SerialId(1) val fromUin: Long = 0L,
|
||||
@SerialId(2) val toUin: Long = 0L,
|
||||
@SerialId(3) val msgType: Int = 0,
|
||||
@SerialId(4) val msgSubtype: Int = 0,
|
||||
@SerialId(5) val msgSeq: Int = 0,
|
||||
@SerialId(6) val msgUid: Long = 0L,
|
||||
@SerialId(7) val msgTime: Int = 0,
|
||||
@SerialId(8) val realMsgTime: Int = 0,
|
||||
@SerialId(9) val nickName: String = "",
|
||||
@SerialId(10) val msgData: ByteArray = EMPTY_BYTE_ARRAY,
|
||||
@SerialId(11) val svrIp: Int = 0,
|
||||
@SerialId(12) val extGroupKeyInfo: OnlinePushTrans.ExtGroupKeyInfo? = null,
|
||||
@SerialId(17) val generalFlag: Int = 0
|
||||
) : ProtoBuf
|
||||
}
|
@ -133,6 +133,7 @@ internal object KnownPacketFactories {
|
||||
object IncomingFactories : List<IncomingPacketFactory<*>> by mutableListOf(
|
||||
OnlinePush.PbPushGroupMsg,
|
||||
OnlinePush.ReqPush,
|
||||
OnlinePush.PbPushTransMsg,
|
||||
MessageSvc.PushNotify,
|
||||
ConfigPushSvc.PushReq
|
||||
|
||||
|
@ -12,13 +12,16 @@ import net.mamoe.mirai.event.broadcast
|
||||
import net.mamoe.mirai.message.GroupMessage
|
||||
import net.mamoe.mirai.qqandroid.QQAndroidBot
|
||||
import net.mamoe.mirai.qqandroid.io.serialization.decodeUniPacket
|
||||
import net.mamoe.mirai.qqandroid.io.serialization.loadAs
|
||||
import net.mamoe.mirai.qqandroid.io.serialization.readProtoBuf
|
||||
import net.mamoe.mirai.qqandroid.network.protocol.data.jce.MsgInfo
|
||||
import net.mamoe.mirai.qqandroid.network.protocol.data.jce.OnlinePushPack
|
||||
import net.mamoe.mirai.qqandroid.network.protocol.data.proto.ImMsgBody
|
||||
import net.mamoe.mirai.qqandroid.network.protocol.data.proto.MsgOnlinePush
|
||||
import net.mamoe.mirai.qqandroid.network.protocol.data.proto.OnlinePushTrans
|
||||
import net.mamoe.mirai.qqandroid.network.protocol.packet.IncomingPacketFactory
|
||||
import net.mamoe.mirai.qqandroid.network.protocol.packet.OutgoingPacket
|
||||
import net.mamoe.mirai.qqandroid.network.protocol.packet.buildResponseUniPacket
|
||||
import net.mamoe.mirai.qqandroid.utils.toMessageChain
|
||||
import net.mamoe.mirai.utils.cryptor.contentToString
|
||||
import net.mamoe.mirai.utils.io.discardExact
|
||||
@ -82,13 +85,29 @@ internal class OnlinePush {
|
||||
}
|
||||
}
|
||||
|
||||
internal object PbPushTransMsg : IncomingPacketFactory<Packet>("OnlinePush.PbPushTransMsg") {
|
||||
|
||||
override suspend fun ByteReadPacket.decode(bot: QQAndroidBot, sequenceId: Int): Packet {
|
||||
val content = this.readProtoBuf(OnlinePushTrans.PbMsgInfo.serializer())
|
||||
println(content.contentToString())
|
||||
return NoPakcet
|
||||
}
|
||||
|
||||
override suspend fun QQAndroidBot.handle(packet: Packet, sequenceId: Int): OutgoingPacket? {
|
||||
return buildResponseUniPacket(client, commandName = "OnlinePush.RespPush", sequenceId = sequenceId) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//0C 01 B1 89 BE 09 5E 3D 72 A6 00 01 73 68 FC 06 00 00 00 3C
|
||||
internal object ReqPush : IncomingPacketFactory<Packet>("OnlinePush.ReqPush") {
|
||||
@ExperimentalUnsignedTypes
|
||||
@UseExperimental(ExperimentalStdlibApi::class)
|
||||
override suspend fun ByteReadPacket.decode(bot: QQAndroidBot, sequenceId: Int): Packet {
|
||||
val reqPushMsg = decodeUniPacket(OnlinePushPack.SvcReqPushMsg.serializer(), "req")
|
||||
println(reqPushMsg.contentToString())
|
||||
reqPushMsg.vMsgInfos.forEach { msgInfo: MsgInfo ->
|
||||
var debug = ""
|
||||
msgInfo.vMsg!!.read {
|
||||
@ -152,9 +171,10 @@ internal class OnlinePush {
|
||||
}
|
||||
}
|
||||
} else if (msgInfo.shMsgType.toInt() == 528) {
|
||||
|
||||
val content = msgInfo.vMsg.loadAs(OnlinePushPack.MsgType0x210.serializer())
|
||||
println(content.contentToString())
|
||||
} else if (msgInfo.shMsgType.toInt() == 4352) {
|
||||
|
||||
println("4352")
|
||||
} else {
|
||||
println("unknown shtype ${msgInfo.shMsgType.toInt()}")
|
||||
}
|
||||
@ -167,7 +187,9 @@ internal class OnlinePush {
|
||||
|
||||
|
||||
override suspend fun QQAndroidBot.handle(packet: Packet, sequenceId: Int): OutgoingPacket? {
|
||||
return null
|
||||
return buildResponseUniPacket(client, commandName = "OnlinePush.RespPush", sequenceId = sequenceId) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -16,7 +16,7 @@ fun main() {
|
||||
println(
|
||||
File(
|
||||
"""
|
||||
E:\Projects\QQAndroidFF\app\src\main\java\tencent\im\statsvc\getonline
|
||||
/Users/jiahua.liu/Desktop/QQAndroid-F/app/src/main/java/com/tencent/pb/onlinepush/
|
||||
""".trimIndent()
|
||||
)
|
||||
.generateUnarrangedClasses().toMutableList().arrangeClasses().joinToString("\n\n")
|
||||
|
@ -49,7 +49,7 @@ class BotConfiguration {
|
||||
/**
|
||||
* 心跳周期. 过长会导致被服务器断开连接.
|
||||
*/
|
||||
var heartbeatPeriodMillis: Long = 30.secondsToMillis
|
||||
var heartbeatPeriodMillis: Long = 300.secondsToMillis
|
||||
/**
|
||||
* 每次心跳时等待结果的时间.
|
||||
* 一旦心跳超时, 整个网络服务将会重启 (将消耗约 5s). 除正在进行的任务 (如图片上传) 会被中断外, 事件和插件均不受影响.
|
||||
|
Loading…
Reference in New Issue
Block a user