Add space automatically if necessary

This commit is contained in:
Him188 2020-02-09 23:35:11 +08:00
parent b991c6ef0c
commit 3c83883c66
2 changed files with 10 additions and 1 deletions

View File

@ -92,7 +92,7 @@ abstract class MessagePacketBase<TSender : QQ, TSubject : Contact>(_bot: Bot) :
// region
/**
* 引用这个消息.
* 引用这个消息. 当且仅当消息为群消息时可用. 否则将会抛出 [IllegalArgumentException]
*/
inline fun MessageChain.quote(): MessageChain = this.quote(sender as? Member ?: error("only group message can be quoted"))

View File

@ -30,6 +30,15 @@ class At @MiraiInternalAPI constructor(val target: Long, val display: String) :
override fun eq(other: Message): Boolean {
return other is At && other.target == this.target
}
// 自动为消息补充 " "
override fun followedBy(tail: Message): MessageChain {
if(tail is PlainText && !tail.stringValue.startsWith(' ')){
return super.followedBy(PlainText(" ")) + tail
}
return super.followedBy(tail)
}
}
/**