Resource icon

Script Regex-based Chat Filter 1.0

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the community!

    Now, what are you waiting for? Join the community now!

Supported Skript Version
  1. 2.11
  2. 2.12
Supported Minecraft Versions
  1. 1.19
  2. 1.20
  3. 1.21
# Chat Filter Skript
A flexible chat filter with support for alternate characters, separators, repeated letters, exceptions, and severity levels
Requires:
- oopsk (for structs)
- skript-reflect (for pre-compiled regex patterns)
author: sovde
version: 1.0
license: MIT (do what you want with it)
How to use:
on load:
1. Customize the alternate characters and separators to suit your needs
2. Add filtered phrases with addFilteredPhrase()

If you change alternates or separators after adding phrases, call regeneratePatterns() to update the patterns

when filtering messages, use filterMessage(message, sender) which returns a struct with details of any matches found:
on chat:
set {_result} to filterMessage(message, sender)
if {_result}->matched is true:
cancel event
send "Your message was blocked due to inappropriate content."
The command testFilter <text> can be used to test filtering of a message: '/testFilter badword'
The command stresstest can be used to benchmark performance of filtering 100,000 messages. It takes about 6 seconds on my machine with the default phrases.

NOTE: filtered phrases are NOT saved between server restarts, so you need to add them on load each time.
This can be worked around, but it was intentional to keep the script simple and focused on filtering logic.
Author
Sovde
Downloads
288
Views
951
First release
Last update
Rating
0.00 star(s) 0 ratings

More resources from Sovde