Skip to content

Commit

Permalink
add mqqapi warning
Browse files Browse the repository at this point in the history
  • Loading branch information
guimc233 committed Jul 6, 2024
1 parent 776e270 commit 0cbbe80
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/main/kotlin/ltd/guimc/lgzbot/PluginMain.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import ltd.guimc.lgzbot.files.Config
import ltd.guimc.lgzbot.files.GithubSubConfig
import ltd.guimc.lgzbot.files.GithubWebhookSubData
import ltd.guimc.lgzbot.files.ModuleStateConfig
import ltd.guimc.lgzbot.listener.message.AntiMappLinkListener
import ltd.guimc.lgzbot.listener.message.FunListener
import ltd.guimc.lgzbot.listener.message.GithubUrlListener
import ltd.guimc.lgzbot.listener.message.MessageFilter
Expand Down Expand Up @@ -186,6 +187,11 @@ object PluginMain : KotlinPlugin(

private fun registerEvents() = PluginMain.globalEventChannel().run {
subscribeAlways<GroupMessageEvent>(priority = EventPriority.HIGHEST) { event -> MessageFilter.filter(event) }
subscribeAlways<GroupMessageEvent>(priority = EventPriority.HIGHEST) { event ->
AntiMappLinkListener.filter(
event
)
}

subscribeAlways<GroupMessageEvent> { event -> GithubUrlListener.onMessage(event); FunListener.onMessage(event) }

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
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

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

0 comments on commit 0cbbe80

Please sign in to comment.