Commit ec485a8b authored by Him188's avatar Him188

Cleanup

parent d47c764a
...@@ -181,8 +181,10 @@ internal class QQAndroidBot constructor( ...@@ -181,8 +181,10 @@ internal class QQAndroidBot constructor(
val group = this.getGroupOrNull(eventGroup.id) val group = this.getGroupOrNull(eventGroup.id)
?: kotlin.run { ?: kotlin.run {
if (this == eventBot) { if (this == eventBot) {
error("A ${eventName()} is outdated. Group ${eventGroup.id} not found for bot ${this.id}. " + error(
"This is because bot isn't in the group anymore") "A ${eventName()} is outdated. Group ${eventGroup.id} not found for bot ${this.id}. " +
"This is because bot isn't in the group anymore"
)
} else { } 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}") 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( ...@@ -206,11 +208,11 @@ internal class QQAndroidBot constructor(
} }
} }
override suspend fun acceptInvitedJoinGroupRequest(event: BotInvitedJoinGroupRequestEvent) override suspend fun acceptInvitedJoinGroupRequest(event: BotInvitedJoinGroupRequestEvent) =
= solveInvitedJoinGroupRequest(event, accept = true) solveInvitedJoinGroupRequest(event, accept = true)
override suspend fun ignoreInvitedJoinGroupRequest(event: BotInvitedJoinGroupRequestEvent) override suspend fun ignoreInvitedJoinGroupRequest(event: BotInvitedJoinGroupRequestEvent) =
= solveInvitedJoinGroupRequest(event, accept = false) solveInvitedJoinGroupRequest(event, accept = false)
private suspend fun solveInvitedJoinGroupRequest(event: BotInvitedJoinGroupRequestEvent, accept: Boolean) { private suspend fun solveInvitedJoinGroupRequest(event: BotInvitedJoinGroupRequestEvent, accept: Boolean) {
...@@ -295,6 +297,7 @@ internal abstract class QQAndroidBotBase constructor( ...@@ -295,6 +297,7 @@ internal abstract class QQAndroidBotBase constructor(
} }
override val groups: ContactList<Group> = ContactList(LockFreeLinkedList()) override val groups: ContactList<Group> = ContactList(LockFreeLinkedList())
@JvmField @JvmField
val groupListModifyLock = Mutex() val groupListModifyLock = Mutex()
......
...@@ -445,12 +445,7 @@ internal class QQAndroidBotNetworkHandler(coroutineContext: CoroutineContext, bo ...@@ -445,12 +445,7 @@ internal class QQAndroidBotNetworkHandler(coroutineContext: CoroutineContext, bo
return this.launch( return this.launch(
start = CoroutineStart.ATOMIC start = CoroutineStart.ATOMIC
) { ) {
try { input.use { parsePacket(it) }
input.use { parsePacket(it) }
} catch (e: Exception) {
// 傻逼协程吞异常
logger.error(e)
}
} }
} }
...@@ -620,8 +615,6 @@ internal class QQAndroidBotNetworkHandler(coroutineContext: CoroutineContext, bo ...@@ -620,8 +615,6 @@ internal class QQAndroidBotNetworkHandler(coroutineContext: CoroutineContext, bo
channel.send(delegate) channel.send(delegate)
} }
class TimeoutException(override val message: String?) : Exception()
/** /**
* 发送一个包, 挂起协程直到接收到指定的返回包或超时 * 发送一个包, 挂起协程直到接收到指定的返回包或超时
*/ */
......
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