Query self profile when missing nickname; Fix #1023

This commit is contained in:
Karlatemp 2021-02-20 20:50:44 +08:00
parent ce06ce85f0
commit f12f78a55f
No known key found for this signature in database
GPG Key ID: 21FBDDF664FF06F8

View File

@ -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" }