Commit eac23171 authored by ryoii's avatar ryoii

Support `Bot.nick`, closed #93

parent 5e553a56
...@@ -87,6 +87,9 @@ internal abstract class QQAndroidBotBase constructor( ...@@ -87,6 +87,9 @@ internal abstract class QQAndroidBotBase constructor(
override val friends: ContactList<QQ> = ContactList(LockFreeLinkedList()) override val friends: ContactList<QQ> = ContactList(LockFreeLinkedList())
override lateinit var nick: String
internal set
override val selfQQ: QQ by lazy { override val selfQQ: QQ by lazy {
@OptIn(LowLevelAPI::class) @OptIn(LowLevelAPI::class)
_lowLevelNewQQ(object : FriendInfo { _lowLevelNewQQ(object : FriendInfo {
......
...@@ -222,6 +222,14 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler ...@@ -222,6 +222,14 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler
logger.error("稍后重试加载好友列表") logger.error("稍后重试加载好友列表")
return@loadFriends return@loadFriends
} }
// self info
data.selfInfo?.apply {
bot.nick = nick ?: ""
// bot.remark = remark ?: ""
// bot.sex = sex
}
totalFriendCount = data.totalFriendCount totalFriendCount = data.totalFriendCount
data.friendList.forEach { data.friendList.forEach {
// atomic add // atomic add
......
...@@ -126,6 +126,7 @@ internal class FriendList { ...@@ -126,6 +126,7 @@ internal class FriendList {
OutgoingPacketFactory<GetFriendGroupList.Response>("friendlist.getFriendGroupList") { OutgoingPacketFactory<GetFriendGroupList.Response>("friendlist.getFriendGroupList") {
class Response( class Response(
val selfInfo: FriendInfo?,
val totalFriendCount: Short, val totalFriendCount: Short,
val friendList: List<FriendInfo> val friendList: List<FriendInfo>
) : Packet { ) : Packet {
...@@ -135,6 +136,7 @@ internal class FriendList { ...@@ -135,6 +136,7 @@ internal class FriendList {
override suspend fun ByteReadPacket.decode(bot: QQAndroidBot): Response { override suspend fun ByteReadPacket.decode(bot: QQAndroidBot): Response {
val res = this.decodeUniPacket(GetFriendListResp.serializer()) val res = this.decodeUniPacket(GetFriendListResp.serializer())
return Response( return Response(
res.stSelfInfo,
res.totoalFriendCount, res.totoalFriendCount,
res.vecFriendInfo.orEmpty() res.vecFriendInfo.orEmpty()
) )
......
...@@ -70,9 +70,7 @@ actual abstract class Bot actual constructor() : CoroutineScope, LowLevelBotAPIA ...@@ -70,9 +70,7 @@ actual abstract class Bot actual constructor() : CoroutineScope, LowLevelBotAPIA
/** /**
* 昵称 * 昵称
*/ */
@MiraiExperimentalAPI("还未支持") actual abstract val nick: String
actual val nick: String
get() = ""// TODO("bot 昵称获取")
/** /**
* 日志记录器 * 日志记录器
......
...@@ -90,8 +90,7 @@ expect abstract class Bot() : CoroutineScope, LowLevelBotAPIAccessor { ...@@ -90,8 +90,7 @@ expect abstract class Bot() : CoroutineScope, LowLevelBotAPIAccessor {
/** /**
* 昵称 * 昵称
*/ */
@MiraiExperimentalAPI("还未支持") abstract val nick: String
val nick: String
/** /**
* 日志记录器 * 日志记录器
......
...@@ -80,9 +80,7 @@ actual abstract class Bot actual constructor() : CoroutineScope, LowLevelBotAPIA ...@@ -80,9 +80,7 @@ actual abstract class Bot actual constructor() : CoroutineScope, LowLevelBotAPIA
/** /**
* 昵称 * 昵称
*/ */
@MiraiExperimentalAPI("还未支持") actual abstract val nick: String
actual val nick: String
get() = ""// TODO("bot 昵称获取")
/** /**
* 日志记录器 * 日志记录器
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment