mirror of
https://github.com/mamoe/mirai.git
synced 2025-02-05 13:52:27 +08:00
Code cleanup, improve docs
This commit is contained in:
parent
75d5020a0a
commit
77a4aa8977
@ -54,9 +54,6 @@ import kotlin.contracts.contract
|
||||
* ```
|
||||
* 但注意: 不能 `String + Message`. 只能 `Message + String`
|
||||
*
|
||||
* #### 实现规范
|
||||
* 除 [MessageChain] 外, 所有 [Message] 的实现类都有伴生对象实现 [Key] 接口.
|
||||
*
|
||||
* #### 发送消息
|
||||
* - 通过 [Contact] 中的成员函数: [Contact.sendMessage]
|
||||
* - 通过 [Message] 的扩展函数: [Message.sendTo]
|
||||
@ -130,6 +127,7 @@ public interface Message { // must be interface. Don't consider any changes.
|
||||
* - ...
|
||||
*
|
||||
* @see toString 得到包含 mirai 消息元素代码的, 易读的字符串
|
||||
* @see Message.content Kotlin 扩展
|
||||
*/
|
||||
public fun contentToString(): String
|
||||
|
||||
|
@ -118,7 +118,6 @@ internal fun Sequence<SingleMessage>.constrainSingleMessages(): List<SingleMessa
|
||||
/**
|
||||
* - [Sequence.toMutableList]
|
||||
* - Replace in-place with marker null
|
||||
* - [Iterable.filterNotNull]
|
||||
*/
|
||||
@MiraiExperimentalApi
|
||||
@JvmSynthetic
|
||||
@ -147,15 +146,6 @@ internal fun constrainSingleMessagesImpl(sequence: Sequence<SingleMessage>): Lis
|
||||
internal fun Iterable<SingleMessage>.constrainSingleMessages(): List<SingleMessage> =
|
||||
constrainSingleMessagesImpl(this.asSequence())
|
||||
|
||||
@JvmSynthetic
|
||||
internal inline fun <T> List<T>.indexOfFirst(offset: Int, predicate: (T) -> Boolean): Int {
|
||||
for (index in offset..this.lastIndex) {
|
||||
if (predicate(this[index]))
|
||||
return index
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
|
||||
@JvmSynthetic
|
||||
@Suppress("UNCHECKED_CAST", "DEPRECATION_ERROR", "DEPRECATION")
|
||||
@ -184,12 +174,6 @@ internal data class MessageChainImpl constructor(
|
||||
override fun equals(other: Any?): Boolean = other is MessageChainImpl && other.delegate == this.delegate
|
||||
}
|
||||
|
||||
@Suppress("FunctionName")
|
||||
internal fun CombinedMessage(
|
||||
left: Message,
|
||||
tail: Message
|
||||
): MessageChain = MessageChainImplBySequence(left.flatten() + tail.flatten())
|
||||
|
||||
@Suppress("FunctionName") // source compatibility with 1.x
|
||||
internal fun MessageChainImplBySequence(
|
||||
delegate: Sequence<SingleMessage> // 可以有重复 ConstrainSingle
|
||||
@ -266,7 +250,6 @@ internal fun calculateImageMd5ByImageId(imageId: String): ByteArray {
|
||||
}
|
||||
}
|
||||
|
||||
@PublishedApi
|
||||
internal val ILLEGAL_IMAGE_ID_EXCEPTION_MESSAGE: String =
|
||||
"ImageId must match Regex `${FRIEND_IMAGE_ID_REGEX_1.pattern}`, " +
|
||||
"`${FRIEND_IMAGE_ID_REGEX_2.pattern}` or " +
|
||||
|
Loading…
Reference in New Issue
Block a user