Contents
irc_cmd_join
Joins the new IRC channel. If the channel does not exist, it will be automatically created by the IRC server. Note that to JOIN the password-protected channel, you must know the password, and specify it in the key argument.
If join is successful, the event_join will be called (with origin set to your nickname), then you are sent the channel’s topic (using event_topic) and the list of users who are on the channel (using LIBIRC_RFC_RPL_NAMREPLY), which will include the user joining – namely you.
Prototype:
int irc_cmd_join ( irc_session_t * session,
const char * channel,
const char * key)
Parameters:
| session | The IRC session which is initiated and connected |
| channel | A channel name to join to. Cannot be NULL. |
| key | Channel password. May be NULL. |
Return value:
Return code 0 means the command was sent to the IRC server successfully. This does not mean the operation succeed, and you need to wait for the appropriate event (in this case event_join) or for the error code (event_numeric).
irc_cmd_part
Leaves the IRC channel. This function is used to leave the IRC channel you’ve already joined to. An attempt to leave the channel you aren’t in results a LIBIRC_RFC_ERR_NOTONCHANNEL server error.
Prototype:
int irc_cmd_part( irc_session_t * session,
const char * channel )
Parameters:
| session | The IRC session which is initiated and connected |
| channel | A channel name to leave. Cannot be NULL. |
Return value:
Return code 0 means the command was sent to the IRC server successfully. This does not mean the operation succeed, and you need to wait for the appropriate event (in this case event_part) or for the error code (event_numeric).
irc_cmd_invite
This function is used to invite someone to invite-only channel. “Invite-only” is a channel mode, which restricts anyone, except invided, to join this channel. After invitation, the user could join this channel. The user, who is invited, will receive the event_invite event. Note that you must be a channel operator to INVITE the users.
Prototype:
int irc_cmd_invite( irc_session_t * session,
const char * nick,
const char * channel )
Parameters:
| session | The IRC session which is initiated and connected |
| nick | A nick to invite. |
| channel | A channel name to invite the nick to. |
Return value:
Return code 0 means the command was sent to the IRC server successfully. This does not mean the operation succeed, but there is no confirmation from the server, so unless you received an error via event_numeric, you should assume it succeed.
irc_cmd_names
This function is used to ask the IRC server for the list of the users who’re in specified channel. You can list all nicknames that are visible to you on any channel that you can see. The list of users will be returned using RPL_NAMREPLY and RPL_ENDOFNAMES numeric codes.
Prototype:
int irc_cmd_names( irc_session_t * session,
const char * channel )
Parameters:
| session | The IRC session which is initiated and connected |
| channel | A channel name(s) to obtain user list. It is possible to specify several channels separated by a comma. |
Return value:
Return code 0 means the command was sent to the IRC server successfully. This does not mean the operation succeed, and you need to wait for the appropriate event or for the error code (event_numeric).
irc_cmd_list
Obtains a list of active server channels with their topics. This function is used to ask the IRC server for the active (existing) channels list. The list will be returned using LIBIRC_RFC_RPL_LISTSTART – LIBIRC_RFC_RPL_LIST – LIBIRC_RFC_RPL_LISTEND sequence. Note that “private” channels are listed (without their topics) as channel “Prv” unless the client generating the LIST query is actually on that channel. Likewise, secret channels are not listed at all unless the client is a member of the channel in question.
Prototype:
int irc_cmd_list( irc_session_t * session,
const char * channel )
Parameters:
| session | The IRC session which is initiated and connected |
| channel | A channel name(s) to obtain user list. It is possible to specify several channels separated by a comma. |
Return value:
Return code 0 means the command was sent to the IRC server successfully. This does not mean the operation succeed, and you need to wait for the appropriate event or for the error code (event_numeric).
irc_cmd_topic
The irc_cmd_topic() is used to change or view the topic of a channel. The topic for channel is returned if topic is NULL. If the topic is not NULL, the topic for the channel will be changed. Note that, depending on +t channel mode, you may be required to be a channel operator to change the channel topic.
If the command succeed, the IRC server will generate a RPL_NOTOPIC or RPL_TOPIC message, containing either old or changed topic. Also the IRC server can (but not have to) generate the non-RFC RPL_TOPIC_EXTRA message, containing the nick of person, who’s changed the topic, and the time of latest topic change.
Prototype:
int irc_cmd_topic ( irc_session_t * session,
const char * channel,
const char * topic )
Parameters:
| session | The IRC session which is initiated and connected |
| channel | The channel name |
| topic | A new topic to change. If NULL, the old topic will be returned, and topic won’t changed. |
Return value:
Return code 0 means the command was sent to the IRC server successfully. This does not mean the operation succeed, and you need to wait for the appropriate event (in this case event_topic) or for the error code (event_numeric).
irc_cmd_channel_mode
The irc_cmd_channel_mode() is used to change or view the channel modes. The channel mode is returned if the mode is NULL. If the mode is not NULL, the mode for the channel will be changed. Note that, only channel operators can change the channel modes.
Channel mode is represended by the letters combination. Every letter has its own meaning in channel modes. Most channel mode letters are boolean (i.e. could only be set or reset), but a few channel mode letters accept a parameter. All channel options are set by adding a plus sign before the letter, and reset by adding a minus sign before the letter.
Here is the list of more or less standard channel modes:
- o nickname – gives (+o nick) or takes (-o nick) the channel operator privileges from a nickname. This mode affects the users in channel, not the channel itself. Examples: “+o tim”, “-o watson”.
- p – sets (+p) or resets (-p) private channel flag. Private channels are shown in channel list as ‘Prv’, without the topic.
- s – sets (+p) or resets (-p) secret channel flag. Secret channels aren’t shown in channel list at all.
- i – sets (+i) or resets (-i) invite-only channel flag. When the flag is set, only the people who are invited by irc_cmd_invite(), can join this channel.
- t – sets (+t) or resets (-t) topic settable by channel operator only flag. When the flag is set, only the channel operators can change the channel topic.
- n – sets (+n) or resets (-n) the protection from the clients outside the channel. When the +n mode is set, only the clients, who are in channel, can send the messages to the channel.
- m – sets (+m) or resets (-m) the moderation of the channel. When the moderation mode is set, only channel operators and the users who have the +v user mode can speak in the channel.
- v nickname – gives (+v nick) or takes (-v nick) from user the ability to speak on a moderated channel. Examples: “+v tim”, “-v watson”.
- l number – sets (+l 20) or removes (-l) the restriction of maximum users in channel. When the restriction is set, and there is a number of users in the channel, no one can join the channel anymore.
- k key – sets (+k secret) or removes (-k) the password from the channel. When the restriction is set, any user joining the channel required to provide a channel key.
- b mask – sets (+b *!*@*.mil) or removes (-b *!*@*.mil) the ban mask on a user to keep him out of channel. Note that to remove the ban you must specify the ban mask to remove, not just “-b”.
Note that the actual list of channel modes depends on the IRC server, and there can be more. If you find out any particular channel mode I missed, please let me know.
Prototype:
int irc_cmd_channel_mode ( irc_session_t * session,
const char * channel,
const char * mode )
Parameters:
| session | The IRC session which is initiated and connected |
| channel | A channel name to invite to |
| mode | A channel mode, described below. If NULL, the channel mode is not changed, just the old mode is returned |
Return value:
Return code 0 means the command was sent to the IRC server successfully. This does not mean the operation succeed, and you need to wait for the appropriate event (in this case event_mode) or for the error code (event_numeric).
irc_cmd_kick
This function is used to kick a person out of channel. Note that you must be a channel operator for this to happen.
Prototype:
int irc_cmd_kick( irc_session_t * session,
const char * nick,
const char * channel,
const char * reason )
Parameters:
| session | The IRC session which is initiated and connected |
| nick | The nick of the person to kick |
| channel | The channel to kick the person from |
| reason | The reason explaining why the person is kicked. May be NULL |
Return value:
Return code 0 means the command was sent to the IRC server successfully. This does not mean the operation succeed, and you need to wait for the appropriate event (in this case event_kick) or for the error code (event_numeric).