Merge remote-tracking branch 'upsteam/master'

This commit is contained in:
ryoii 2020-02-04 21:08:26 +08:00
commit 2c9d38dffa
10 changed files with 19 additions and 56 deletions

View File

@ -86,18 +86,18 @@ internal class MemberImpl(
} else if (myPermission == MemberPermission.MEMBER) { } else if (myPermission == MemberPermission.MEMBER) {
return false return false
} }
try { return try {
bot.network.run { bot.network.run {
val response = TroopManagement.Mute( TroopManagement.Mute(
client = bot.client, client = bot.client,
groupCode = group.id, groupCode = group.id,
memberUin = this@MemberImpl.id, memberUin = this@MemberImpl.id,
timeInSecond = durationSeconds timeInSecond = durationSeconds
).sendAndExpect<TroopManagement.Mute.Response>() ).sendAndExpect<TroopManagement.Mute.Response>()
} }
return true true
} catch (e: Exception) { } catch (e: Exception) {
return false false
} }
} }

View File

@ -89,8 +89,7 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler
is LoginPacket.LoginPacketResponse.DeviceLockLogin -> { is LoginPacket.LoginPacketResponse.DeviceLockLogin -> {
response = LoginPacket.SubCommand20( response = LoginPacket.SubCommand20(
bot.client, bot.client,
response.t402, response.t402
response.t403
).sendAndExpect() ).sendAndExpect()
continue@mainloop continue@mainloop
} }

View File

