I would suggest doing /who the_nick and check for an * rather than doing /whois simply because /who only returns 2 numerics where as /whois returns many. Even better (if your network supports it, and most do) would be to /userhost the_nick and check for an *. /userhost only returns 1 numeric so it is even easier to setup the script for that.