From 0d4850591c4a80ff70b8b0803ef5a09cddd52cde Mon Sep 17 00:00:00 2001 From: "jiahua.liu" Date: Sun, 2 Feb 2020 20:11:41 +0800 Subject: [PATCH] Troop Member List --- .../net/mamoe/mirai/qqandroid/ContactImpl.kt | 30 +++++++++++-------- .../kotlin/net.mamoe.mirai/contact/Group.kt | 4 +-- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt index 0c64b2c22..18a0821a4 100644 --- a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt +++ b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt @@ -73,25 +73,30 @@ internal class MemberImpl( @UseExperimental(MiraiInternalAPI::class) -internal class GroupImpl(bot: QQAndroidBot, override val coroutineContext: CoroutineContext, override val id: Long) : ContactImpl(), Group { +internal class GroupImpl( + bot: QQAndroidBot, override val coroutineContext: CoroutineContext, override val id: Long, + override val owner: Member, + override val name: String, + override val announcement: String, + override val members: ContactList +) : ContactImpl(), Group { override val internalId: GroupInternalId = GroupId(id).toInternalId() - override val owner: Member - get() = TODO("not implemented") - override val name: String - get() = TODO("not implemented") - override val announcement: String - get() = TODO("not implemented") - override val members: ContactList = ContactList(LockFreeLinkedList()) override fun getMember(id: Long): Member = - members.delegate.filteringGetOrAdd({ it.id == id }, { MemberImpl(bot.getQQ(id) as QQImpl, this, coroutineContext) }) + members.delegate.filteringGetOrAdd( + { it.id == id }, + { MemberImpl(bot.getQQ(id) as QQImpl, this, coroutineContext) }) - override suspend fun updateGroupInfo(): GroupInfo { - TODO("not implemented") + override suspend fun updateGroupInfo(): net.mamoe.mirai.data.GroupInfo { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. } override suspend fun quit(): Boolean { - TODO("not implemented") + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + operator fun get(key: Long): Member? { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. } override val bot: QQAndroidBot by bot.unsafeWeakRef() @@ -112,4 +117,5 @@ internal class GroupImpl(bot: QQAndroidBot, override val coroutineContext: Corou override suspend fun uploadImage(image: ExternalImage): ImageId { TODO("not implemented") } + } \ No newline at end of file diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Group.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Group.kt index 536068c67..55775a094 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Group.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Group.kt @@ -15,7 +15,7 @@ import net.mamoe.mirai.utils.coerceAtLeastOrFail * - Group ID([Group.internalId]) 是与调用 API 时使用的 id.(在 QQ 客户端中不可见) * @author Him188moe */ -interface Group : Contact, CoroutineScope/*, Map*/ { // TODO: 2020/1/29 实现接口 Map +interface Group : Contact, CoroutineScope { /** * 内部 ID. 内部 ID 为 [GroupId] 的映射 */ @@ -101,4 +101,4 @@ fun Long.groupId(): GroupId = GroupId(this.coerceAtLeastOrFail(0)) * @see GroupInternalId.toId 由 [GroupInternalId] 转换为 [GroupId] * @see GroupId.toInternalId 由 [GroupId] 转换为 [GroupInternalId] */ -inline class GroupInternalId(inline val value: Long) +inline class GroupInternalId(inline val value: Long) \ No newline at end of file