mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-05 07:30:09 +08:00
Fix unresolved references
This commit is contained in:
parent
c2d2be6c0a
commit
79fe9076f5
@ -5,16 +5,19 @@ package net.mamoe.mirai.timpc.network.packet.event
|
||||
import kotlinx.io.core.ByteReadPacket
|
||||
import kotlinx.io.core.discardExact
|
||||
import net.mamoe.mirai.Bot
|
||||
import net.mamoe.mirai.network.data.Packet
|
||||
import net.mamoe.mirai.network.data.EventPacket
|
||||
import net.mamoe.mirai.timpc.network.packet.PacketVersion
|
||||
import net.mamoe.mirai.utils.io.readQQ
|
||||
import net.mamoe.mirai.contact.Member
|
||||
import net.mamoe.mirai.contact.Group
|
||||
|
||||
|
||||
data class MemberPermissionChangePacket(
|
||||
val groupId: Long,
|
||||
val qq: Long,
|
||||
val member: Member,
|
||||
val kind: Kind
|
||||
) : Packet {
|
||||
) : EventPacket {
|
||||
val group: Group get() = member.group
|
||||
|
||||
enum class Kind {
|
||||
/**
|
||||
* 变成管理员
|
||||
@ -35,12 +38,13 @@ internal object GroupMemberPermissionChangedEventFactory : KnownEventParserAndHa
|
||||
// 取消管理员
|
||||
// 00 00 00 08 00 0A 00 04 01 00 00 00 22 96 29 7B 01 00 76 E4 B8 DD 00
|
||||
discardExact(remaining - 5)
|
||||
val group = bot.getGroup(identity.from)
|
||||
val qq = readQQ()
|
||||
val kind = when (readByte().toInt()) {
|
||||
0x00 -> MemberPermissionChangePacket.Kind.NO_LONGER_OPERATOR
|
||||
0x01 -> MemberPermissionChangePacket.Kind.BECOME_OPERATOR
|
||||
else -> error("Could not determine permission change kind")
|
||||
}
|
||||
return MemberPermissionChangePacket(identity.from, qq, kind)
|
||||
return MemberPermissionChangePacket(group.getMember(qq), kind)
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlinx.coroutines.withContext
|
||||
import net.mamoe.mirai.Bot
|
||||
import net.mamoe.mirai.network.data.LoginResult
|
||||
import net.mamoe.mirai.timpc.TIMPC
|
||||
import java.util.*
|
||||
|
||||
@ -47,12 +46,12 @@ suspend fun main() {
|
||||
if (password.endsWith(".")) password.substring(0, password.length - 1) else password
|
||||
)
|
||||
|
||||
withContext(Dispatchers.IO) {
|
||||
bot.login()
|
||||
}.let { state ->
|
||||
if (state == LoginResult.SUCCESS) {
|
||||
goodBotList.add(bot)
|
||||
try {
|
||||
withContext(Dispatchers.IO) {
|
||||
bot.login()
|
||||
}
|
||||
goodBotList.add(bot)
|
||||
} catch (ignored: Exception) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,8 +13,8 @@ import kotlinx.coroutines.launch
|
||||
import kotlinx.io.core.readBytes
|
||||
import net.mamoe.mirai.Bot
|
||||
import net.mamoe.mirai.event.subscribeMessages
|
||||
import net.mamoe.mirai.network.data.LoginResult
|
||||
import net.mamoe.mirai.timpc.TIMPC
|
||||
import net.mamoe.mirai.utils.LoginFailedException
|
||||
import java.lang.ref.WeakReference
|
||||
|
||||
class MiraiService : Service() {
|
||||
@ -42,18 +42,18 @@ class MiraiService : Service() {
|
||||
private fun login(qq: Long, pwd: String) {
|
||||
GlobalScope.launch {
|
||||
mBot = TIMPC.Bot(qq, pwd).apply {
|
||||
val loginResult = login {
|
||||
captchaSolver = {
|
||||
val bytes = it.readBytes()
|
||||
val bitmap = BitmapFactory.decodeByteArray(bytes, 0, bytes.size)
|
||||
mCaptchaDeferred = CompletableDeferred()
|
||||
mCallback?.get()?.onCaptcha(bitmap)
|
||||
mCaptchaDeferred.await()
|
||||
try {
|
||||
login {
|
||||
captchaSolver = {
|
||||
val bytes = it.readBytes()
|
||||
val bitmap = BitmapFactory.decodeByteArray(bytes, 0, bytes.size)
|
||||
mCaptchaDeferred = CompletableDeferred()
|
||||
mCallback?.get()?.onCaptcha(bitmap)
|
||||
mCaptchaDeferred.await()
|
||||
}
|
||||
}
|
||||
}
|
||||
if (loginResult == LoginResult.SUCCESS) {
|
||||
mCallback?.get()?.onSuccess()
|
||||
} else {
|
||||
} catch (e: LoginFailedException) {
|
||||
mCallback?.get()?.onFailed()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user