RegEx Chat Filter

Discussion in 'Plugin Requests' started by MPG1, Aug 1, 2020 at 10:59 AM.

  1. Offline

    MPG1

    Info:
    • Version: 1.14.4 Spigot
    • Category: Chat
    • Suggested Name: RegExChat
    • Due: A.S.A.P i guess
    Thingy:
    You might say there are already RegEx filters out there. I tried some, looked over others, but none fit the bill. I'm looking for the most simple it can get.
    Description:
    If anything matching a regex expression is sent in chat or with configurable commands, it will be replaced with a configurable character.
    Regex expressions will be stored in a text backend, 1 expression per line. (filter.txt)

    Commands:
    Code:
    /regex add <filter> (regex.add):
       Adds a regex expression to the filter list.
    /regex remove <number> (regex.remove):
       Prints a list of filters, click one to remove it. (with toggleable confirm)
    /regex list (regex.list):
       Prints a list of the filters, and the replacement character.
    /regex debug [textfile?] (regex.debug):
       Prints all the messages that matched an expression in the console/textfile in this format:
          <timestamp> "%text%" - %filter%
    Other Permissions:
    Code:
    regex.bypass.<filter number>:
    Allows you to bypass the filter indicated.
    regex.bypass.*:
    Allows you to bypass all filters.
    
     
    Last edited: Aug 2, 2020 at 10:39 AM
  2. Offline

    timtower Moderator Moderator

    @MPG1 Send where? Chat? Or should it also replace messages by plugins?
    Could you post an example file?
     
  3. Offline

    MPG1

    I made edits in italic, for ease of finding.
    Config:
    Code:
    replacechar: "*" # character to replace regex matches
    chatcommands: # commands to filter regex from
    - me
    - w
    - r
    - etc...
    Filters.txt:
    Code:
    d+((\s|_|-)*|.{1,2})(i|1)+((\s|_|-)*|.{1,2})c+((\s|_|-)*|.{1,2})(k|c)+ #example filter for d*ck
    l(a|4)g # example filter for "lag"
    debug.txt (if applicable):
    <timestamp> "lag" - l(a|4)g
     
  4. Offline

    timtower Moderator Moderator

    @MPG1 checking commands is not easy, or it is just chat or it is with all messages send to the player.
     
  5. Offline

    MPG1

    Yea- the latter.
    Any message sent with a command in the list.
    I think that's a thing in EssentialsXchat, so it should be possible.
     
  6. Offline

    timtower Moderator Moderator

    @MPG1 EssentialsChat does not handle plugin messages like worldedit, if this is done then it will be done based on packets, not on hooking into specific plugins.
     
  7. Offline

    KarimAKL

    @MPG1 I haven't tried this with other plugins so, i'm not sure how compatible it is.

    Anyway, try this.

    Note: I'm not done, i just wanted to give you a "preview" file. The replacing as well as the "/regex add (some filter here)" command should already be working, it's just the other 3 commands. I also wanted to add a parameter of sorts to the config so it can be like "- tell 2,3" or something. I'm thinking those will be used to exclude arguments from the commands so you won't censor the player's name when trying to send them a message.

    Let me know what you think about the idea and the "preview" plugin.
     
  8. Offline

    MPG1

    Thanks! I will try this A.S.A.P, and I am really thankful for this. Hooray!

    Edit: Woah! I love the help command, the config and the backend. This is AWESOME! (Please continue)
     
    Last edited: Aug 6, 2020 at 8:14 PM
    KarimAKL likes this.
  9. Offline

    MPG1

    bump for KarimAKL
     
    KarimAKL likes this.
  10. Offline

    KarimAKL

    Glad to hear it. :) I'm currently not at my PC but, i will be back this Sunday.
     

Share This Page