diff --git a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.kt b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.kt index 8ea181156..687f4ef0b 100644 --- a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.kt +++ b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.kt @@ -87,6 +87,9 @@ internal abstract class QQAndroidBotBase constructor( override val friends: ContactList = ContactList(LockFreeLinkedList()) + override lateinit var nick: String + internal set + override val selfQQ: QQ by lazy { @OptIn(LowLevelAPI::class) _lowLevelNewQQ(object : FriendInfo { diff --git a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/QQAndroidBotNetworkHandler.kt b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/QQAndroidBotNetworkHandler.kt index 5e8ca7509..79f830469 100644 --- a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/QQAndroidBotNetworkHandler.kt +++ b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/QQAndroidBotNetworkHandler.kt @@ -222,6 +222,14 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler logger.error("稍后重试加载好友列表") return@loadFriends } + + // self info + data.selfInfo?.apply { + bot.nick = nick ?: "" +// bot.remark = remark ?: "" +// bot.sex = sex + } + totalFriendCount = data.totalFriendCount data.friendList.forEach { // atomic add diff --git a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/list/FriendList.kt b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/list/FriendList.kt index afba1794b..810264d7b 100644 --- a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/list/FriendList.kt +++ b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/list/FriendList.kt @@ -126,6 +126,7 @@ internal class FriendList { OutgoingPacketFactory("friendlist.getFriendGroupList") { class Response( + val selfInfo: FriendInfo?, val totalFriendCount: Short, val friendList: List ) : Packet { @@ -135,6 +136,7 @@ internal class FriendList { override suspend fun ByteReadPacket.decode(bot: QQAndroidBot): Response { val res = this.decodeUniPacket(GetFriendListResp.serializer()) return Response( + res.stSelfInfo, res.totoalFriendCount, res.vecFriendInfo.orEmpty() ) diff --git a/mirai-core/src/androidMain/kotlin/net/mamoe/mirai/Bot.kt b/mirai-core/src/androidMain/kotlin/net/mamoe/mirai/Bot.kt index 6e196b5fa..55cfe557b 100644 --- a/mirai-core/src/androidMain/kotlin/net/mamoe/mirai/Bot.kt +++ b/mirai-core/src/androidMain/kotlin/net/mamoe/mirai/Bot.kt @@ -70,9 +70,7 @@ actual abstract class Bot actual constructor() : CoroutineScope, LowLevelBotAPIA /** * 昵称 */ - @MiraiExperimentalAPI("还未支持") - actual val nick: String - get() = ""// TODO("bot 昵称获取") + actual abstract val nick: String /** * 日志记录器 diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/Bot.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/Bot.kt index d14132c07..7a770c21a 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/Bot.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/Bot.kt @@ -90,8 +90,7 @@ expect abstract class Bot() : CoroutineScope, LowLevelBotAPIAccessor { /** * 昵称 */ - @MiraiExperimentalAPI("还未支持") - val nick: String + abstract val nick: String /** * 日志记录器 diff --git a/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/Bot.kt b/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/Bot.kt index 7b328c255..c75272acd 100644 --- a/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/Bot.kt +++ b/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/Bot.kt @@ -80,9 +80,7 @@ actual abstract class Bot actual constructor() : CoroutineScope, LowLevelBotAPIA /** * 昵称 */ - @MiraiExperimentalAPI("还未支持") - actual val nick: String - get() = ""// TODO("bot 昵称获取") + actual abstract val nick: String /** * 日志记录器