@ -28,8 +28,8 @@ internal data class RequestPushNotify(
@Suppress("ArrayInDataClass") @Suppress("ArrayInDataClass")
@Serializable @Serializable
internal data class MsgInfo( internal data class MsgInfo(
@SerialId(0) val lFromUin: Long = 0L, @SerialId(0) val lFromUin: Long? = 0L,
@SerialId(1) val uMsgTime: Long = 0L, @SerialId(1) val uMsgTime: Long? = 0L,
@SerialId(2) val shMsgType: Short, @SerialId(2) val shMsgType: Short,
@SerialId(3) val shMsgSeq: Short, @SerialId(3) val shMsgSeq: Short,
@SerialId(4) val strMsg: String?, @SerialId(4) val strMsg: String?,

View File

@ -360,7 +360,7 @@ internal object KnownPacketFactories {
} }
@UseExperimental(ExperimentalContracts::class) @UseExperimental(ExperimentalContracts::class)
internal inline fun <I : IoBuffer, R> I.withUse(block: I.() -> R): R { internal inline fun <R> IoBuffer.withUse(block: IoBuffer.() -> R): R {
contract { contract {
callsInPlace(block, kotlin.contracts.InvocationKind.EXACTLY_ONCE) callsInPlace(block, kotlin.contracts.InvocationKind.EXACTLY_ONCE)
} }
@ -372,7 +372,7 @@ internal inline fun <I : IoBuffer, R> I.withUse(block: I.() -> R): R {
} }
@UseExperimental(ExperimentalContracts::class) @UseExperimental(ExperimentalContracts::class)
internal inline fun <I : ByteReadPacket, R> I.withUse(block: I.() -> R): R { internal inline fun <R> ByteReadPacket.withUse(block: ByteReadPacket.() -> R): R {
contract { contract {
callsInPlace(block, kotlin.contracts.InvocationKind.EXACTLY_ONCE) callsInPlace(block, kotlin.contracts.InvocationKind.EXACTLY_ONCE)
} }

View File

@ -146,8 +146,7 @@ fun BytePacketBuilder.t116(
fun BytePacketBuilder.t100( fun BytePacketBuilder.t100(
appId: Long = 16, appId: Long = 16,
subAppId: Long = 537062845, subAppId: Long = 537062845,
appClientVersion: Int, appClientVersion: Int
sigMap: Int
) { ) {
writeShort(0x100) writeShort(0x100)
writeShortLVPacket { writeShortLVPacket {
@ -156,7 +155,7 @@ fun BytePacketBuilder.t100(
writeInt(appId.toInt()) writeInt(appId.toInt())
writeInt(subAppId.toInt()) writeInt(subAppId.toInt())
writeInt(appClientVersion) writeInt(appClientVersion)
writeInt(34869472) // 34869472? writeInt(34869472) // sigMap, 34869472?
} shouldEqualsTo 22 } shouldEqualsTo 22
} }

View File

@ -72,8 +72,7 @@ internal object LoginPacket : OutgoingPacketFactory<LoginPacket.LoginPacketRespo
@UseExperimental(MiraiInternalAPI::class) @UseExperimental(MiraiInternalAPI::class)
operator fun invoke( operator fun invoke(
client: QQAndroidClient, client: QQAndroidClient,
t402: ByteArray, t402: ByteArray
t403: ByteArray
): OutgoingPacket = buildLoginOutgoingPacket(client, bodyType = 2) { sequenceId -> ): OutgoingPacket = buildLoginOutgoingPacket(client, bodyType = 2) { sequenceId ->
writeSsoPacket(client, subAppId, commandName, sequenceId = sequenceId) { writeSsoPacket(client, subAppId, commandName, sequenceId = sequenceId) {
writeOicqRequestPacket(client, EncryptMethodECDH7(client.ecdh), 0x0810) { writeOicqRequestPacket(client, EncryptMethodECDH7(client.ecdh), 0x0810) {
@ -96,10 +95,7 @@ internal object LoginPacket : OutgoingPacketFactory<LoginPacket.LoginPacketRespo
private const val subAppId = 537062845L private const val subAppId = 537062845L
@UseExperimental(MiraiInternalAPI::class) @UseExperimental(MiraiInternalAPI::class)
operator fun invoke( operator fun invoke(
client: QQAndroidClient, client: QQAndroidClient
t174: ByteArray,
t402: ByteArray,
phoneNumber: String
): OutgoingPacket = buildLoginOutgoingPacket(client, bodyType = 2) { sequenceId -> ): OutgoingPacket = buildLoginOutgoingPacket(client, bodyType = 2) { sequenceId ->
writeSsoPacket(client, subAppId, commandName, sequenceId = sequenceId, unknownHex = "01 00 00 00 00 00 00 00 00 00 01 00") { writeSsoPacket(client, subAppId, commandName, sequenceId = sequenceId, unknownHex = "01 00 00 00 00 00 00 00 00 00 01 00") {
writeOicqRequestPacket(client, EncryptMethodECDH7(client.ecdh), 0x0810) { writeOicqRequestPacket(client, EncryptMethodECDH7(client.ecdh), 0x0810) {
@ -163,7 +159,7 @@ internal object LoginPacket : OutgoingPacketFactory<LoginPacket.LoginPacketRespo
if (ConfigManager.get_loginWithPicSt()) appIdList = longArrayOf(1600000226L) if (ConfigManager.get_loginWithPicSt()) appIdList = longArrayOf(1600000226L)
*/ */
t116(client.miscBitMap, client.subSigMap) t116(client.miscBitMap, client.subSigMap)
t100(appId, subAppId, client.appClientVersion, client.mainSigMap or 0xC0) t100(appId, subAppId, client.appClientVersion)
t107(0) t107(0)
// t108(byteArrayOf()) // t108(byteArrayOf())
@ -310,7 +306,7 @@ internal object LoginPacket : OutgoingPacketFactory<LoginPacket.LoginPacketRespo
@UseExperimental(MiraiDebugAPI::class) @UseExperimental(MiraiDebugAPI::class)
override suspend fun ByteReadPacket.decode(bot: QQAndroidBot): LoginPacketResponse { override suspend fun ByteReadPacket.decode(bot: QQAndroidBot): LoginPacketResponse {
val subCommand = readUShort().toInt() discardExact(2) // subCommand
// println("subCommand=$subCommand") // println("subCommand=$subCommand")
val type = readUByte() val type = readUByte()
// println("type=$type") // println("type=$type")
@ -703,7 +699,7 @@ internal object LoginPacket : OutgoingPacketFactory<LoginPacket.LoginPacketRespo
private fun QQAndroidClient.analysisTlv149(t149: ByteArray): LoginPacketResponse.Error { private fun QQAndroidClient.analysisTlv149(t149: ByteArray): LoginPacketResponse.Error {
return t149.read { return t149.read {
val type: Short = readShort() discardExact(2) //type
val title: String = readUShortLVString() val title: String = readUShortLVString()
val content: String = readUShortLVString() val content: String = readUShortLVString()
val otherInfo: String = readUShortLVString() val otherInfo: String = readUShortLVString()

View File

@ -1,31 +0,0 @@
package net.mamoe.mirai.qqandroid.network.protocol.packet.login
import kotlinx.io.core.ByteReadPacket
import net.mamoe.mirai.data.Packet
import net.mamoe.mirai.qqandroid.QQAndroidBot
import net.mamoe.mirai.qqandroid.network.QQAndroidClient
import net.mamoe.mirai.qqandroid.network.protocol.packet.*
internal object TransEmpPacket : OutgoingPacketFactory<TransEmpPacket.Response>("wtlogin.trans_emp") {
private const val appId = 16L
private const val subAppId = 537062845L
@Suppress("FunctionName")
fun SubCommand1(
client: QQAndroidClient
): OutgoingPacket = buildLoginOutgoingPacket(client, bodyType = 2) {
writeOicqRequestPacket(client, EncryptMethodECDH135(client.ecdh), TODO()) {
// oicq.wlogin_sdk.request.trans_emp_1#packTransEmpBody
}
}
object Response : Packet
override suspend fun ByteReadPacket.decode(bot: QQAndroidBot): Response {
TODO("not implemented")
}
}

View File

@ -175,7 +175,7 @@ fun ByteReadPacket.analysisOneFullPacket(): ByteReadPacket = debugIfFail("Failed
readShort().toInt().takeIf { it != 8001 }?.let { readShort().toInt().takeIf { it != 8001 }?.let {
println("这个包不是 oicqRequest") println("这个包不是 oicqRequest")
return@debugIfFail this return@debugIfFail this
println(" got new protocolVersion=$it") //println(" got new protocolVersion=$it")
} }
val commandId = readUShort().toInt() val commandId = readUShort().toInt()
println(" commandId=0x${commandId.toShort().toUHexString()}") println(" commandId=0x${commandId.toShort().toUHexString()}")

View File

@ -11,7 +11,7 @@ import net.mamoe.mirai.utils.MiraiInternalAPI
*/ */
class At @MiraiInternalAPI constructor(val target: Long, val display: String) : Message { class At @MiraiInternalAPI constructor(val target: Long, val display: String) : Message {
@UseExperimental(MiraiInternalAPI::class) @UseExperimental(MiraiInternalAPI::class)
constructor(member: Member) : this(member.id, member.groupCard) constructor(member: Member) : this(member.id, "@${member.groupCard}")
override fun toString(): String = display override fun toString(): String = display

View File

@ -76,7 +76,7 @@ suspend fun main() {
startsWith("profile", removePrefix = true) { startsWith("profile", removePrefix = true) {
val account = it.trim() val account = it.trim()
if (account.isNotEmpty()) { if (account.isNotEmpty()) {
account.toLong().qq() bot.getFriend(account.toLong())
} else { } else {
sender sender
}.queryProfile().toString().reply() }.queryProfile().toString().reply()