[INACTIVE][CHAT] RegexFilter v1.05 - Regular expression chat filter [432-860]

Discussion in 'Inactive/Unsupported Plugins' started by FloydATC, Feb 19, 2011.

  1. Offline


    RegexFilter - Regular Expression chat filter
    Version: v1.05

    This plugin uses the power of Regular Expressions to filter anything you want from chat. Matching messages can be rewritten, logged and blocked, depending on the rules you define. Stop yourself from accidently sending those embarrasing .commands to chat. Warn users who use bad language and even turn their profanities into harmless language.

    This plugin comes with a default setup that effectively replaces my dotFilter and 7filter plugins, which will no longer be maintained.

    • Command typos beginning with certain characters can be stopped (like . and 7)
    • Optionally recover those typos and execute the command as intended
    • Define your own macros or command aliases
    • Simple but powerful configuration with built-in debugging
    • Each regular expression is compiled only once => very fast
    • Supports config reload with "/regex reload"
    • Permissions aware, rules may apply to players, groups or permission nodes
    • Automatically kick players
    • Still no cake
    Download http://minecraft.atc.no/plugins/RegexFilter.jar

    Source code is included - no strings attached, no warranties implied

    Version 1.00
    • Original release
    Version 1.01
    • Changed priority to "lowest" for compatibility with iChat
    Version 1.02
    • Added "/regex reload" command and "then debug" statement
    Version 1.03
    • Removed the "stupidly long constructor" as per Bukkit team recommendation
    Version 1.04
    • Added "then command" to convert chat messages into commands
    Version 1.05
    • Added permission awareness, "then kick" and "then abort"
    • Download and copy to your "plugins" directory
    • Optionally create the directory "plugins/RegexPlugin"
    • Optionally create the file "plugins/RegexPlugin/rules.txt" and edit

    # Each rule must have one 'match' statement and atleast one 'then' statement
    # match <regular expression>
    # ignore user|group [space separated list]
    # ignore permission [node]
    # require user|group [space separated list]
    # require permission [node]
    # then replace <string>|warn [<string>]|log|deny|debug|kick|abort
    # Example 1:
    match f+u+c+k+
    then replace cluck
    then warn Watch your language please
    then log
    # Example 2:
    match dick
    then replace duck
    # Emulate DotFilter
    match ^\.[a-z]+
    then warn
    then deny
    # Emulate 7Filter
    match ^7[a-z]+
    then warn
    then deny
    # Quietly turn "(command" into "/command"
    match ^\((?=[a-z]+)
    then replace
    then command
    Please do NOT post questions here about how to write regular expressions, there are thousands of web sites discussing this topic. Google is your friend. The plugin uses java.util.regex and is CASE_INSENSITIVE. It is NOT possible to use parens to capture substrings to be used with replace. ALL matching rules are applied in the order they appear before any action is taken.
  2. Offline


    Ah, thank you for the feedback. I will have a look at it anyway, since I think it still uses some deprecated calls to Permissions that may go away soon.
  3. Offline


    Does this still work? Its on the inactive board for such long time :(
    Any news on this?
  4. Offline


    It still works perfectly but I don't know if anyone else beside myself is actually using it...?
  5. Offline


    I can move it back, but please update to latest RB (currently 670)
  6. Offline


    Now please test it on latest RB (currently 674).
  7. Offline


    Confirmed to work with 733. As long as the chat API doesn't change it should be fairly robust.
  8. Offline


    #here's one i use for words with 3 or more capital letters:

    match ^.*(\p{L}*\p{P}*\p{Lu}){3}\p{L}*\p{P}*.*$
    then warn NO CAPS!!!
    then replace
    then command warp chatrules

    #and to trim repeated characters to 2 repeats maximum:

    match (.)\1\1+
    then replace

    btw... thanks for the plugin... if you would have waited one day longer, i was planning on doing this :-P

    #replace nazi with barbie
    match \b(\S*?)(?:N|n)\p{P}*(?:A|a)\p{P}*(?:Z|z)\p{P}*(?:I|i)(\S*?)\b
    then replace barbie
    then log

    #replace IP addresses with 'terrible server' (stops advertising of other servers)
    match \b\d{1,3}+\p{P}*\d{1,3}+\p{P}*\d{1,3}+\p{P}*\d{1,3}+\b
    then replace terrible server
    then log

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: May 9, 2016
  9. Offline


  10. Offline


    You should add all caps filters within this.
  11. Offline


    @FloydATC Thanks for this plugin. I actually have something I can apply my learning of regular expressions to.

    Edit: Will you add the ability to match against actions (the /me command)?

    The first thing I'm doing is fixing some of the common annoyances I see in chat.. such as plz/pls/plx/plox/pl0x. It's not perfect, and I'm still working on it, but so far I have: pl[zsx]|pl[o0]x|/gi .. some of my players already love it :)
  12. Offline


    Interfering with other plugins' commands? It's not something I'm about to try any time soon, sorry...
  13. Offline


    That's fine, no big deal :)

    What about the ability to apply a filter to only one player, and the reverse.. apply the filter to everyone but one player?
  14. Offline


    any possibility of getting a 'then finish' or something? so the rest of the rules are ignored?
  15. Offline


    Love it!

    The regex is too much for me to sit down and read... but I can do the basics which is what I need. Thanks!
  16. Offline


    This is something I've been wanting to do, yes. It will be optional so if Permissions.jar is not available then such config statements will generate a warning at load time and then get silently ignored.

    Should be fairly easy to implement. Combining this with Permissions makes a lot of sense.

    Here's what I'm thinking... (WARNING: The final implementation may be different!)
    ignore user <usernames>            Skip current rule if username matches
    ignore group <groupnames>        Skip current rule if groupname matches
    ignore permission <permission_node>    Skip current rule if user has permission
    require user <usernames>        Skip current rule if username does not match
    require group <groupnames>        Skip current rule if groupname does not match
    require permission <permission_node>    Skip current rule if user does not have permission
    then finish                Abort ruleset processing if this rule matches
    (update: fixed copy/paste error)

    This would allow rules such as:
    match ^\!test
    require group admins
    then finish
  17. Offline


    that would be excellent
  18. Offline


    Great Plugin, thank you!

    Edit: This works perfectly on latest craft bukkit (766)
  19. Offline


    That's weird, my post was deleted. Is there a way to edit out glass and hello?
  20. Offline


    Can you PLEASE add a feature that will kick, ban, and/or mute players who use a censored word?
  21. Offline


    Kicking is easy, banning and muting will have to wait for now.

    Version 1.05 has been posted, with the following new features:
    • ignore user <names>
    • ignore group <names>
    • ignore permission <node>
    • require user <names>
    • require group <names>
    • require permission <node>
    • then abort
    • then kick
    • The "group" and "permission" checks will not be available unless the Permissions plugin is available.
    • Multiple "user" and "group" names must be separated by spaces.
    • All names are case-insensitive.
  22. Offline


    Quick question for you. can you have some sort of exact word match thing? For example, I want to ban the use of the word "ass" and "hell" however, nobody can then say, "Can I have some glass?" or "Hello, how are you?" because it sees ass and hell. Can you find a way to add * or "" in them? For example

    If word == "ass" then kick
    If word == "hell" then kick
    If word == *ass* then do nothing
    If word == Hell* then do nothing

    Hopefully you're understanding what I'm putting down.
  23. Offline


    You really should Google for a good tutorial on regular expressions, because fancy wildcard patterns are what they're all about. The word "ass" is actually a good example of why conventional wildcards (like the ones you find in Windows) are insufficient. Consider the words "glass", "assistant" and "massage". Basically, you only want to match the letters "ass" if they appear as a single word. The regular expression \b (word boundary) fits the bill in most cases, because it picks up on whitespaces, beginning/end of line as well as most punctuation.

    Try this:
    match \bass\b
    then replace bottom
  24. Offline


    Any idea why this matches "fuck" and overrides the filter I already have in place for this word?

    EDIT: Also, how do I specify more than one match on a single rule?
    e.g. match hell|damn|fart
  25. Offline


    Exactly like that. http://lmgtfy.com?q=regular+expressions
  26. Offline


    Oh, just learn advanced calculus from a textbook written in greek in 1 day you say? :p I'm rather certain that learning java (thereby making this moot) would be a lot easier. Just saying. I've struggled and struggled with regexp in the past and have never been able to wrap my head around it.
  27. Offline


    Any progress with adding the ability to mute players who use these bad words?
  28. Offline


    Nasty little bug here...

    2011-06-16 15:15:46 [INFO] [Filter] devonda> fuk fuck fuck fuck!
    2011-06-16 15:16:02 [SEVERE] javax.script.ScriptException: sun.org.mozilla.javascript.internal.EcmaError: TypeError: Cannot call method "getSettings" of null (<Unknown source>#28) in <Unknown source> at line number 28
    2011-06-16 15:16:02 [SEVERE]     at com.sun.script.javascript.RhinoScriptEngine.invoke(Unknown Source)
    2011-06-16 15:16:02 [SEVERE]     at com.sun.script.javascript.RhinoScriptEngine.invokeFunction(Unknown Source)
    2011-06-16 15:16:02 [SEVERE]     at nickguletskii200.SpyerAdmin.CustomHandling.who(Unknown Source)
    2011-06-16 15:16:02 [SEVERE]     at nickguletskii200.SpyerAdmin.SpyerAdminCommands.onCommand(Unknown Source)
    2011-06-16 15:16:02 [SEVERE]     at org.bukkit.command.PluginCommand.execute(PluginCommand.java:35)
    2011-06-16 15:16:02 [SEVERE]     at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:128)
    2011-06-16 15:16:02 [SEVERE]     at org.bukkit.craftbukkit.CraftServer.dispatchCommand(CraftServer.java:287)
    2011-06-16 15:16:02 [SEVERE]     at net.minecraft.server.NetServerHandler.handleCommand(NetServerHandler.java:712)
    2011-06-16 15:16:02 [SEVERE]     at net.minecraft.server.NetServerHandler.chat(NetServerHandler.java:678)
    2011-06-16 15:16:02 [SEVERE]     at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:671)
    2011-06-16 15:16:02 [SEVERE]     at net.minecraft.server.Packet3Chat.a(Packet3Chat.java:32)
    2011-06-16 15:16:02 [SEVERE]     at net.minecraft.server.NetworkManager.b(NetworkManager.java:226)
    2011-06-16 15:16:02 [SEVERE]     at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:75)
    2011-06-16 15:16:02 [SEVERE]     at net.minecraft.server.NetworkListenThread.a(SourceFile:105)
    2011-06-16 15:16:02 [SEVERE]     at net.minecraft.server.MinecraftServer.h(MinecraftServer.java:399)
    2011-06-16 15:16:02 [SEVERE]     at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:309)
    2011-06-16 15:16:02 [SEVERE]     at net.minecraft.server.ThreadServerApplication.run(SourceFile:422)
  29. Offline


    Yes, but the stack trace points to a "RhinoScriptEngine" in "SpyerAdmin". ECMA is the proper name for "JavaScript", which suggests there may be a problem with one of its configuration files or scripts. To confirm this, see if you still get this problem if you disable RegexFilter.
  30. Offline


    I removed SpyerAdmin after it messed up my server.
  31. Offline


    Download doesnt work. :(

Share This Page