Skip to content

Commit

Permalink
deep search
Browse files Browse the repository at this point in the history
  • Loading branch information
guimc233 committed Jul 6, 2024
1 parent 0cbbe80 commit 5f5ea76
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
package ltd.guimc.lgzbot.listener.message

import net.mamoe.mirai.event.events.GroupMessageEvent
import net.mamoe.mirai.message.data.QuoteReply
import net.mamoe.mirai.message.data.RichMessage
import net.mamoe.mirai.message.data.*

object AntiMappLinkListener {
suspend fun filter(e: GroupMessageEvent) {
for (singleMessage in e.message) {
if (check(e.message)) e.subject.sendMessage(QuoteReply(e.source) + "WARN: 本消息可能包含mqqapi链接 请注意安全")
}

fun check(m: MessageChain): Boolean {
for (singleMessage in m) {
if (singleMessage is RichMessage && singleMessage.content.contains("mqqapi:\\/\\/")) {
e.subject.sendMessage(QuoteReply(e.source) + "WARN: 本可能消息包含mqqapi链接 请注意安全")
return true
}

if (singleMessage is ForwardMessage) {
return check(singleMessage.toMessageChain())
}
}
return false
}
}

0 comments on commit 5f5ea76

Please sign in to comment.