Instead of querying the user with a WHOIS
command, you need to query the applicable channel with the NAMES
command.
From RFC 2812 - Internet Relay Chat: Client Protocol:
3.2.5 Names message
Command: NAMES
Parameters: [ <channel> *( "," <channel> ) [ <target> ] ]
By using the NAMES
command, a user can list all nicknames that are visible to him. For more details on what is visible and what is not, see "Internet Relay Chat: Channel Management" [IRC-CHAN]. The <channel>
parameter specifies which channel(s) to return information about. There is no error reply for bad channel names.
If no <channel>
parameter is given, a list of all channels and their occupants is returned. At the end of this list, a list of users who are visible but either not on any channel or not on a visible channel are listed as being on 'channel' "*
".
If the <target>
parameter is specified, the request is forwarded to that server which will generate the reply.
Wildcards are allowed in the <target>
parameter.
Numerics:
ERR_TOOMANYMATCHES
ERR_NOSUCHSERVER
RPL_NAMREPLY
RPL_ENDOFNAMES
Examples:
NAMES #twilight_zone,#42
; Command to list visible users on #twilight_zone and #42
NAMES
; Command to list all visible channels and users
Quering a channel with the NAMES
command will yield these two replies:
353
RPL_NAMREPLY
"( "=" / "*" / "@" ) <channel>
:[ "@" / "+" ] <nick> *( " " [ "@" / "+" ] <nick> )
- "
@
" is used for secret channels, "*
" for private channels, and "=
" for others (public channels).
as well as:
366
RPL_ENDOFNAMES
"<channel> :End of NAMES list"
You can split the list of nicks on the whitespace character, and determine whether the first character of a nick is a mode identifier (+
, @
, etc..) or an alphanumeric character (which implies that the user has no special mode on the channel.)
The IRC standard only defines +
as a voiced user and @
as a channel operator, but other servers can be known to use special characters like ~
for channel owner and &
for "super" channel operators. As a general rule, you could simply check to see that the user has any channel mode (other than the default) to verify that they're voiced or better.