Are you sure %nick is being set to what you are expecting? Try adding this debug line:
/echo -s nick: %nick
Assuming the variable is being set correctly (ie to a nickname who is on the channel where the text is received), the code should work as it is written.
-genius_at_work