Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
guimc233 committed Aug 7, 2024
1 parent 088c6c4 commit 5c190fc
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/main/kotlin/ltd/guimc/lgzbot/PluginMain.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import ltd.guimc.lgzbot.listener.nudge.AntiNudgeSpam
import ltd.guimc.lgzbot.listener.nudge.NudgeMute
import ltd.guimc.lgzbot.utils.FbUtils.getFbValue
import ltd.guimc.lgzbot.utils.LL4JUtils
import ltd.guimc.lgzbot.utils.MessageUtils.getPlainText
import ltd.guimc.lgzbot.utils.RegexUtils
import ltd.guimc.lgzbot.utils.RegexUtils.getDefaultPinyinRegex
import ltd.guimc.lgzbot.utils.RegexUtils.getDefaultRegex
import ltd.guimc.lgzbot.utils.RegexUtils.getSeriousRegex
Expand All @@ -41,11 +43,9 @@ import net.mamoe.mirai.console.plugin.jvm.KotlinPlugin
import net.mamoe.mirai.console.plugin.name
import net.mamoe.mirai.console.plugin.version
import net.mamoe.mirai.event.EventPriority
import net.mamoe.mirai.event.events.BotInvitedJoinGroupRequestEvent
import net.mamoe.mirai.event.events.GroupMessageEvent
import net.mamoe.mirai.event.events.NewFriendRequestEvent
import net.mamoe.mirai.event.events.NudgeEvent
import net.mamoe.mirai.event.events.*
import net.mamoe.mirai.event.globalEventChannel
import net.mamoe.mirai.message.data.toMessageChain
import java.io.IOException
import java.nio.file.Path
import java.nio.file.StandardWatchEventKinds
Expand Down Expand Up @@ -224,6 +224,13 @@ object PluginMain : KotlinPlugin(
it.accept()
}

subscribeAlways<MessagePreSendEvent>(priority = EventPriority.LOW) { e ->
if (RegexUtils.matchRegex(seriousRegex, e.message.toMessageChain().getPlainText())) {
e.cancel()
e.target.sendMessage("Send message cancelled due to security check")
}
}

// Anti NudgeSpam
subscribeAlways<NudgeEvent>(priority = EventPriority.HIGHEST) { e ->
AntiNudgeSpam.onNudge(e)
Expand Down

0 comments on commit 5c190fc

Please sign in to comment.