use $chr(35) instead of # because mIRC thinks # is the current channel name in events that are triggered from a channel.