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 // https://github.com/mamoe/mirai/issues/1019
kotlin.runCatching { kotlin.runCatching {
nick bot.nick
}.onFailure { }.onFailure {
throw contextualBugReportException( bot.asQQAndroidBot().nick = MiraiImpl.queryProfile(bot, bot.id).nickname
context = "Bot login", if (bot.nick.isBlank()) {
forDebug = it.toString(), logger.warning { "Unable to fetch nickname of bot." }
e = it, }
)
} }
logger.info { "Login successful" } logger.info { "Login successful" }