Skip to content
Prev Previous commit
Update AntiSpam.kt
  • Loading branch information
emyfops committed Jan 2, 2026
commit d478adc9769100e413e12a6474909a14553f0402
16 changes: 8 additions & 8 deletions src/main/kotlin/com/lambda/module/modules/chat/AntiSpam.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import com.lambda.util.ChatUtils.slurs
import com.lambda.util.ChatUtils.swears
import com.lambda.util.ChatUtils.toAscii
import com.lambda.util.NamedEnum
import com.lambda.util.text.MessageDirection
import com.lambda.util.text.DirectMessage
import com.lambda.util.text.MessageParser
import com.lambda.util.text.MessageType
import net.minecraft.text.Text
Expand Down Expand Up @@ -79,13 +79,13 @@ object AntiSpam : Module(
}

init {
listen<ChatEvent.Message> { event ->
listen<ChatEvent.Receive> { event ->
var raw = event.message.string
val author = MessageParser.playerName(raw)

if (
ignoreSystem && !MessageType.Both.matches(raw) && !MessageDirection.Both.matches(raw) ||
ignoreDms && MessageDirection.Receive.matches(raw)
ignoreSystem && !MessageType.Both.matches(raw) && !DirectMessage.Both.matches(raw) ||
ignoreDms && DirectMessage.Receive.matches(raw)
) return@listen

val slurMatches = slurs.takeIf { detectSlurs.enabled }.orEmpty().flatMap { it.findAll(raw).toList().reversed() }
Expand All @@ -102,8 +102,8 @@ object AntiSpam : Module(
fun doMatch(replace: ReplaceConfig, matches: Sequence<MatchResult>) {
if (
cancelled ||
filterSystem && !MessageType.Both.matches(raw) && !MessageDirection.Both.matches(raw) ||
filterDms && MessageDirection.Receive.matches(raw) ||
filterSystem && !MessageType.Both.matches(raw) && !DirectMessage.Both.matches(raw) ||
filterDms && DirectMessage.Receive.matches(raw) ||
filterFriends && author?.let { FriendManager.isFriend(it) } == true ||
filterSelf && MessageType.Self.matches(raw)
) return
Expand All @@ -127,9 +127,9 @@ object AntiSpam : Module(
doMatch(detectColors, colorMatches)

if (cancelled) return@listen event.cancel()
if (!hasMatches) return@listen

event.message = Text.of(if (fancyChats) raw.toAscii else raw)
if (hasMatches)
event.message = Text.of(if (fancyChats) raw.toAscii else raw)
}
}

Expand Down