BotFactory依次创建两个bot时出现exception
-
使用2.6.1 mirai-core。
可复现。BotFactory创建第一个bot并执行bot.login(),等第一个bot可以收到群消息事件时,再BotFactory创建第二个bot并执行bot.login()。此时异常被打印为error级日志, 第二个bot可继续登录和正常工作。
19|mirai-server | 2021-06-17 12:29:33 E/Bot 277****622: Failed to load account secrets from local cache. Invalidating cache...
19|mirai-server | net.mamoe.mirai.internal.utils.crypto.DecryptionFailedException
19|mirai-server | at net.mamoe.mirai.internal.utils.crypto.TEA.fail(TEA.kt:295)
19|mirai-server | at net.mamoe.mirai.internal.utils.crypto.TEA.access$fail(TEA.kt:33)
19|mirai-server | at net.mamoe.mirai.internal.utils.crypto.TEA$doOption$7.invoke(TEA.kt:271)
19|mirai-server | at net.mamoe.mirai.internal.utils.crypto.TEA.doOption(TEA.kt:291)
19|mirai-server | at net.mamoe.mirai.internal.utils.crypto.TEA.decrypt(TEA.kt:315)
19|mirai-server | at net.mamoe.mirai.internal.utils.crypto.TEA.decrypt$default(TEA.kt:314)
19|mirai-server | at net.mamoe.mirai.internal.QQAndroidBot.loadSecretsFromCacheOrCreate(QQAndroidBot.kt:108)
19|mirai-server | at net.mamoe.mirai.internal.QQAndroidBot.initClient(QQAndroidBot.kt:133)
19|mirai-server | at net.mamoe.mirai.internal.QQAndroidBot.<init>(QQAndroidBot.kt:125)
19|mirai-server | at net.mamoe.mirai.internal.BotFactoryImpl.newBot(BotFactory.kt:34)
19|mirai-server | at net.mamoe.mirai.BotFactory$INSTANCE.newBot(BotFactory.kt:115)
19|mirai-server | at com.hundun.mirai.server.SpringConsole$BotThread.run(SpringConsole.java:76)
看下了net.mamoe.mirai.internal.QQAndroidBot.loadSecretsFromCacheOrCreate源码,猜测是第二次创建时检测到第一次的缓存存在就试图去取。
应该改为根据账号区分缓存,或是无缓存的账号只需要info级别的日志?
-
-
workdingDir
inBotConfiguration
-
补充:
分别使用了两个deviceInfoFileName构造BotConfigurationString deviceInfoFileName = botPrivateSettings.getBotAccount() + "_device.json"; Bot miraiBot = BotFactory.INSTANCE.newBot(botPrivateSettings.getBotAccount(), botPrivateSettings.getBotPwd(), new BotConfiguration() { { fileBasedDeviceInfo(deviceInfoFileName); setProtocol(MiraiProtocol.ANDROID_PHONE); enableContactCache(); } });
是建议两个deviceInfoFileName处于不同文件夹吗?(因为还要判断和自动创建文件夹就偷懒了
-
-
好了