HappyFilter – Prohibited-Word Shield
✨ Key Features
️ Ultra-Smart Word Filter
- More than naive keyword matching: catches words split by special characters (e.g. c/n/m)
- Regex rules block URLs, ads, and anything you can describe
- History tracker: prohibited words sent in several messages are still caught
- Optional console logging of every hit
- Fully customizable warning / replacement messages
Flexible Replacement Engine
- Define your own replacement pool
- Random pick from replace_words on every hit
⚡ High-Performance (?) Core
- Aho-Corasick automaton – the same algo that lets you AK* in OI!
- Fully asynchronous chat-event handling
AK = “All-Killed”, slang for a perfect score in Chinese competitive programming.
️ Configuration Deep-Dive
Code (YAML):
# config.yml
enabled
: true
# master switch
log_to_console
: true
# print hits to console
filter_words
:
# plain prohibited words
-
"cnm"
-
"sb"
-
"byd"
-
"nm"
filter_rules:
regex
:
# Java-style regexes
-
"(?:[a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,}(?:\\.[a-zA-Z]{2,})?"
interference_characters
:
# chars used to evade filters
- '/'
- '\'
- '.'
- ','
- '|'
- ' '
replace:
replace_words
:
# pool of clean replacements
-
"Meow"
warning:
enabled
: true
message
:
"§cDo not post sensitive content!"
Code (YAML):
# messages.yml
prefix
:
"§7[§dHappy§bFilter§7] "
commands:
reload_success
:
"§aConfig reloaded."
plugin_enabled
:
"§aFilter enabled."
plugin_disabled
:
"§aFilter disabled."
unknown_command
:
"§cUnknown command."
no_permission
:
"§cNo permission."
help:
header
:
"§aHappyFilter Help"
reload
:
"§a/happyfilter reload - reload configs"
help
:
"§a/happyfilter help - show this help"
enable
:
"§a/happyfilter enable - turn filter ON"
disable
:
"§a/happyfilter disable - turn filter OFF"
log
:
"Left: {l} Right: {r} Word: {w}"
# console line format
warning:
message
:
"§cDo not post sensitive content!"
Command Reference
Command
Description
/happyfilter reload Reload configuration files
/happyfilter help Show help page
/happyfilter enable Activate the filter
/happyfilter disable De-activate the filter (until next enable/reload)
Permission Nodes
Node
What it grants
happyfilter.bypass Immunity to the filter
happyfilter.admin Access to all admin commands
Pro Tips
- Escape backslashes twice in YAML regex: \\.
- Add new words by simply appending lines under filter_words.
- Performance: the Aho-Corasick trie is rebuilt ONLY when the word list changes.
- Testing: use /happyfilter disable for safe testing, then /happyfilter enable to go live again.
Bug reports: 1031612019 (QQ) or open a GitHub issue.