Commit 8df1cfff authored by Him188's avatar Him188

Cleanup

parent f2f2de06
...@@ -86,18 +86,18 @@ internal class MemberImpl( ...@@ -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
} }
} }
......
...@@ -360,7 +360,7 @@ internal object KnownPacketFactories { ...@@ -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 { ...@@ -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)
} }
......
...@@ -146,8 +146,7 @@ fun BytePacketBuilder.t116( ...@@ -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( ...@@ -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
} }
......
...@@ -72,8 +72,7 @@ internal object LoginPacket : OutgoingPacketFactory<LoginPacket.LoginPacketRespo ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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()
......
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")
}
}
\ No newline at end of file
...@@ -175,7 +175,7 @@ fun ByteReadPacket.analysisOneFullPacket(): ByteReadPacket = debugIfFail("Failed ...@@ -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()}")
......
...@@ -76,7 +76,7 @@ suspend fun main() { ...@@ -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()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment