|
|
@@ -22,6 +22,7 @@ import net.mamoe.mirai.message.GroupMessageEvent
|
|
|
import net.mamoe.mirai.message.MessageEvent
|
|
|
import net.mamoe.mirai.message.TempMessageEvent
|
|
|
import net.mamoe.mirai.message.data.*
|
|
|
+import net.mamoe.mirai.utils.PlannedRemoval
|
|
|
import kotlin.jvm.JvmName
|
|
|
import kotlin.jvm.JvmOverloads
|
|
|
import kotlin.jvm.JvmSynthetic
|
|
|
@@ -95,48 +96,54 @@ open class MessageSubscribersBuilder<M : MessageEvent, out Ret, R : RR, RR>(
|
|
|
operator fun invoke(onEvent: MessageListener<M, R>): Ret = content(filter, onEvent)
|
|
|
}
|
|
|
|
|
|
- /** 启动这个监听器, 在满足条件时回复原消息 */
|
|
|
+ /** 启动监听器, 在 [Bot] 未被禁言且消息满足条件 [this] 时回复原消息 */
|
|
|
@MessageDsl
|
|
|
open infix fun ListeningFilter.reply(toReply: String): Ret =
|
|
|
- content(filter) { reply(toReply);[email protected] }
|
|
|
+ content(filter) { if ((this as? GroupMessageEvent)?.group?.isBotMuted != true) reply(toReply);[email protected] }
|
|
|
|
|
|
|
|
|
- /** 启动这个监听器, 在满足条件时回复原消息 */
|
|
|
+ /** 启动监听器, 在 [Bot] 未被禁言且消息满足条件 [this] 时回复原消息 */
|
|
|
@MessageDsl
|
|
|
open infix fun ListeningFilter.reply(message: Message): Ret =
|
|
|
- content(filter) { reply(message);[email protected] }
|
|
|
-
|
|
|
- /** 启动这个监听器, 在满足条件时回复原消息 */
|
|
|
- @JvmName("reply3")
|
|
|
- @MessageDsl
|
|
|
- open infix fun ListeningFilter.`->`(toReply: String): Ret = this.reply(toReply)
|
|
|
+ content(filter) { if ((this as? GroupMessageEvent)?.group?.isBotMuted != true) reply(message);[email protected] }
|
|
|
|
|
|
- /** 启动这个监听器, 在满足条件时回复原消息 */
|
|
|
- @JvmName("reply3")
|
|
|
- @MessageDsl
|
|
|
- open infix fun ListeningFilter.`->`(message: Message): Ret = this.reply(message)
|
|
|
-
|
|
|
- /** 启动这个监听器, 在满足条件时回复原消息 */
|
|
|
+ /**
|
|
|
+ * 启动监听器, 在 [Bot] 未被禁言且消息满足条件 [this] 时执行 [replier] 并以其返回值回复.
|
|
|
+ * 返回值 [Unit] 将被忽略, [Message] 将被直接回复, 其他内容将会 [Any.toString] 后发送.
|
|
|
+ */
|
|
|
@MessageDsl
|
|
|
- open infix fun ListeningFilter.reply(replier: (@MessageDsl suspend M.(String) -> Any?)): Ret =
|
|
|
- content(filter) { [email protected](this, replier) }
|
|
|
+ open infix fun ListeningFilter.reply(
|
|
|
+ replier: (@MessageDsl suspend M.(String) -> Any?)
|
|
|
+ ): Ret =
|
|
|
+ content(filter) {
|
|
|
+ if ((this as? GroupMessageEvent)?.group?.isBotMuted != true)
|
|
|
+ [email protected](this, replier)
|
|
|
+ else [email protected]
|
|
|
+ }
|
|
|
|
|
|
- /** 启动这个监听器, 在满足条件时引用回复原消息 */
|
|
|
+ /** 启动监听器, 在 [Bot] 未被禁言且消息满足条件 [this] 时引用回复原消息 */
|
|
|
@MessageDsl
|
|
|
open infix fun ListeningFilter.quoteReply(toReply: String): Ret =
|
|
|
- content(filter) { quoteReply(toReply);[email protected] }
|
|
|
+ content(filter) { if ((this as? GroupMessageEvent)?.group?.isBotMuted != true) quoteReply(toReply); [email protected] }
|
|
|
|
|
|
- /** 启动这个监听器, 在满足条件时引用回复原消息 */
|
|
|
+ /** 启动监听器, 在 [Bot] 未被禁言且消息满足条件 [this] 时引用回复原消息 */
|
|
|
@MessageDsl
|
|
|
open infix fun ListeningFilter.quoteReply(toReply: Message): Ret =
|
|
|
- content(filter) { quoteReply(toReply);[email protected] }
|
|
|
+ content(filter) { if ((this as? GroupMessageEvent)?.group?.isBotMuted != true) quoteReply(toReply);[email protected] }
|
|
|
|
|
|
- /** 启动这个监听器, 在满足条件时执行 [replier] 并引用回复原消息 */
|
|
|
+ /**
|
|
|
+ * 启动监听器, 在 [Bot] 未被禁言且消息满足条件 [this] 时执行 [replier] 并以其返回值回复原消息
|
|
|
+ * 返回值 [Unit] 将被忽略, [Message] 将被直接回复, 其他内容将会 [Any.toString] 后发送
|
|
|
+ */
|
|
|
@MessageDsl
|
|
|
open infix fun ListeningFilter.quoteReply(replier: (@MessageDsl suspend M.(String) -> Any?)): Ret =
|
|
|
- content(filter) { [email protected](this, replier) }
|
|
|
+ content(filter) {
|
|
|
+ if ((this as? GroupMessageEvent)?.group?.isBotMuted != true)
|
|
|
+ [email protected](this, replier)
|
|
|
+ else [email protected]
|
|
|
+ }
|
|
|
|
|
|
- /** 无任何触发条件, 每次收到消息都执行 [onEvent] */
|
|
|
+ /** 无触发条件, 每次收到消息都执行 [onEvent] */
|
|
|
@MessageDsl
|
|
|
open fun always(onEvent: MessageListener<M, RR>): Ret = subscriber({ true }, onEvent)
|
|
|
|
|
|
@@ -453,6 +460,20 @@ open class MessageSubscribersBuilder<M : MessageEvent, out Ret, R : RR, RR>(
|
|
|
//// DEPRECATED AND INTERNAL ////
|
|
|
/////////////////////////////////
|
|
|
|
|
|
+ /** 启动这个监听器, 在满足条件时回复原消息 */
|
|
|
+ @PlannedRemoval("1.2.0")
|
|
|
+ @Deprecated("use reply instead", ReplaceWith("this.reply(message)"))
|
|
|
+ @JvmName("reply3")
|
|
|
+ @MessageDsl
|
|
|
+ open infix fun ListeningFilter.`->`(toReply: String): Ret = this.reply(toReply)
|
|
|
+
|
|
|
+ /** 启动这个监听器, 在满足条件时回复原消息 */
|
|
|
+ @PlannedRemoval("1.2.0")
|
|
|
+ @Deprecated("use reply instead", ReplaceWith("this.reply(message)"))
|
|
|
+ @JvmName("reply3")
|
|
|
+ @MessageDsl
|
|
|
+ open infix fun ListeningFilter.`->`(message: Message): Ret = this.reply(message)
|
|
|
+
|
|
|
@Suppress("REDUNDANT_INLINE_SUSPEND_FUNCTION_TYPE", "UNCHECKED_CAST") // false positive
|
|
|
internal suspend inline fun executeAndReply(m: M, replier: suspend M.(String) -> Any?): RR {
|
|
|
when (val message = replier(m, m.message.contentToString())) {
|