Commit fc4fb4f2 authored by Him188's avatar Him188

Retry fetch group on fail

parent 2b4d9a8e
...@@ -215,12 +215,11 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler ...@@ -215,12 +215,11 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler
.sendAndExpect<FriendList.GetTroopListSimplify.Response>(retry = 2) .sendAndExpect<FriendList.GetTroopListSimplify.Response>(retry = 2)
troopListData.groups.forEach { troopNum -> troopListData.groups.forEach { troopNum ->
launch { suspend fun loadGroup() {
tryNTimesOrException(3) {
try {
bot.groups.delegate.addLast( bot.groups.delegate.addLast(
@Suppress("DuplicatedCode") @Suppress("DuplicatedCode")
GroupImpl( (GroupImpl(
bot = bot, bot = bot,
coroutineContext = bot.coroutineContext, coroutineContext = bot.coroutineContext,
id = troopNum.groupCode, id = troopNum.groupCode,
...@@ -242,13 +241,20 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler ...@@ -242,13 +241,20 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler
this.delegate.groupCode = troopNum.groupCode this.delegate.groupCode = troopNum.groupCode
}, },
members = bot.queryGroupMemberList(troopNum.groupUin, troopNum.groupCode, troopNum.dwGroupOwnerUin) members = bot.queryGroupMemberList(troopNum.groupUin, troopNum.groupCode, troopNum.dwGroupOwnerUin)
) ))
) )
} catch (e: Exception) { }?.let {
logger.error("群${troopNum.groupCode}的列表拉取失败, 一段时间后将会重试") logger.error("群${troopNum.groupCode}的列表拉取失败, 一段时间后将会重试")
logger.error(e) logger.error(it)
this@QQAndroidBotNetworkHandler.launch {
delay(10_000)
loadGroup()
}
} }
} }
launch {
loadGroup()
}
} }
logger.info("群组列表与群成员加载完成, 共 ${troopListData.groups.size}个") logger.info("群组列表与群成员加载完成, 共 ${troopListData.groups.size}个")
} catch (e: Exception) { } catch (e: 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