Him188 6 lat temu
rodzic
commit
e58665f93e

+ 1 - 1
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/BotHelper.kt

@@ -50,7 +50,7 @@ inline fun <R> Bot.withSession(block: BotSession.() -> R): R = with(this.network
 suspend inline fun Bot.sendPacket(packet: OutgoingPacket) = this.network.sendPacket(packet)
 
 /**
- * 使用在默认配置基础上修改的配置登录
+ * 使用在默认配置基础上修改的配置进行登录
  */
 suspend inline fun Bot.login(noinline configuration: BotNetworkConfiguration.() -> Unit): LoginResult = this.network.login(BotNetworkConfiguration().apply(configuration))
 

+ 5 - 1
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/Contact.kt

@@ -65,7 +65,7 @@ inline class GroupInternalId(val value: UInt)
 @Suppress("MemberVisibilityCanBePrivate", "CanBeParameter")
 class Group internal constructor(bot: Bot, val groupId: GroupId) : Contact(bot, groupId.value) {
     val internalId = GroupId(id).toInternalId()
-    val members: ContactList<QQ>
+    val members: ContactList<Member>
         get() = TODO("Implementing group members is less important")
 
     override suspend fun sendMessage(message: MessageChain) {
@@ -75,6 +75,10 @@ class Group internal constructor(bot: Bot, val groupId: GroupId) : Contact(bot,
     companion object
 }
 
+/**
+ * 以 [BotSession] 作为接收器 (receiver) 并调用 [block], 返回 [block] 的返回值.
+ * 这个方法将能帮助使用在 [BotSession] 中定义的一些扩展方法, 如 [BotSession.sendAndExpect]
+ */
 inline fun <R> Contact.withSession(block: BotSession.() -> R): R = bot.withSession(block)
 
 /**

+ 2 - 2
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/Message.kt

@@ -417,7 +417,7 @@ class EmptyMessageChain : MessageChain {
  * Null 的 [MessageChain].
  * 它不包含任何元素, 也没有创建任何 list.
  *
- * - 所有 get 方法均抛出 [NoSuchElementException]
+ * - 所有 get 方法均抛出 [IndexOutOfBoundsException]
  * - 所有 add 方法均抛出 [UnsupportedOperationException]
  * - 其他判断类方法均 false 或 -1
  */
@@ -434,7 +434,7 @@ object NullMessageChain : MessageChain {
     override fun concat(tail: Message): MessageChain = MessageChainImpl(tail)
     override val size: Int = 0
     override fun containsAll(elements: Collection<Message>): Boolean = false
-    override fun get(index: Int): Message = throw NoSuchElementException()
+    override fun get(index: Int): Message = throw IndexOutOfBoundsException()
     override fun indexOf(element: Message): Int = -1
     override fun isEmpty(): Boolean = true
     override fun iterator(): MutableIterator<Message> = EmptyMutableIterator()