mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-08 17:20:11 +08:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
a43c67741a
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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
|
||||
|
@ -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())
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user