From 0c49d8c9235d8a4740e4f490f3ae00ffa466d9dc Mon Sep 17 00:00:00 2001 From: Him188 Date: Thu, 28 Nov 2019 23:10:47 +0800 Subject: [PATCH] Add val idContentString --- .../kotlin/net.mamoe.mirai/contact/Contact.kt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Contact.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Contact.kt index 947671404..87ccf2b38 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Contact.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Contact.kt @@ -59,13 +59,23 @@ inline fun Contact.withSession(block: BotSession.() -> R): R { /** * 只读联系人列表 */ -class ContactList internal constructor(internal val delegate: MutableContactList) : Map by delegate { +class ContactList @PublishedApi internal constructor(internal val delegate: MutableContactList) : Map by delegate { + /** + * ID 列表的字符串表示. + * 如: + * ``` + * [123456, 321654, 123654] + * ``` + */ + val idContentString: String get() = this.keys.joinToString(prefix = "[", postfix = "]") { it.toLong().toString() } + override fun toString(): String = delegate.toString() } /** * 可修改联系人列表. 只会在内部使用. */ +@PublishedApi internal class MutableContactList : MutableMap by mutableMapOf() { override fun toString(): String = asIterable().joinToString(separator = ", ", prefix = "ContactList(", postfix = ")") { it.value.toString() } } \ No newline at end of file