mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-19 21:49:16 +08:00
Retry fetch group on fail
This commit is contained in:
parent
2b4d9a8e79
commit
fc4fb4f297
@ -215,12 +215,11 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler
|
||||
.sendAndExpect<FriendList.GetTroopListSimplify.Response>(retry = 2)
|
||||
|
||||
troopListData.groups.forEach { troopNum ->
|
||||
launch {
|
||||
|
||||
try {
|
||||
suspend fun loadGroup() {
|
||||
tryNTimesOrException(3) {
|
||||
bot.groups.delegate.addLast(
|
||||
@Suppress("DuplicatedCode")
|
||||
GroupImpl(
|
||||
(GroupImpl(
|
||||
bot = bot,
|
||||
coroutineContext = bot.coroutineContext,
|
||||
id = troopNum.groupCode,
|
||||
@ -242,14 +241,21 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler
|
||||
this.delegate.groupCode = troopNum.groupCode
|
||||
},
|
||||
members = bot.queryGroupMemberList(troopNum.groupUin, troopNum.groupCode, troopNum.dwGroupOwnerUin)
|
||||
))
|
||||
)
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
}?.let {
|
||||
logger.error("群${troopNum.groupCode}的列表拉取失败, 一段时间后将会重试")
|
||||
logger.error(e)
|
||||
logger.error(it)
|
||||
this@QQAndroidBotNetworkHandler.launch {
|
||||
delay(10_000)
|
||||
loadGroup()
|
||||
}
|
||||
}
|
||||
}
|
||||
launch {
|
||||
loadGroup()
|
||||
}
|
||||
}
|
||||
logger.info("群组列表与群成员加载完成, 共 ${troopListData.groups.size}个")
|
||||
} catch (e: Exception) {
|
||||
logger.error("加载组信息失败|一般这是由于加载过于频繁导致/将以热加载方式加载群列表")
|
||||
|
Loading…
Reference in New Issue
Block a user