-
Notifications
You must be signed in to change notification settings - Fork 2
IRC Protocol
Content Table
The Internet Relay Chat (IRC) protocol is a set of rules and conventions that define how clients and servers communicate with each other over the internet. The protocol is based on a simple text-based format, using plaintext messages sent over TCP/IP connections.
The IRC protocol defines a set of commands and replies that clients and servers can use to perform various actions, such as joining and leaving channels, sending messages, and managing users and channels.
The core commands in the IRC protocol include:
- JOIN: used to join a channel
- PART: used to leave a channel
- PRIVMSG: used to send messages to a user or a channel
- NICK: used to change a user's nickname
- QUIT: used to disconnect from the server
- MODE: used to change the modes of a channel or a user
The IRC protocol also defines a set of replies that servers can send to clients in response to various commands. These replies include:
- RPL_WELCOME: sent to a client when they connect to the server
- RPL_TOPIC: sent to a client when they join a channel, indicating the current topic of the channel
- RPL_NAMREPLY: sent to a client when they join a channel, indicating the current list of users in the channel
It's worth noting that the IRC protocol is an open standard, and different implementations may have variations in their implementation and handling of the protocol.
The JOIN command is used to request to join a specific channel on the IRC server. The channel may be specified by its name or by its channel key, if one is set. If the channel does not exist, the server will create it.
Syntax
JOIN <channel> [<key>]
channel
: The name of the channel to join. This can be a combination of letters, digits, and special characters, but must not begin with a digit or special character.
key
: (Optional) The channel key or password, if one is set for the channel.
Examples
JOIN #example
This will join the channel named #example. If the channel does not exist, it will be created.
JOIN #example secretkey
This will join the channel #example, but only if the correct key or password (secretkey) is provided.
Some channels may be restricted and require an invitation or special privileges to join. The channel name must be prefixed with a # symbol. If the channel key is not provided when joining a password-protected channel, the server will return an error.
The USER command is used to set the user information for the client connecting to the IRC server. This includes the user's username, hostname, and real name.
Syntax
USER <username> <hostname> <servername> <realname>
username
: The user's username.
hostname
: The user's hostname or the name of the client's host machine.
servername
: The name of the server the user is connected to.
realname
: The user's real name or "gecos".
USER jane example.com irc.example.com Jane Doe
This sets the user's username to jane
, hostname to example.com
, servername to irc.example.com
, and real name to Jane Doe
.
The USER command must be sent before the NICK command in order to properly register with the server. The servername and hostname fields are not used by all servers and may be ignored. The real name field is typically used to display the user's full name or other personal information.
The NICK command is used to set or change the client's nickname on the IRC server. The nickname is a unique identifier that is used to represent the client in channels and for private messaging.
Syntax
NICK <nickname>
nickname
: The new nickname for the client. This can be a combination of letters, digits, and special characters, but must not begin with a digit or special character.
Examples
NICK jane
This sets the client's nickname to jane
.
NICK jane_doe
This changes the client's nickname to jane_doe
.
The NICK command must be sent after the USER command in order to properly register with the server. If the desired nickname is already in use by another client, the server will return an error and the client must choose a different nickname. Some servers may have restrictions on the length or format of nicknames.
The KICK command is used by operators to forcibly remove a user from a channel. This can be used as a means of punishment or to remove disruptive users from a channel.
Syntax
KICK <channel> <user> [<reason>]
channel
: The name of the channel from which the user will be removed.
user
: The nickname of the user to be removed.
reason
: (Optional) A message explaining the reason for the kick.
KICK #example jane
This kicks the user jane
from the channel #example
.
KICK #example jane spamming
This kicks the user jane
from the channel #example
for the reason "spamming".
Only operators or users with special privileges can use the KICK command. If the specified channel or user does not exist, the server will return an error. The KICK command may not be allowed on all channels, depending on the channel's mode or settings.
The WHOIS command is used to request information about a specific user on the IRC server. This includes the user's nickname, username, hostname, and any channels they are currently in.
Syntax
WHOIS <user>
user
: The nickname of the user to request information about.
WHOIS jane
This requests information about the user jane
.
The server will return a response with the requested information about the user. If the specified user does not exist, the server will return an error. Some servers may also return additional information about the user, such as their real name or server of origin.
The CAP command is used to request or acknowledge capabilities supported by the server or client. Capabilities are additional features or extensions to the IRC protocol that may be supported by the server or client.
Syntax
CAP <subcommand> [<capability>] [<parameters>]
subcommand
: The subcommand for the CAP command. This can be one of LS, REQ, ACK, NAK, or CLEAR.
capability
: (Optional) The name of the capability to request or acknowledge.
parameters
: (Optional) Additional parameters or options for the capability.
CAP LS
This requests a list of capabilities supported by the server.
CAP REQ :multi-prefix
This requests the multi-prefix
capability from the server.
CAP ACK :multi-prefix
This acknowledges that the client supports the multi-prefix
capability.
The CAP command is used to negotiate and exchange capabilities between the client and server.
Not all servers or clients may support the same set of capabilities.
The LS
, REQ
, and ACK
subcommands can be used by the client to request or acknowledge capabilities. The NAK and CLEAR
subcommands can be used by the server to reject or reset capability negotiations.
The MODE command is used to set or request the mode of a channel or user on the IRC server. Modes can be used to change the behavior or settings of a channel or user, such as setting channel privileges or banning users.
Syntax
MODE <target> <mode> [<parameters>]
target
: The name of the channel or user to set the mode for.
mode
: The mode to set or request. This can be a combination of mode characters and parameters, such as +o
or +b
nick!user@host
.
parameters
: (Optional) Additional parameters or options for the mode.
MODE #example +o jane
This sets operator mode for the user jane in the channel #example.
MODE #example +b nick!user@host
This sets a ban for the user nick!user@host
in the channel #example
.
MODE jane +i
This sets invisible mode for the user jane
.
Only operators or users with special privileges can set modes on a channel. The available modes and their parameters may vary depending on the server or client. The MODE command can also be used to request the current mode of a channel or user.