From 397861500f399258c50a66cd3fcb952d74a14310 Mon Sep 17 00:00:00 2001 From: Him188 Date: Thu, 13 Feb 2020 09:35:43 +0800 Subject: [PATCH] Message DSL: add `String.reply(Message)` --- .../kotlin/net.mamoe.mirai/event/MessageSubscribers.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/MessageSubscribers.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/MessageSubscribers.kt index 0d0b5a8c8..f3cc39023 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/MessageSubscribers.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/MessageSubscribers.kt @@ -588,6 +588,12 @@ class MessageSubscribersBuilder>( return content({ it.trim() == toCheck }, { reply(reply) }) } + @MessageDsl + infix fun String.reply(reply: Message): Listener { + val toCheck = this.trim() + return content({ it.trim() == toCheck }, { reply(reply) }) + } + @MessageDsl inline infix fun String.reply(crossinline replier: @MessageDsl suspend T.(String) -> Any?): Listener { val toCheck = this.trim()