Merge remote-tracking branch 'origin/master'

This commit is contained in:
Him188 2020-01-17 22:36:32 +08:00
commit a43c67741a
7 changed files with 30 additions and 0 deletions

View File

@ -14,6 +14,10 @@ inline class At(val target: Long) : Message {
override fun toString(): String = "[@$target]" // TODO: 2019/11/25 使用群名称进行 at. 因为手机端只会显示这个文字
companion object Key : Message.Key<At>
override fun eq(other: Message): Boolean {
return other is At && other.target == this.target
}
}
/**

View File

@ -9,6 +9,10 @@ inline class Face(val id: FaceId) : Message {
override fun toString(): String = "[face${id.value}]"
companion object Key : Message.Key<Face>
override fun eq(other: Message): Boolean {
return other is Face && other.id == this.id
}
}
/**

View File

@ -19,6 +19,10 @@ inline class Image(inline val id: ImageId) : Message {
override fun toString(): String = "[${id.value}]"
companion object Key : Message.Key<Image>
override fun eq(other: Message): Boolean {
return other is Image && other.id == this.id
}
}
inline val Image.idValue: String get() = id.value

View File

@ -97,6 +97,8 @@ interface Message {
operator fun plus(another: Float): MessageChain = this.followedBy(another.toString().toMessage())
operator fun plus(another: Number): MessageChain = this.followedBy(another.toString().toMessage())
}
/**

View File

@ -41,6 +41,11 @@ interface MessageChain : Message, MutableList<Message> {
*/
operator fun <M : Message> get(key: Message.Key<M>): M = first(key)
override fun eq(other: Message): Boolean {
if(other is MessageChain && other.size != this.size)
return false
return this.toString() == other.toString()
}
}
/**

View File

@ -6,6 +6,13 @@ inline class PlainText(val stringValue: String) : Message {
override fun toString(): String = stringValue
companion object Key : Message.Key<PlainText>
override fun eq(other: Message): Boolean {
if(other is MessageChain){
return other eq this.toString()
}
return other is PlainText && other.stringValue == this.stringValue
}
}
/**

View File

@ -11,6 +11,10 @@ inline class XMLMessage(val stringValue: String) : Message,
SingleOnly {
override fun followedBy(tail: Message): Nothing = error("XMLMessage Message cannot be followed")
override fun toString(): String = stringValue
override fun eq(other: Message): Boolean {
return other is XMLMessage && other.stringValue == this.stringValue
}
}
/**