Raised This Month: $ Target: $400
 0% 

[Any] Regex Trigger (v2.5.2)


Post New Thread Reply   
 
Thread Tools Display Modes
Author
JoinedSenses
Senior Member
Join Date: Sep 2013
Plugin ID:
6104
Plugin Version:
2.5.2.
Plugin Category:
Server Management
Plugin Game:
Any
Plugin Dependencies:
    Servers with this Plugin:
    117 
    Plugin Description:
    Regex trigger/filter for names, chat and commands
    Old 04-20-2018 , 00:54   [Any] Regex Trigger (v2.5.2)
    Reply With Quote #1

    Regex Trigger

    v2.5.2.

    Only works with SM 1.10



    Description:

    Serves as a regex trigger/filter for names, chat, and commands.
    This plugin is pretty much a direct upgrade to this: https://forums.alliedmods.net/showthread.php?t=71867.

    Check out the documentation there, since I feel they've done a nice job of detailing it.
    One difference is that this plugin allows the use of "namefilter" and "commandfilter" in the config file, not just "chatfilter"

    If you'd like to see a demo of the discord relay, pm me for an invite to my discord.

    For more information, please see the post below, or visit my github repo for this project:
    https://github.com/JoinedSenses/SM-Regex-Trigger


    What this plugin does:
    Serves as a trigger/filter for names, chat, and commands using a config which allows for regex.
    Only tested in TF2 and CSS

    If you are unfamilair with regex, read through the attached RegexExplanation.txt or check out these websites:
    http://www.rexegg.com/regex-quickstart.html
    https://www.regular-expressions.info/
    https://regex101.com

    Code:
    [\s\W_]*(?:s|scrap|ref|crate|selling|[0-9]+)\s*(?:to|\W|\W*[0-9]+)\s*(?:unusuals*|unu)[\s\W_]*\b




    Relay Integration
    Included IRC/Discord Features:
    * Method to relay 'connect' messages to a main IRC channel
    * Method to relay triggered names and chat/command messages to discord channels for debugging/analysis.




    ConVars:
    sm_regex_allow "1" Status of the plugin. (1 = on, 0 = off)
    sm_regex_config_path "configs/regextriggers/" Location to store the regex triggers at.
    sm_regex_check_chat "1" Filter out and check chat messages.
    sm_regex_check_commands "1" Filter out and check commands.
    sm_regex_check_names "1" Filter out and check names.
    sm_regex_prefix "" Prefix for random name when player has become unnamed
    sm_regex_irc_enabled "0" Enable IRC relay for SourceIRC. Sends messages to flagged channels"
    sm_regex_channelname "" Key name from discord.cfg for name relay"
    sm_regex_channelchat "" Key name from discord.cfg for chat relay"


    Installation:
    * Install regexfiltering.smx into your plugins folder.
    * Create a key values config at addons/sourcemod/configs/regextriggers/regextriggers.cfg. Use the available config for reference if need.
    * Optional: SourceIRC for multi-server relay functionality
    * Optional #2: modified version of SourceIRC
    * Optional #3: Discord API and configure discord.cfg and cfg/sourcemod/plugin.regextrigger.cfg.
    * Load the plugin once and edit cfg/sourcemod/plugin.regextrigger.cfg as needed. Reload plugin if changes were made.

    To compile, you will need sourceirc.inc and discord.inc

    Config Keys
    Warn: Display a warning message to the player
    Code:
    "warn" "msg"
    Allows you to give fair warning about your rules when they are broken

    Action: Executed if a pattern matches
    Code:
    "action" "rcon action"
    "rcon action" can be any command you want, but there may be only one action per section.
    %n, %i, and %u will be replaced with the clients name, index, or userid, respectively, if they are in the command string.

    Block: Block the text absolutely (Does not work for names)
    Code:
    "block" "1"
    Very simple, skips all the replacement stuff, does not skip the limiting step, so you can block and limit at the same time (limit the amount of times one can attempt to say it, and also block the words from being said)

    Limit: Limit the amount of times the matched action can occur
    Code:
    "limit" "number"
    Also simple, will block if the client says the pattern more times than "number"

    Forgive: Forgives one indiscretion every x seconds
    Code:
    "forgive" "x"
    Allows more flexibility with limiting. It might be ok to advertise once every five minutes, not every five seconds, so you can "forgive" a slip up every "x" seconds.

    Punish: executes a punishment command if limit is exceeded
    Code:
    "punish" "cmd"
    "cmd" can be any command you want, but there may be only one punishment per section.
    %n, %i, and %u will be replaced with the clients name, index, or userid, respectively, if they are in the command string.

    Replace: Replaces matched text with a value.
    Code:
    "replace" "with"
    Will replace the pattern's matches with "with", and check everything again.
    Supports use of capture groups greater than 0 by using \#, such as \1 or \2

    Relay: Relays information to the related discord channel
    Code:
    "relay" "1"
    If enabled and discord api is use, this will allow the plugin to relay messages to discord channels.


    GITHUB

    - Changelog

    .
    Attached Files
    File Type: txt RegexExplanation.txt (6.7 KB, 817 views)

    Last edited by JoinedSenses; 05-09-2019 at 07:27. Reason: Updated version number
    JoinedSenses is offline
    JoinedSenses
    Senior Member
    Join Date: Sep 2013
    Old 04-20-2018 , 00:56   Re: Regex Filtering
    Reply With Quote #2

    Quote:
    Originally Posted by Twilight Suzuka View Post
    Want to filter not only dirty words and potentially offensive phrases, but also things like IP and email addresses? Then this plugin is for you!

    This plugin provides the ability to do the following things if a clients say text matches a provided REGEX pattern.

    (chatpattern) for chat

    1. Execute an RCON command (action)
    2. Limit the amount of times such a pattern may be spoken (limit)
    3. Enforce the limit with a block of the text
    4. Enforce the limit with a punishment RCON command (punish)
    5. Allow for forgiveness of one violation every x seconds (forgive)
    5. Block the text absolutely (no limit) (block)
    6. Replace the matches with a string (replace)
    7. Replace matches from ANOTHER REGEX pattern with a string (replacepattern)
    8. Warn the client they are violating the matching rules (warn)
    9. Allow admins with specified levels to be immune (immunity)

    All of this is done via a simple file format, no commands required!

    Format:

    The file, configs/regexrestrict.cfg, is structured in typical SM structure.
    To group a bunch of patterns to specific rules, put them all into a subsection together.

    Ex.

    Code:
    "Censor"
    {
    	"ExampleBlock"
    	{
    		"chatpattern"		"fuck 'CASELESS'"
    		"warn"				"Don't say that!"
    		"replace"			"FACK"
    	}
    }
    Here are the usable blocks:

    Chat Pattern: Search for a pattern

    Code:
    "chatpattern" "pattern 'flags'"
    Multiple flags can be used, seperate them with a |.
    If no flags are set, omit the delimiting single quote characters.
    You may also delimit the pattern with single quotes for prettiness, ala:

    Code:
    "chatpattern" " 'pattern' 'flags' "
    Valid Flags:
    Code:
    CASELESS - Ignore Case.
    MULTILINE - Multilines (affects ^ and $ so that they match the start/end of a line rather than matching the start/end of the string).
    DOTALL - Single line (affects . so that it matches any character, even new line characters). 
    EXTENDED - Pattern extension (ignore whitespace and # comments).
    UNGREEDY - Invert greediness of quantifiers
    UTF8 - Use UTF-8 Chars */
    NO_UTF8_CHECK - Do not check the pattern for UTF-8 validity (only relevant if PCRE_UTF8 is set)
    Warn: Display a warning message to the player

    Code:
    "warn" "msg"
    Allows you to give fair warning about your rules when they are broken

    Action: Executed if a pattern matches

    Code:
    "action" "rcon action"
    "rcon action" can be any command you want, but there may be only one action per section.

    %n, %i, and %u will be replaced with the clients name, index, or userid, respectively, if they are in the command string.

    Block: Block the text absolutely

    Code:
    "block" "1"
    Very simple, skips all the replacement stuff, does not skip the limiting step, so you can block and limit at the same time (limit the amount of times one can attempt to say it, and also block the words from being said)

    Limit: Limit the amount of times a piece of text can be said

    Code:
    "limit" "number"
    Also simple, will block if the client says the pattern more times than "number"

    Forgive: Forgives one indiscretion every x seconds

    Code:
    "forgive" "x"
    Allows more flexibility with limiting. It might be ok to advertise once every five minutes, not every five seconds, so you can "forgive" a slip up every "x" seconds.

    Punish: executes a punishment command if limit is exceeded

    Code:
    "punish" "cmd"
    "cmd" can be any command you want, but there may be only one punishment per section.

    %n, %i, and %u will be replaced with the clients name, index, or userid, respectively, if they are in the command string.

    Replace: I think you get it

    Code:
    "replace" "with"
    Will replace the pattern's matches with "with", and check everything again. This can cause an avalanche effect if "with" matches a previous pattern somehow, rendering many changes, which wastes CPU, but can render interesting messages.


    Replace Pattern: Replace against a pattern

    To be added soon, currently just deletes based on pattern


    To do:
    Allow name and command enforcement

    Have fun!

    Edit: Altered slightly; will now accept a map based regex file, of the format "regexfilter_MAPNAME.cfg", and will power off if no regex filter files are found (for efficiency reasons).
    JoinedSenses is offline
    T1MOXA
    Member
    Join Date: Aug 2016
    Old 05-03-2018 , 20:19   Re: [TF2/CSS/Any?] Regex Filter (redux)
    Reply With Quote #3

    A good plugin, but as for me it lacks whitelists for each rule.
    Let's say I want to block all domains except certain.

    Last edited by T1MOXA; 05-03-2018 at 20:19.
    T1MOXA is offline
    JoinedSenses
    Senior Member
    Join Date: Sep 2013
    Old 05-05-2018 , 15:17   Re: [TF2/CSS/Any?] Regex Filter (redux)
    Reply With Quote #4

    Quote:
    Originally Posted by T1MOXA View Post
    A good plugin, but as for me it lacks whitelists for each rule.
    Let's say I want to block all domains except certain.
    You can add your own whitelist with negative lookbehind to allow exemptions. The config attached is just a guideline - you can write your own config or modify the one attached.

    http://www.rexegg.com/regex-lookarounds.html

    Lets say you wanted to add an exemption for google.com in names
    here is the original
    Code:
    [\W\s]*[\w\-\.]+[,.]+(?:de|com|co|org|trade|me|ru|gg|tf|net)[\/]*\W*
    and here is the modified
    Code:
    [\W\s]*[\w\-\.]+(?<!google)[,.]+(?:de|com|co|org|trade|me|ru|gg|tf|net)[\/]*\W*
    If it contains the word google in front of the period, it exempts the filter.

    Make sure you check out the links I attached in the original post if you're interested in learning how regex works so that maybe you can write your own .cfg file or modify the one I attached.

    Last edited by JoinedSenses; 05-05-2018 at 15:20.
    JoinedSenses is offline
    T1MOXA
    Member
    Join Date: Aug 2016
    Old 05-06-2018 , 11:38   Re: [TF2/CSS/Any?] Regex Filter (redux)
    Reply With Quote #5

    In my opinion it will complicate the rules and not all users will understand how to do it...
    T1MOXA is offline
    JoinedSenses
    Senior Member
    Join Date: Sep 2013
    Old 05-06-2018 , 19:35   Re: [TF2/CSS/Any?] Regex Filter (redux)
    Reply With Quote #6

    Regex is a powerful tool, but it's up to the users of this plugin whether or not they want to learn how it works.
    If you have any specific questions regarding configuration creation, feel free to add me on steam.

    As I said, the attached configuration is just an example and doesn't need to be used - you can create your own config. Something as simple as this can be used:
    Code:
    "Censor"
    {
    	"Website names"
    	{
    		"namepattern"		"lmaobox\.net 'CASELESS'"
    		"namepattern"		"trade\.tf 'CASELESS'"
    		"namepattern"		"scrap\.tf 'CASELESS'"
    		"replace"		""
    	}
    }
    The code used within the attached config is just a catch-all regex and can be removed. Most of the items within the config just include more complex methods to prevent users from cirvumventing the filter.

    Last edited by JoinedSenses; 05-05-2019 at 02:41.
    JoinedSenses is offline
    JoinedSenses
    Senior Member
    Join Date: Sep 2013
    Old 05-08-2018 , 02:14   Re: [TF2/CSS/Any?] Regex Filter (redux)
    Reply With Quote #7

    I have attached RegexExplanation.txt, which details what the config does and how it works.

    Last edited by JoinedSenses; 05-08-2018 at 10:15.
    JoinedSenses is offline
    ThatKidWhoGames
    Veteran Member
    Join Date: Jun 2013
    Location: IsValidClient()
    Old 05-08-2018 , 08:06   Re: [TF2/CSS/Any?] Regex Filter (redux)
    Reply With Quote #8

    Awesome! Thanks for this
    ThatKidWhoGames is offline
    JoinedSenses
    Senior Member
    Join Date: Sep 2013
    Old 05-21-2018 , 22:32   Re: [TF2/CSS/Any?] Regex Filter (redux)
    Reply With Quote #9

    Updated to v.2.1.1

    Added list of random names to choose from if player name is 'unnamed' after passing through filters.
    Added sm_regexfilters_prefix cvar to add a prefix to a players randomly generated name.

    You can view the changes here: https://github.com/JoinedSenses/TF2-...ec7a61b344e39c


    Last edited by JoinedSenses; 05-26-2018 at 11:55.
    JoinedSenses is offline
    JoinedSenses
    Senior Member
    Join Date: Sep 2013
    Old 11-17-2018 , 14:15   Re: [TF2/CSS/Any?] Regex Filter (redux)
    Reply With Quote #10

    Plugin has been updated to version 2.4.3. - Mostly includes bug fixes on name checking.

    Last edited by JoinedSenses; 05-05-2019 at 02:42.
    JoinedSenses is offline
    Reply


    Thread Tools
    Display Modes

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off

    Forum Jump


    All times are GMT -4. The time now is 02:36.


    Powered by vBulletin®
    Copyright ©2000 - 2024, vBulletin Solutions, Inc.
    Theme made by Freecode