There is no $chan in a raw event, try $1 instead.

No such command as /closemsg. Try window -c $nick.

Again, I do not suggest while loops in text commands.

Are you certain the ignore command is being called? Do you see their nick in the ignore list?

/echo -a is a scripters friend. We use echo to show us exactly what is going on in a script. You can use it simply let you know that a comparison checked true or to return the actual data in the event.

raw whisper:*:{
echo -s WHISPER $1-

}
This here alone will tell you a lot about the whisper event.

You can also use $rawmsg to get the actual data the server sends you.