[TWITCH] Help with regex, regular expressions - 10/03/17 06:36 PM
EDIT: NVM, figured it out
So I'm making a antispam script using regex. So for example if somebody in chat types "dab" he will get timed out for 10 sec. I wrote the code but came across a problem, in the 9th line
if I leave space between \b and % it will only trigger when someone types "Something dab something" but i want it to trigger if someone just types "dab". I might be stupid for not figuring this out but what can you do, I just got into regular expressions so I'm still learning and all the help is really appreciated!
Tnx in advance.
Whole code:
So I'm making a antispam script using regex. So for example if somebody in chat types "dab" he will get timed out for 10 sec. I wrote the code but came across a problem, in the 9th line
Code:
if ($regex($1-,/\b %blacklistedWord \b/)) { ... }
if I leave space between \b and % it will only trigger when someone types "Something dab something" but i want it to trigger if someone just types "dab". I might be stupid for not figuring this out but what can you do, I just got into regular expressions so I'm still learning and all the help is really appreciated!
Tnx in advance.
Whole code:
Code:
on *:text:*:#: { var %i = 1 if ($nick isop $chan || $ini(%antispamFolder,0) == 0 || %antispamStatus != $true) { halt } elseif (%antispamStatus == $true) { while (%i <= $ini(%antispamFolder, 0)) { var %blacklistedWord = $readini(%antispamFolder, %i, Text) if ($regex($1-,/\b %blacklistedWord \b/)) { var %channelAntispam = $readini(%antispamFolder, %i, Channel) if (%channelAntispam == $chan) { var %timeouttime = $readini(%antispamFolder, %i, Time) if (%timeouttime == Ban) { msg $chan /ban $nick Blacklisted word/phrase return } else { msg $chan /timeout $nick %timeouttime Blacklisted word/phrase return } } } inc %i } } }