From ec485a8b6f96a2091ce9b0911a3a5803286f6ea4 Mon Sep 17 00:00:00 2001 From: Him188 Date: Fri, 22 May 2020 00:16:10 +0800 Subject: [PATCH] Cleanup --- .../mamoe/mirai/qqandroid/QQAndroidBot.common.kt | 15 +++++++++------ .../network/QQAndroidBotNetworkHandler.kt | 9 +-------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.common.kt b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.common.kt index 9920c0f7d..b430bb92a 100644 --- a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.common.kt +++ b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.common.kt @@ -181,8 +181,10 @@ internal class QQAndroidBot constructor( val group = this.getGroupOrNull(eventGroup.id) ?: kotlin.run { if (this == eventBot) { - error("A ${eventName()} is outdated. Group ${eventGroup.id} not found for bot ${this.id}. " + - "This is because bot isn't in the group anymore") + error( + "A ${eventName()} is outdated. Group ${eventGroup.id} not found for bot ${this.id}. " + + "This is because bot isn't in the group anymore" + ) } else { error("A ${eventName()} is from bot ${eventBot.id}, but you are trying to respond it using bot ${this.id} who isn't a member of the group ${eventGroup.id}") } @@ -206,11 +208,11 @@ internal class QQAndroidBot constructor( } } - override suspend fun acceptInvitedJoinGroupRequest(event: BotInvitedJoinGroupRequestEvent) - = solveInvitedJoinGroupRequest(event, accept = true) + override suspend fun acceptInvitedJoinGroupRequest(event: BotInvitedJoinGroupRequestEvent) = + solveInvitedJoinGroupRequest(event, accept = true) - override suspend fun ignoreInvitedJoinGroupRequest(event: BotInvitedJoinGroupRequestEvent) - = solveInvitedJoinGroupRequest(event, accept = false) + override suspend fun ignoreInvitedJoinGroupRequest(event: BotInvitedJoinGroupRequestEvent) = + solveInvitedJoinGroupRequest(event, accept = false) private suspend fun solveInvitedJoinGroupRequest(event: BotInvitedJoinGroupRequestEvent, accept: Boolean) { @@ -295,6 +297,7 @@ internal abstract class QQAndroidBotBase constructor( } override val groups: ContactList = ContactList(LockFreeLinkedList()) + @JvmField val groupListModifyLock = Mutex() diff --git a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/QQAndroidBotNetworkHandler.kt b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/QQAndroidBotNetworkHandler.kt index c96fe77dd..abb7ac691 100644 --- a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/QQAndroidBotNetworkHandler.kt +++ b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/QQAndroidBotNetworkHandler.kt @@ -445,12 +445,7 @@ internal class QQAndroidBotNetworkHandler(coroutineContext: CoroutineContext, bo return this.launch( start = CoroutineStart.ATOMIC ) { - try { - input.use { parsePacket(it) } - } catch (e: Exception) { - // 傻逼协程吞异常 - logger.error(e) - } + input.use { parsePacket(it) } } } @@ -620,8 +615,6 @@ internal class QQAndroidBotNetworkHandler(coroutineContext: CoroutineContext, bo channel.send(delegate) } - class TimeoutException(override val message: String?) : Exception() - /** * 发送一个包, 挂起协程直到接收到指定的返回包或超时 */