@@ -35,7 +35,7 @@ import com.lambda.util.ChatUtils.slurs
3535import com.lambda.util.ChatUtils.swears
3636import com.lambda.util.ChatUtils.toAscii
3737import com.lambda.util.NamedEnum
38- import com.lambda.util.text.DirectMessage
38+ import com.lambda.util.text.MessageDirection
3939import com.lambda.util.text.MessageParser
4040import com.lambda.util.text.MessageType
4141import net.minecraft.text.Text
@@ -45,9 +45,13 @@ object AntiSpam : Module(
4545 description = " Keeps your chat clean" ,
4646 tag = ModuleTag .CHAT ,
4747) {
48- private val ignoreSelf by setting(" Ignore Self" , true )
49- private val ignoreFriends by setting(" Ignore Friends" , true )
5048 private val fancyChats by setting(" Replace Fancy Chat" , false )
49+
50+ private val filterSelf by setting(" Ignore Self" , true )
51+ private val filterFriends by setting(" Ignore Friends" , true )
52+ private val filterSystem by setting(" Filter System Messages" , false )
53+ private val filterDms by setting(" Filter DMs" , true )
54+
5155 private val ignoreSystem by setting(" Ignore System" , false )
5256 private val ignoreDms by setting(" Ignore DMs" , false )
5357
@@ -75,15 +79,13 @@ object AntiSpam : Module(
7579 }
7680
7781 init {
78- listen<ChatEvent .Receive > { event ->
82+ listen<ChatEvent .Message > { event ->
7983 var raw = event.message.string
8084 val author = MessageParser .playerName(raw)
8185
8286 if (
83- ignoreSystem && ! MessageType .Both .matches(raw) && ! DirectMessage .Both .matches(raw) ||
84- ignoreDms && DirectMessage .Receive .matches(raw) ||
85- ignoreFriends && author?.let { FriendManager .isFriend(it) } == true ||
86- ignoreSelf && MessageType .Self .matches(raw)
87+ ignoreSystem && ! MessageType .Both .matches(raw) && ! MessageDirection .Both .matches(raw) ||
88+ ignoreDms && MessageDirection .Receive .matches(raw)
8789 ) return @listen
8890
8991 val slurMatches = slurs.takeIf { detectSlurs.enabled }.orEmpty().flatMap { it.findAll(raw).toList().reversed() }
@@ -98,7 +100,13 @@ object AntiSpam : Module(
98100 var hasMatches = false
99101
100102 fun doMatch (replace : ReplaceConfig , matches : Sequence <MatchResult >) {
101- if (cancelled) return
103+ if (
104+ cancelled ||
105+ filterSystem && ! MessageType .Both .matches(raw) && ! MessageDirection .Both .matches(raw) ||
106+ filterDms && MessageDirection .Receive .matches(raw) ||
107+ filterFriends && author?.let { FriendManager .isFriend(it) } == true ||
108+ filterSelf && MessageType .Self .matches(raw)
109+ ) return
102110
103111 when (replace.action) {
104112 ReplaceConfig .ActionStrategy .Hide -> matches.firstOrNull()?.let { event.cancel(); cancelled = true } // If there's one detection, nuke the whole damn thang
0 commit comments