Bot color changer

By toclafane1 on Jun 20, 2011

A simple bot color changer to use type

!color 0 - 15

you will need to put $read(color.txt, s, $chan) after each msg $chan

on *:LOAD: { 
  echo -s 3you have just loaded toclafane's color changer 
  echo -s 3to use type !color 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.
}
Sign in to comment.
blackvenomm666   -  Jun 21, 2011

just so you could ask about it conscious

 Respond  
Jethro   -  Jun 21, 2011

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.

 Respond  
Conscious   -  Jun 21, 2011

May I ask what the point of the ( |$) is?

 Respond  
Jethro   -  Jun 21, 2011
/^!(theme|colou?r)( |$)/Si

One great thing about regex is that it can match for both words at the same time using ? as an optional alternative.

 Respond  
blackvenomm666   -  Jun 21, 2011

that doesnt matter how some use it. it's how he has it set up if they want it to do colour they can change it themselves

 Respond  
Conscious   -  Jun 21, 2011

The opening line should be..

on $*:Text:/^(!theme|!colo(u?)r)/Si:#:{

Some use 'colour' and some use 'color'.

 Respond  
blackvenomm666   -  Jun 21, 2011

well as usual jaytea teaches me something new

 Respond  
napa182   -  Jun 21, 2011

so damn true. ;x

 Respond  
Jethro   -  Jun 21, 2011

Yes, jaytea. Well said.

While !$2 is fairly interchangeable with $2 = $null, it's not completely identical to one another in its function.

 Respond  
jaytea   -  Jun 21, 2011
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.

 Respond  
toclafane1   -  Jun 20, 2011

hahaha lol

 Respond  
blackvenomm666   -  Jun 20, 2011

just one way is shorter haha

 Respond  
Jethro   -  Jun 20, 2011

chelero, they're fairly interchangeable.

 Respond  
toclafane1   -  Jun 20, 2011

thanks for the comments

 Respond  
chelero   -  Jun 20, 2011

if ($2 == $null) {

to;

if (!$2) {

 Respond  
Jethro   -  Jun 20, 2011

Ok just change 1-9 to 0-9 then...

 Respond  
napa182   -  Jun 20, 2011

Jethro_, one thing I know he said 1-15 in his description, but in the code its self they are 0-15 so you will have to allow 0 =P

 Respond  
Jethro   -  Jun 20, 2011
On $*:Text:/^!(theme|color) ?([1-9]|1[0-5])?( |$)/Si:#:{
    if ($nick($chan,$nick,@&~)) {
    if ($strip($2) == $null) {

You can indicate the color range directly to ensure that it starts from 1 to 15. And if $2 isn't supplied, it will message the warning as usual.

 Respond  
toclafane1   -  Jun 20, 2011

ok thanks and i will have a look in to that :)

 Respond  
napa182   -  Jun 20, 2011

if you are going to use regex you may as well use $regml() just replace where you have $2- or $2 with $regml(2) this is just a example :

On $*:Text:/^!(theme|color)?\s?(\d+)?/Si:#:{
  if ($nick($chan,$nick,@&~)) {
    if ($regml(2) !isnum 0-15) {
 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.