Skip to content

Commit d478adc

Browse files
committed
Update AntiSpam.kt
1 parent 339f89b commit d478adc

File tree

1 file changed

+8
-8
lines changed
  • src/main/kotlin/com/lambda/module/modules/chat

1 file changed

+8
-8
lines changed

src/main/kotlin/com/lambda/module/modules/chat/AntiSpam.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import com.lambda.util.ChatUtils.slurs
3535
import com.lambda.util.ChatUtils.swears
3636
import com.lambda.util.ChatUtils.toAscii
3737
import com.lambda.util.NamedEnum
38-
import com.lambda.util.text.MessageDirection
38+
import com.lambda.util.text.DirectMessage
3939
import com.lambda.util.text.MessageParser
4040
import com.lambda.util.text.MessageType
4141
import net.minecraft.text.Text
@@ -79,13 +79,13 @@ object AntiSpam : Module(
7979
}
8080

8181
init {
82-
listen<ChatEvent.Message> { event ->
82+
listen<ChatEvent.Receive> { event ->
8383
var raw = event.message.string
8484
val author = MessageParser.playerName(raw)
8585

8686
if (
87-
ignoreSystem && !MessageType.Both.matches(raw) && !MessageDirection.Both.matches(raw) ||
88-
ignoreDms && MessageDirection.Receive.matches(raw)
87+
ignoreSystem && !MessageType.Both.matches(raw) && !DirectMessage.Both.matches(raw) ||
88+
ignoreDms && DirectMessage.Receive.matches(raw)
8989
) return@listen
9090

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

129129
if (cancelled) return@listen event.cancel()
130-
if (!hasMatches) return@listen
131130

132-
event.message = Text.of(if (fancyChats) raw.toAscii else raw)
131+
if (hasMatches)
132+
event.message = Text.of(if (fancyChats) raw.toAscii else raw)
133133
}
134134
}
135135

0 commit comments

Comments
 (0)