Commit ec0d7f44 authored by Him188's avatar Him188

Add `ListenerFilter.reply`

parent 8b9cef05
...@@ -249,6 +249,21 @@ class MessageSubscribersBuilder<T : MessagePacket<*, *>>( ...@@ -249,6 +249,21 @@ class MessageSubscribersBuilder<T : MessagePacket<*, *>>(
operator fun invoke(onEvent: MessageListener<T>): Listener<T> { operator fun invoke(onEvent: MessageListener<T>): Listener<T> {
return content(filter, onEvent) return content(filter, onEvent)
} }
infix fun reply(toReply: String): Listener<T> {
return content(filter) { reply(toReply) }
}
infix fun reply(message: Message): Listener<T> {
return content(filter) { reply(message) }
}
infix fun reply(replier: (@MessageDsl suspend T.(String) -> Any?)): Listener<T> {
return content(filter) {
@Suppress("DSL_SCOPE_VIOLATION_WARNING")
executeAndReply(replier)
}
}
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment