浏览代码

Query self profile when missing nickname; Fix #1023

Karlatemp 5 年之前
父节点
当前提交
f12f78a55f
共有 1 个文件被更改,包括 5 次插入6 次删除
  1. 5 6
      mirai-core/src/commonMain/kotlin/AbstractBot.kt

+ 5 - 6
mirai-core/src/commonMain/kotlin/AbstractBot.kt

@@ -292,13 +292,12 @@ internal abstract class AbstractBot<N : BotNetworkHandler> constructor(
 
             // https://github.com/mamoe/mirai/issues/1019
             kotlin.runCatching {
-                nick
+                bot.nick
             }.onFailure {
-                throw contextualBugReportException(
-                    context = "Bot login",
-                    forDebug = it.toString(),
-                    e = it,
-                )
+                bot.asQQAndroidBot().nick = MiraiImpl.queryProfile(bot, bot.id).nickname
+                if (bot.nick.isBlank()) {
+                    logger.warning { "Unable to fetch nickname of bot." }
+                }
             }
 
             logger.info { "Login successful" }