you should loop the channel you on, and use the if-then-else statement to check if $Nick ison #chan2 and then do the command you desire