Many ircds have a way of doing that via the /who command.
The following works on unreal ircd and on bewareircd (the two I can run locally atm. I know both ircu (Undernet) and bahamut (Dalnet) have an equivalent format)
I think bahamut's is:
(but I'm just working from (poor) memory).
And it looks like (from reading the source, so untested) ircu's format is:
(note the '%' separator, it is required to mark the second set of options - here there are no options specified)
Obviously doing this server-side rather than client side is better for you (all the hard work is done by the remote computer, not your local machine)!