From 9f7dec264340c5078e4677c1c354b8678f6902ba Mon Sep 17 00:00:00 2001
From: Him188 <Him188@mamoe.net>
Date: Sat, 29 Feb 2020 01:21:33 +0800
Subject: [PATCH 1/3] Add `.editorConfig`

---
 .editorconfig | 2 ++
 1 file changed, 2 insertions(+)
 create mode 100644 .editorconfig

diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 000000000..970f61a6f
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,2 @@
+[*.{kt, kts}]
+max_line_length = 120

From 756e8b537e8326a8cae8ea9ee1862512c3b979dc Mon Sep 17 00:00:00 2001
From: Him188 <Him188@mamoe.net>
Date: Sat, 29 Feb 2020 13:24:24 +0800
Subject: [PATCH 2/3] Improve `equals`

---
 .../commonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt
index e082ddedb..c71fea9d9 100644
--- a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt
+++ b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt
@@ -300,7 +300,7 @@ internal class MemberImpl(
     @Suppress("DuplicatedCode")
     override fun equals(other: Any?): Boolean { // 不要删除. trust me
         if (this === other) return true
-        if (other !is Contact) return false
+        if (other !is Member) return false
         if (this::class != other::class) return false
         return this.id == other.id && this.bot == other.bot
     }

From 0cbc0f0e29838430591c36891f167d5c32ca5ee3 Mon Sep 17 00:00:00 2001
From: Him188 <Him188@mamoe.net>
Date: Sat, 29 Feb 2020 13:47:47 +0800
Subject: [PATCH 3/3] Add `containsAny` and `containsAll`

---
 .../event/subscribeMessages.kt                | 73 ++++++++++++++++++-
 1 file changed, 71 insertions(+), 2 deletions(-)

diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/subscribeMessages.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/subscribeMessages.kt
index 7057fe3ee..1fdc66593 100644
--- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/subscribeMessages.kt
+++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/subscribeMessages.kt
@@ -324,7 +324,7 @@ class MessageSubscribersBuilder<T : MessagePacket<*, *>>(
         content { sub in it }
 
     /**
-     * 如果消息内容包含 [sub]
+     * 如果消息内容包含 [sub] 中的任意一个元素
      */
     @MessageDsl
     inline fun contains(
@@ -345,6 +345,72 @@ class MessageSubscribersBuilder<T : MessagePacket<*, *>>(
         }
     }
 
+    /**
+     * 如果消息内容包含 [sub]
+     */
+    @MessageDsl
+    fun containsAny(vararg sub: String): ListeningFilter =
+        content { sub.any { item -> item in it } }
+
+    /**
+     * 如果消息内容包含 [sub] 中的任意一个元素
+     */
+    @MessageDsl
+    inline fun containsAny(
+        vararg sub: String,
+        ignoreCase: Boolean = false,
+        trim: Boolean = true,
+        crossinline onEvent: MessageListener<T>
+    ): Listener<T> {
+        return if (trim) {
+            val list = sub.map { it.trim() }
+            content({
+                list.any { toCheck -> it.contains(toCheck, ignoreCase = ignoreCase) }
+            }, {
+                onEvent(this, this.message.toString().trim())
+            })
+        } else {
+            content({
+                sub.any { toCheck -> it.contains(toCheck, ignoreCase = ignoreCase) }
+            }, {
+                onEvent(this, this.message.toString())
+            })
+        }
+    }
+
+    /**
+     * 如果消息内容包含 [sub]
+     */
+    @MessageDsl
+    fun containsAll(vararg sub: String): ListeningFilter =
+        content { sub.all { item -> item in it } }
+
+    /**
+     * 如果消息内容包含 [sub] 中的任意一个元素
+     */
+    @MessageDsl
+    inline fun containsAll(
+        vararg sub: String,
+        ignoreCase: Boolean = false,
+        trim: Boolean = true,
+        crossinline onEvent: MessageListener<T>
+    ): Listener<T> {
+        return if (trim) {
+            val list = sub.map { it.trim() }
+            content({
+                list.all { toCheck -> it.contains(toCheck, ignoreCase = ignoreCase) }
+            }, {
+                onEvent(this, this.message.toString().trim())
+            })
+        } else {
+            content({
+                sub.all { toCheck -> it.contains(toCheck, ignoreCase = ignoreCase) }
+            }, {
+                onEvent(this, this.message.toString())
+            })
+        }
+    }
+
     /**
      * 如果消息的前缀是 [prefix]
      */
@@ -538,7 +604,10 @@ class MessageSubscribersBuilder<T : MessagePacket<*, *>>(
      * 如果 [filter] 返回 `true` 就执行 `onEvent`
      */
     @MessageDsl
-    inline fun content(crossinline filter: T.(String) -> Boolean, crossinline onEvent: MessageListener<T>): Listener<T> =
+    inline fun content(
+        crossinline filter: T.(String) -> Boolean,
+        crossinline onEvent: MessageListener<T>
+    ): Listener<T> =
         subscriber {
             if (filter(this, it)) onEvent(this, it)
         }