it all depends on where it's placed as to what it will do.. if nick is in the target place as in ctcpreply $nick it will send to that nickname.. if you had ctcpreply $nick $nick hey it would target the nickname and say the nickname in the reply.
This is the concept I tend to follow
If i want to create a var for use only while the snippet is processing like a while loop then use a temp variable
example to check what dialogs you currently have open
/checkdialogs {
var %d 1
while ($dialog(%d)) {
echo -a $dialog(%d)
inc %d
}
}
now %d is a variable set, but it only lasts until the snippet is done processing. You do not have to use any unset. Once the process is over the var is gone.
You can also use an unset command on a timer
set -u5 %blah on
This will set the variable %blah to on for a period of 5 seconds and then auto unset it. Reasoning behind using temp vars and timed unsets is to keep unneeded variables from accumulating in your variables file.
Only set a non temp, non timed unset variable if you plan on using the variable for prolonged periods of time. I mainly use variables for settings or information I wish to keep for long periods of time. There are other methods such as hash tables and ini files that can do the same thing but I would first get comfortable with variables before i moved on to those other types.
You won't have to set variables for things like $chan or $nick in an event unless you plan on carrying them over to something else. If the event supports the identifier you don't have to set a variable.
for example
on *:JOIN:#:{
set %nickname $nick
set %channelname $chan
ctcpreply %nickname Hey %nickname welcome to %channelname
unset %nickname, %channelname
}
is more easily done with
on *:JOIN:#:{
ctcpreply $nick Hey $nick welcome to $chan
}
The code doesn't work on buzzen because buzzen does not support ctcp like that so it would be a bit useless.
Koach does have support for ctcp so you shouldn't have problems there
Another thing to consider is on join commands like that, is to always add in flood protection. If you had a mass join on the room it would play havoc and most likely disconnect you without some form of flood protection.
a simple auto unsetting variable would be a good idea.
example
on *:JOIN:#:{
inc -u3 %welcome.flood
if (%welcome.flood == 1) && ($nick != $me) { ctcpreply $nick Hey $nick welcome to $chan }
}
Basically what it is doing is each time there is a join it sets an increasing number to the variable %welcome.flood
Peter joins room
%welcome.flood is set to 1
Jan joins room
%welcome.flood is set to 2
and so on
but the variable will unset after 3 seconds defined by the -u3
so it will start the count back over after 3 seconds
so if more than 1 user joins in a 3 sec period it will not ctcpreply the nick
:note the unset time can be lowered in a very active room
As with most anything in scripting you can achieve the same thing in many different ways. I've laid out the previous examples in a way I hope is very easily understandable. If you have any questions just ask.
Edited Mar 20, 2009 5:45 PM by err0r