Support Bot.nick, closed #93

This commit is contained in:
ryoii 2020-04-04 09:40:14 +08:00
parent 5e553a56ca
commit eac23171ec
6 changed files with 16 additions and 8 deletions

View File

@ -87,6 +87,9 @@ internal abstract class QQAndroidBotBase constructor(
override val friends: ContactList<QQ> = ContactList(LockFreeLinkedList())
override lateinit var nick: String
internal set
override val selfQQ: QQ by lazy {
@OptIn(LowLevelAPI::class)
_lowLevelNewQQ(object : FriendInfo {

View File

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

View File

@ -126,6 +126,7 @@ internal class FriendList {
OutgoingPacketFactory<GetFriendGroupList.Response>("friendlist.getFriendGroupList") {
class Response(
val selfInfo: FriendInfo?,
val totalFriendCount: Short,
val friendList: List<FriendInfo>
) : 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()
)

View File

@ -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
/**
* 日志记录器

View File

@ -90,8 +90,7 @@ expect abstract class Bot() : CoroutineScope, LowLevelBotAPIAccessor {
/**
* 昵称
*/
@MiraiExperimentalAPI("还未支持")
val nick: String
abstract val nick: String
/**
* 日志记录器

View File

@ -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
/**
* 日志记录器