Detect if IRC user is “voice” or higher [C # irc bot]

I have a team that I want to limit only to certain ranks. I am using unreal3.2.6 IRC.

I read this: enter image description here

But I'm still not sure what I can do to check user ratings.

I want to find out if the user is “Voice” or higher. What can I look at the user, and what can I do to check if they are voice or higher? What are the values ​​for each rank so that I can check?

I am only trying to check the current channel, not the entire IRC server.

For example:

When a user tries to execute the !roll (Rolls a dice) command and is not a Voice or higher, nothing will happen.

 if (data.Equals("!roll")) { //Check if user contains (@,+,etc?) if(nickname.StartsWith(@..+..etc)) { roll(nickname); } } 
+7
source share
2 answers

Instead of asking a user with a WHOIS command, you need to request the appropriate channel using the NAMES command.

From RFC 2812 - Internet Relay Chat: Client Protocol :

3.2.5 Message Names

Team: NAMES

Parameters: [ <channel> *( "," <channel> ) [ <target> ] ]

Using the NAMES command, the user can list all the nicknames that are visible to him. For more information on what is visible and what is not, see "Internet Relay Chat: Channel Control" [IRC-CHAN] . The <channel> parameter indicates which channel (s) should return information. There is no response to invalid channel names.

If the <channel> parameter is not specified, a list of all channels and their inhabitants is returned. At the end of this list, a list of users who are visible but not on any channel or not on the visible channel are listed as "channel" " * ".

If the <target> parameter is specified, the request is sent to the server that will generate the response.

The <target> parameter allows wildcards.

Numeric:

ERR_TOOMANYMATCHES ERR_NOSUCHSERVER
RPL_NAMREPLY RPL_ENDOFNAMES

Examples:

NAMES #twilight_zone,#42 ; Command to display visible users in #twilight_zone and # 42

NAMES Command to display all visible channels and users

A channel request using the NAMES command will give the following two answers:

353 RPL_NAMREPLY

"( "=" / "*" / "@" ) <channel>
:[ "@" / "+" ] <nick> *( " " [ "@" / "+" ] <nick> )

  • " @ " is used for secret channels, " * " for private channels and " = " for others (public channels).

and:

366 RPL_ENDOFNAMES

"<channel> :End of NAMES list"

You can split the nickname list into a space character and determine whether the first nickname is a mode identifier ( + , @ , etc.) or an alphanumeric character (which implies that the user does not have a special mode on the channel.)

The IRC standard defines only + as the voice of the user and @ as the channel operator, but it is known that other servers use special characters, such as ~ for the channel owner and & for the "super" channel operators. Typically, you can simply check that the user has some kind of channel mode (other than the default) to make sure they are voiced or better.

+6
source

If you are not using the API that provides you with this information, the IRC protocol does not give you any messages in "ident @vhost" in the WHOIS response 311. IRC bots that I wrote in the past, you must track this material yourself. Although when you send the WHOIS <nick> command, the response line 319 will have a list of channels in which the nickname is located, and @ / + /% / ~ in front of the channels indicating the user modes that the nickname has in this channel. You can analyze them, but this will increase the amount of traffic if you need to send WHOIS every time someone does something on the channel.

When you first join the channel, you will get a bunch of 353 <your nick> @ <channel> :<user_list> , where <user_list> could be:

: snowcloud Chibi-Ryu CUF Nere ~ thundra vatar nm449 | Klapo Apocalypse + Skull_Leader% KagaminBot Razaekel Kloacy & Cherry-chan @happytang MagusHrist% Frostii hexerr laptop

You can see modifiers + (voice), % (half-operator), @ (op), ~ (owner) before each nickname. In addition, if you select WHO <channel> (depending on the server, you may need to be in the channel to get something back), you will receive a line response on line 352: 352 <your nick> <channel> <user> <host> <server> <nick> <H|G>[*][@|+|%|~] :<hopcount> <real name> . And you can parse the material after H / G to get custom modes.

This is the only way to request custom modes, but while your bot is sitting in the channel, it will receive messages like MODE <channel> +|-<v|h|a|o> <nick> . So when you see one of them, you can internally keep track of who got + v or -v, etc. Then you will not need to send a command to the server every time someone from the channel makes a “! Roll” "(some IRC servers will kick you for flooding if you keep sending WHOIS).

+5
source

All Articles