A simple Colour Changer! To change the colour of your text > !color/!theme 0-15
msg $chan $read(color.txt, s, $chan) $+
on *:LOAD: { echo -s 04Colour changer by Stewie - to use: !color/!theme 0-15 }
on $*:TEXT:/^(!theme|!color)/Si:#:{
if ($nick($chan,$nick,@&~)) {
if ($2 == $null) {
msg $chan $read(color.txt, s, $chan) $+ Please use: !theme E.g !theme 3
msg $chan $read(color.txt, s, $chan) $+ My color themes are: ( $+ 0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 $read(color.txt, s, $chan) $+ )
msg $chan $read(color.txt, s, $chan) $+ To reset $me $+ 's color theme for $chan use: !theme 0
}
else {
write -ds $chan color.txt
write color.txt $chan $+ $2-
msg $chan $read(color.txt, s, $chan) $+ $+ $nick $+ , your new color theme will look like this in $chan
}
}
else msg $chan $read(color.txt, s, $chan) $+ Sorry $nick $+ , you cannot use this command.
}
It stop at the word by itself or followed by a space. That way you don't trigger the regex if someone says, for example "colorful" or "colourful"
I used to utilize the word boundary \b, but it doesn't stop punctuation characters from triggering it to what I call it a "false positive." A sentence usually consists of many words in this format: "word1 word2 word3," so ( |$) will make sure it either proceeds with a space or ends the word as is.
It also allows you to use $2 if you don't want to use $regml() to refer to the value.
if ($2 == $null) {
to;
if (!$2) {
bad idea in this case. 'if (!$2)' is not the same as 'if ($2 == $null)'. if (!$2) is equivalent to:
if ($2 == 0) || ($2 == $false) || ($2 == $null)
'0' is a valid colour (although the script's description is inconsistent with the message in on LOAD) and so we wouldn't want to use 'if (!$2)' since $2 = 0 will satisfy that condition.