The thing is, everybody can enter $2 as a word, and it doesn't have to be a channel. We want to make sure it starts with "#." just in case. There are people who might tamper with it. I don't see the need for three text events though:
on $*:text:/^(yes|no|join\s\43(?!\43)\S+)$/iS:?:{
if ($regml(1) == yes) && (%invite == on) {
set %yes on
.timer 1 2 msg $nick thank you now please type join #chan and i will join.
}
elseif ($regml(1) == no) {
msg $nick You responded no good bye..
close -m $nick
}
else {
if (%yes == on) {
.timer 1 2 msg $nick joining $token($regml(1),2,32) now...
.timer 1 4 $regml(1)
}
else {
.timer 1 2 msg $nick you have not said yes or have not invited me to the channel. plz try again
unset %invite %yes
close -m $nick
}
}
}