mirror of
https://github.com/mamoe/mirai.git
synced 2025-04-05 07:10:11 +08:00
Fix build
This commit is contained in:
parent
aa0bf81af1
commit
df56c86fca
mirai-core-qqandroid/src
androidMain/kotlin/net/mamoe/mirai/qqandroid/utils
commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol
mirai-core-timpc/src/commonMain/kotlin/net.mamoe.mirai.timpc
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai
mirai-demos
mirai-demo-1/src/main/java/demo/subscribe
mirai-demo-android/src/main/kotlin/net/mamoe/mirai/demo
mirai-demo-gentleman/src/main/kotlin/demo/gentleman
@ -5,6 +5,7 @@ import android.net.wifi.WifiManager
|
||||
import android.os.Build
|
||||
import android.telephony.TelephonyManager
|
||||
import kotlinx.io.core.toByteArray
|
||||
import net.mamoe.mirai.utils.Context
|
||||
import net.mamoe.mirai.utils.localIpAddress
|
||||
import net.mamoe.mirai.utils.md5
|
||||
import java.io.File
|
||||
|
@ -11,6 +11,6 @@ class SyncCookie(
|
||||
@SerialId(4) val unknown2: Long = 3497826378,
|
||||
@SerialId(5) val const1: Long = 1680172298,
|
||||
@SerialId(6) val const2: Long = 2424173273,
|
||||
@SerialId(7) val unknown3: Long = 83,
|
||||
@SerialId(7) val unknown3: Long = 0,
|
||||
@SerialId(8) val unknown4: Long = 0
|
||||
) : ProtoBuf
|
@ -27,7 +27,6 @@ import net.mamoe.mirai.qqandroid.utils.toRichTextElems
|
||||
import net.mamoe.mirai.utils.cryptor.contentToString
|
||||
import net.mamoe.mirai.utils.currentTimeSeconds
|
||||
import net.mamoe.mirai.utils.io.hexToBytes
|
||||
import net.mamoe.mirai.utils.io.toReadPacket
|
||||
import kotlin.math.absoluteValue
|
||||
import kotlin.random.Random
|
||||
|
||||
@ -61,8 +60,8 @@ internal class MessageSvc {
|
||||
client: QQAndroidClient,
|
||||
msgTime: Long //PbPushMsg.msg.msgHead.msgTime
|
||||
): OutgoingPacket = buildOutgoingUniPacket(
|
||||
client,
|
||||
extraData = EXTRA_DATA.toReadPacket()
|
||||
client//,
|
||||
// extraData = EXTRA_DATA.toReadPacket()
|
||||
) {
|
||||
writeProtoBuf(
|
||||
MsgSvc.PbGetMsgReq.serializer(),
|
||||
|
@ -24,4 +24,10 @@ object TIMPC : BotFactory {
|
||||
* 使用指定的 [配置][configuration] 构造 [Bot] 实例
|
||||
*/
|
||||
fun Bot(qq: Long, password: String, configuration: BotConfiguration = BotConfiguration.Default): Bot = TIMPCBot(BotAccount(qq, password), configuration)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用指定的 [配置][configuration] 构造 [Bot] 实例
|
||||
*/
|
||||
inline fun TIMPC.Bot(qq: Long, password: String, configuration: (BotConfiguration.() -> Unit)): Bot =
|
||||
this.Bot(qq, password, BotConfiguration().apply(configuration))
|
@ -91,7 +91,7 @@ internal class TIMPCBotNetworkHandler internal constructor(coroutineContext: Cor
|
||||
heartbeatJob?.join()
|
||||
}
|
||||
|
||||
override fun dispose(cause: Throwable?) {
|
||||
override fun close(cause: Throwable?) {
|
||||
super.close(cause)
|
||||
|
||||
this.heartbeatJob?.cancel(CancellationException("handler closed"))
|
||||
@ -312,6 +312,7 @@ internal class TIMPCBotNetworkHandler internal constructor(coroutineContext: Cor
|
||||
else -> error("No decrypter is found")
|
||||
} as? D ?: error("Internal error: could not cast decrypter which is found for factory to class Decrypter")
|
||||
|
||||
@UseExperimental(MiraiInternalAPI::class)
|
||||
suspend fun onPacketReceived(packet: Any) {//complex function, but it doesn't matter
|
||||
when (packet) {
|
||||
is TouchPacket.TouchResponse.OK -> {
|
||||
|
@ -4,6 +4,7 @@ package net.mamoe.mirai
|
||||
|
||||
import net.mamoe.mirai.utils.BotConfiguration
|
||||
import net.mamoe.mirai.utils.Context
|
||||
import net.mamoe.mirai.utils.ContextImpl
|
||||
|
||||
// Do not use ServiceLoader. Probably not working on MPP
|
||||
@PublishedApi
|
||||
@ -41,4 +42,17 @@ fun Bot(context: Context, qq: Long, password: String, configuration: BotConfigur
|
||||
* 加载现有协议的 [BotFactory], 并使用指定的 [配置][configuration] 构造 [Bot] 实例
|
||||
*/
|
||||
inline fun Bot(context: Context, qq: Long, password: String, configuration: (BotConfiguration.() -> Unit)): Bot =
|
||||
factory.Bot(context, qq, password, configuration)
|
||||
factory.Bot(context, qq, password, configuration)
|
||||
|
||||
|
||||
/**
|
||||
* 加载现有协议的 [BotFactory], 并使用指定的 [配置][configuration] 构造 [Bot] 实例
|
||||
*/
|
||||
fun Bot(qq: Long, password: String, configuration: BotConfiguration = BotConfiguration.Default): Bot =
|
||||
factory.Bot(ContextImpl(), qq, password, configuration)
|
||||
|
||||
/**
|
||||
* 加载现有协议的 [BotFactory], 并使用指定的 [配置][configuration] 构造 [Bot] 实例
|
||||
*/
|
||||
inline fun Bot(qq: Long, password: String, configuration: (BotConfiguration.() -> Unit)): Bot =
|
||||
factory.Bot(ContextImpl(), qq, password, configuration)
|
@ -17,6 +17,7 @@ import net.mamoe.mirai.message.data.ImageId
|
||||
import net.mamoe.mirai.message.data.PlainText
|
||||
import net.mamoe.mirai.message.data.firstOrNull
|
||||
import net.mamoe.mirai.message.sendAsImageTo
|
||||
import net.mamoe.mirai.timpc.Bot
|
||||
import net.mamoe.mirai.timpc.TIMPC
|
||||
import net.mamoe.mirai.utils.suspendToExternalImage
|
||||
import java.io.File
|
||||
@ -39,10 +40,8 @@ private fun readTestAccount(): BotAccount? {
|
||||
@Suppress("UNUSED_VARIABLE")
|
||||
suspend fun main() {
|
||||
val bot = TIMPC.Bot( // JVM 下也可以不写 `TIMPC.` 引用顶层函数
|
||||
readTestAccount() ?: BotAccount(//填写你的账号
|
||||
id = 1994701121,
|
||||
passwordPlainText = "123456"
|
||||
)
|
||||
1994701121,
|
||||
"123456"
|
||||
) {
|
||||
// 覆盖默认的配置
|
||||
randomDeviceName = false
|
||||
@ -134,6 +133,7 @@ fun Bot.messageDSL() {
|
||||
reply(message)
|
||||
}
|
||||
|
||||
listener.complete() // 停止监听
|
||||
|
||||
// 自定义的 filter, filter 中 it 为转为 String 的消息.
|
||||
// 也可以用任何能在处理时使用的变量, 如 subject, sender, message
|
||||
|
@ -14,6 +14,7 @@ import kotlinx.io.core.IoBuffer
|
||||
import kotlinx.io.core.readBytes
|
||||
import net.mamoe.mirai.Bot
|
||||
import net.mamoe.mirai.event.subscribeMessages
|
||||
import net.mamoe.mirai.timpc.Bot
|
||||
import net.mamoe.mirai.timpc.TIMPC
|
||||
import net.mamoe.mirai.utils.LoginFailedException
|
||||
import net.mamoe.mirai.utils.LoginSolver
|
||||
|
@ -8,7 +8,6 @@ import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import net.mamoe.mirai.Bot
|
||||
import net.mamoe.mirai.BotAccount
|
||||
import net.mamoe.mirai.alsoLogin
|
||||
import net.mamoe.mirai.contact.MemberPermission
|
||||
import net.mamoe.mirai.event.Subscribable
|
||||
@ -23,32 +22,18 @@ import net.mamoe.mirai.message.data.Image
|
||||
import net.mamoe.mirai.message.data.buildXMLMessage
|
||||
import net.mamoe.mirai.message.data.getValue
|
||||
import net.mamoe.mirai.message.sendAsImageTo
|
||||
import net.mamoe.mirai.utils.ContextImpl
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
import javax.swing.filechooser.FileSystemView
|
||||
import kotlin.random.Random
|
||||
|
||||
private fun readTestAccount(): BotAccount? {
|
||||
val file = File("testAccount.txt")
|
||||
if (!file.exists() || !file.canRead()) {
|
||||
return null
|
||||
}
|
||||
|
||||
val lines = file.readLines()
|
||||
return try {
|
||||
BotAccount(lines[0].toLong(), lines[1])
|
||||
} catch (e: Throwable) {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("UNUSED_VARIABLE")
|
||||
suspend fun main() {
|
||||
val bot = Bot(
|
||||
readTestAccount() ?: BotAccount(
|
||||
id = 913366033,
|
||||
passwordPlainText = "a18260132383"
|
||||
)
|
||||
ContextImpl(),
|
||||
913366033,
|
||||
"a18260132383"
|
||||
) {
|
||||
// override config here.
|
||||
}.alsoLogin()
|
||||
|
Loading…
Reference in New Issue
Block a user