View Single Post
Author Message
JoinedSenses
Senior Member
Join Date: Sep 2013
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, 808 views)

Last edited by JoinedSenses; 05-09-2019 at 07:27. Reason: Updated version number
JoinedSenses is offline