Wollabot Manual
Wollabot Manual
Wollabot Manual
Christian Joergensen
Wollabot Manual
by Christian Joergensen
A throughful introduction on how to use Wollabot covering from installation and configuration to writing your own
modules
Table of Contents
Credits .............................................................................................................................................................................i
1. Installation .................................................................................................................................................................1
1.1. Requirements..................................................................................................................................................1
1.2. Download and unpacking...............................................................................................................................1
2. Configuration ............................................................................................................................................................2
2.1. The config file.................................................................................................................................................2
2.1.1. ’main’ configuration category............................................................................................................2
2.1.2. ’modules’ configuration category ......................................................................................................3
2.1.3. ’channel’ configuration category .......................................................................................................3
2.2. Other configuration options (advanced users and developers).......................................................................3
3. Modules......................................................................................................................................................................4
3.1. Short introduction on how modules are structured ........................................................................................4
3.2. API introduction.............................................................................................................................................4
3.3. API reference..................................................................................................................................................5
bind_prefix...................................................................................................................................................5
bind_query ...................................................................................................................................................6
bind_all ........................................................................................................................................................7
bind_notice ..................................................................................................................................................8
bind_chan.....................................................................................................................................................8
bind_onconnect............................................................................................................................................9
bind_type ...................................................................................................................................................10
bind_timer..................................................................................................................................................12
send_raw ....................................................................................................................................................13
send_privmsg .............................................................................................................................................13
send_ctcp ...................................................................................................................................................14
send_action ................................................................................................................................................14
send_notice ................................................................................................................................................15
is_op...........................................................................................................................................................16
is_voice ......................................................................................................................................................17
is_on_channel ............................................................................................................................................17
mode ..........................................................................................................................................................18
kick ............................................................................................................................................................19
change_nick ...............................................................................................................................................19
topic ...........................................................................................................................................................20
join .............................................................................................................................................................20
invite ..........................................................................................................................................................21
A. RFC 1459: Internet Relay Chat Protocol.............................................................................................................23
B. Client-To-Client Protocol.......................................................................................................................................82
iii
List of Tables
3-1. Wollabot message types.........................................................................................................................................10
List of Examples
3-1. A greet function .......................................................................................................................................................5
3-1. A kick function ........................................................................................................................................................6
3-1. Log module for raw IRC input logging ...................................................................................................................7
3-1. On join message.......................................................................................................................................................8
3-1. Repeat module for a single channel.........................................................................................................................9
3-1. Authenticating with Q ...........................................................................................................................................10
3-1. Binding to QUIT and PART messages using bind_type .......................................................................................11
3-2. Binding to everything except nickchanges and KICK messages using bind_type................................................11
3-1. Printing the time every five minutes ......................................................................................................................12
3-1. Sending a raw message..........................................................................................................................................13
3-1. Send a message using the send_privmsg method ..................................................................................................14
3-1. Find out IRC client version from user ’foobar’ .....................................................................................................14
3-1. Getting the bot to indicate it’s strong feelings using send_action .........................................................................15
3-1. Making an on-join message using bind_type and send_notice .............................................................................16
3-1. Ask for ops if the bot doesn’t have ........................................................................................................................17
3-1. Ask for voice if the bot doesn’t have .....................................................................................................................17
3-1. Making the bot join a channel if not on it..............................................................................................................18
3-1. Op a user................................................................................................................................................................18
3-1. Kick stupiduser from a channel .............................................................................................................................19
3-1. Changing the bots nick ..........................................................................................................................................20
3-1. Setting the topic .....................................................................................................................................................20
3-1. Joining a channel ...................................................................................................................................................21
3-1. Inviting a user to a channel....................................................................................................................................21
iv
Credits
Over the time, some people has contributed Wollabot. Here I’ll try to list them:
• Thomas Johansson
• Dan Kuykendall
i
Chapter 1. Installation
In this chapter you will learn how to download and install your Wollabot correctly.
1.1. Requirements
To run a Wollabot nothing more than a CGI installation of PHP4 newer than 4.2.0 is needed. Refer to the PHP
Manual (http://www.php.net/manual/en/install.commandline.php) for information on how to make a CGI installation
of PHP.
Note: Wollabot is NOT supposed to run through Apache or any other webserver. Wollabot is a standalone
application written in PHP using the commandline interpreter.
1
Chapter 2. Configuration
This chapter covers how to configure your Wollabot.
[main]
; IRC preferences
server = "irc.quakenet.org"
port = "6667"
nickname = "wollabot"
username = "w0114"
[modules]
; Base module - DO NOT remove those unless you know what you’re doing
loadmodule = "Wollabot_Base.php"
[channel]
name = "#wollabot"
on_join = "PRIVMSG #wollabot :Hello, I’m a Wollabot\PRIVMSG #wollabot :Visit my website at http://wol
key = ""
[channel]
name = "#quux"
on_join = ""
key = "foobar"
The main philosophy behind the configuration file is for it to be mostly self-explanatory. However we will provide
you with an overview here. It consists of configuration categories defined using square brackets ([category]).
Each configuration category has it’s own different configuration properties. These i will go through here:
2
Chapter 2. Configuration
3
Chapter 3. Modules
In this chapter you will learn how to write your own modules.
function MyModule () {
// Constructor for your module
}
$wollabot->register_module("MyModule");
This is pretty much the most simple module you can make. It does completely nothing. In order to add some
functionality, we need to use a bind-method. We have quite a few bind-methods, but in our example we will use
bind_prefix() for the sake of simplicity. The methods bind_prefix() binds a user-defined method in the current class
to a given prefix in a IRC message (either channel, query or notice). It takes two arguments: method and prefix. Let
us start out by making a greet function, that greet everyone who writes ’hello’ in your channel.
function MyModule () {
$this->bind_prefix(’say_hello’, ’hello’);
}
4
Chapter 3. Modules
$wollabot->register_module("MyModule");
Here we see how the method say_hello() take exactly one argument, being an array of data from the IRC message
that triggered it. The data array consists of the following elements:
$data[’from’] => The user who sent the message (in the form of nick!user@host
$data[’nick’] => The nickname of the user who sent the message
$data[’ident’] => The ident of the user who sent the message (username)
$data[’host’] => The host of the user who sent the message
$data[’channel’] => The channel in which the message was written (if given)
$data[’message’] => The actual message
$data[’message_exploded’] => The actual mesasge exploded by space
$data[’type’] => The message type - refer to WOLLABOT_TYPE_* constants
$data[’raw’] => The raw message directly from socket
$data[’raw_exploded’] => The raw message directly from socket exploded by space
bind_prefix
Name
bind_prefix — Binds a prefix on a IRC message to a given method
Synopsis
void bind_prefix(string method, string prefix);
Description
When someone writes a message in a channel, notice or query, begginning with prefix, method is called.
5
Chapter 3. Modules
function MyModule () {
$this->bind_prefix(’say_hello’, ’hello’);
}
$wollabot->register_module("MyModule");
bind_query
Name
bind_query — Binds a query (private) IRC message to a given method
Synopsis
void bind_query(string method);
Description
When someone writes a private message to the bot in query, method is called. This is great for private commands
such as authentication and things not meant for the public to see.
function MyModule () {
$this->bind_query(’do_kick’);
}
6
Chapter 3. Modules
$wollabot->register_module("MyModule");
bind_all
Name
bind_all — Binds all input to a given method
Synopsis
void bind_all(string method);
Description
When any input on the IRC connection is recieved a method bound here will be called. This includes MOTD’s,
bans and so on.
var $fp;
function MyModule () {
$this->bind_all(’do_logging’);
$fp = fopen("/home/bot/logfile.txt", "a");
}
7
Chapter 3. Modules
$wollabot->register_module("MyModule");
bind_notice
Name
bind_notice — Binds a notice IRC message to a given method
Synopsis
void bind_notice(string method);
Description
When a notice is recieved (from channel or private) method is called. This works exactly
WRITE ME!
bind_chan
Name
bind_chan — Binds an IRC message on a given channel to a given method
Synopsis
void bind_chan(string method, string channel);
8
Chapter 3. Modules
Description
This method binds IRC messages on a given channel or all channels setting channel to all. If you want to bind
your method to multiple channels simply run bind_chan multiple times as well.
var $last_message;
function MyModule () {
$this->bind_chan(’check_repeat’, ’#wollabot’);
}
$this->last_message = $data[’message’];
$wollabot->register_module("MyModule");
bind_onconnect
Name
bind_onconnect — When connected successful a bound method is called
Synopsis
void bind_onconnect(string method);
9
Chapter 3. Modules
Description
When successfully connected to the server (after the numeric reply ’376’ - "end of MOTD") method is called. This
is great for authentication with other bots or network services. Following is an example for QuakeNet’s Q service-bot.
function MyModule () {
$this->bind_onconnect(’q_auth’);
}
$wollabot->register_module("MyModule");
bind_type
Name
bind_type — Binds a message type from a defined list of types to a method
Synopsis
void bind_type(string method, int type);
Description
This is a very powerful way of binding to an IRC message of a given type. The type is made up using bitwise
operators to create your kind of type-specification from a list of types.
10
Chapter 3. Modules
In order to make your own type specification you use the bitwise operators. If you want all QUIT and PART
messages your could do the following.
If you instead would like all messages except nickchanges and KICK messages you would use something like:
11
Chapter 3. Modules
Example 3-2. Binding to everything except nickchanges and KICK messages using bind_type
bind_timer
Name
bind_timer — Make a method be called with a given frequency
Synopsis
void bind_timer(string method, double frequency);
Description
Wollabot 0.3.0 introduces the concept of timers which enables you to run a user-defined method at a given
frequency specified in ms.
Note: Bear in mind that this bind method does not supply you with a $data parameter for obvious reasons.
function MyModule () {
$this->bind_timer(’print_time’, 300000);
}
function print_time () {
$this->privmsg("#wollabot", "Time is now:".date("d/m/Y H:i:s"));
}
$wollabot->register_module("MyModule");
12
Chapter 3. Modules
send_raw
Name
send_raw — Semds a raw message to the IRC server
Synopsis
void send_raw(string out);
Description
This will send out directly to the IRC server. Look into RFC 1459 (Appendix A) for guidance on what to send.
send_privmsg
Name
send_privmsg — Sends a message to a channel or user (in query)
Synopsis
void send_privmsg(string target, string message);
13
Chapter 3. Modules
Description
This is pretty much the most important method of them all - the one for sending messages (message)to channels
and users. Supply target with your given target - that is, the user or the channel. Remember to prefix channels
with ’#’.
send_ctcp
Name
send_ctcp — Sends a CTCP request to a channel or user
Synopsis
void send_ctcp(string target, string message);
Description
CTCP is an acronym for Client-To-Client Protocol (Appendix B) and may be used for gathering information about a
given client. Please refer to the above link for information on what queries can be made.
Example 3-1. Find out IRC client version from user ’foobar’
$this->send_ctcp("foobar", "VERSION");
Note: You need to setup a listener for the reply using the bind_type method.
14
Chapter 3. Modules
send_action
Name
send_action — Sends an action to a channel or user
Synopsis
void send_action(string target, string message);
Description
Actions is an IRC way of telling what you are doing. An action could be like (depending on the users client):
In order to send such one you need to supply a channel or user to send it to in the target parameter. Further more
you must include the actual action in the message parameter.
Example 3-1. Getting the bot to indicate it’s strong feelings using send_action
send_notice
Name
send_notice — Sends a notice to a channel or user
Synopsis
void send_notice(string target, string message);
15
Chapter 3. Modules
Description
Notices is a great way to get the users attention for warnings or ie. on join messages. The send_notice needs two
parameters. One for the channel or user to send the notice to, that is target. The other one is the message to send,
that is message.
function MyModule () {
$this->bind_type(’onjoin_message’, WOLLABOT_TYPE_JOIN);
}
$wollabot->register_module("MyModule");
is_op
Name
is_op — Check if a user is op on a given channel
Synopsis
bool is_op(string channel [, string user ]);
16
Chapter 3. Modules
Description
is_op provides a way of checking if a given user is op on a given channel. If no user is specified the bot itself
is used.
is_voice
Name
is_voice — Check if a user is voice on a given channel
Synopsis
bool is_voice(string channel [, string target ]);
Description
is_voice provides a way of checking if a given user has voice on a given channel. If no user is specified the
bot itself is used.
17
Chapter 3. Modules
is_on_channel
Name
is_on_channel — Checks if a user is on a given channel
Synopsis
bool is_on_channel(string channel [, string nickname ]);
Description
is_on_channel provides a way of checking if a given user has is on a given channel. If no user is specified
the bot itself is used.
if (!$this->is_on_channel("#wollabot")) $this->join("#wollabot");
mode
Name
mode — Changes user/channel-mode
Synopsis
void mode(string target, string mode);
Description
Modes are used to define settings for channels and users. See RFC 1459 section 4.2.3 for the available modes
(Appendix A).
18
Chapter 3. Modules
kick
Name
kick — Kicks a user (or multiple) from a given channel
Synopsis
void kick(mixed targets, string channel, [ string reason ]);
Description
Depending on whether targets is an array or a string, multiple or single users can be kicked from a given
channel with a reason (but not needed - if not specified a default reason saying ’Sod off’ will be issued).
change_nick
Name
change_nick — Changes the nick of the bot
19
Chapter 3. Modules
Synopsis
void change_nick(string nick);
Description
$this->nick("foobot");
topic
Name
topic — Sets the topic for a given channel
Synopsis
void topic(string channel, string topic);
Description
On IRC the topic is used to display static information to the users. It can be set using topic which uses to
parameters. channel is the channel in prospect and topic is the new topic to be set.
20
Chapter 3. Modules
join
Name
join — Make the bot join a channel
Synopsis
void join(string channel, [ string key ]);
Description
This function makes the bot join a given channel. If the channel is guarded by key it can be supplied using the
second parameter.
$this->join("#wollabot");
invite
Name
invite — Invite a user to a given channel
Synopsis
void invite(string channel, string nickname);
Description
If a channel has set channelmode +i - you will need an invitation to join. such one can be issued by the bot using this
function. Just tell it which channel to invite to and which nickname to invite.
21
Chapter 3. Modules
$this->invite("#wollabot", "razor");
22
Appendix A. RFC 1459: Internet Relay Chat
Protocol
Abstract
The IRC protocol was developed over the last 4 years since it was
first implemented as a means for users on a BBS to chat amongst
themselves. Now it supports a world-wide network of servers and
clients, and is stringing to cope with growth. Over the past 2 years,
the average number of users connected to the main IRC network has
grown by a factor of 10.
Table of Contents
1. INTRODUCTION ............................................... 4
1.1 Servers ................................................ 4
1.2 Clients ................................................ 5
1.2.1 Operators .......................................... 5
1.3 Channels ................................................ 5
1.3.1 Channel Operators .................................... 6
2. THE IRC SPECIFICATION ....................................... 7
2.1 Overview ................................................ 7
2.2 Character codes ......................................... 7
2.3 Messages ................................................ 7
2.3.1 Message format in ’pseudo’ BNF .................... 8
2.4 Numeric replies ......................................... 10
3. IRC Concepts ................................................ 10
3.1 One-to-one communication ................................ 10
3.2 One-to-many ............................................. 11
3.2.1 To a list .......................................... 11
3.2.2 To a group (channel) ............................... 11
3.2.3 To a host/server mask .............................. 12
23
Appendix A. RFC 1459: Internet Relay Chat Protocol
24
Appendix A. RFC 1459: Internet Relay Chat Protocol
1. INTRODUCTION
The IRC (Internet Relay Chat) protocol has been designed over a
number of years for use with text based conferencing. This document
describes the current IRC protocol.
The IRC protocol has been developed on systems using the TCP/IP
network protocol, although there is no requirement that this remain
the only sphere in which it operates.
25
Appendix A. RFC 1459: Internet Relay Chat Protocol
1.1 Servers
:
[ etc. ]
:
1.2 Clients
1.2.1 Operators
26
Appendix A. RFC 1459: Internet Relay Chat Protocol
1.3 Channels
27
Appendix A. RFC 1459: Internet Relay Chat Protocol
possibly ceasing to exist on one side of the split. When the split
is healed, the connecting servers announce to each other who they
think is in each channel and the mode of that channel. If the
channel exists on both sides, the JOINs and MODEs are interpreted in
an inclusive manner so that both sides of the new connection will
agree about which clients are in the channel and what modes the
channel has.
2.1 Overview
28
Appendix A. RFC 1459: Internet Relay Chat Protocol
2.3 Messages
Servers and clients send eachother messages which may or may not
generate a reply. If the message contains a valid command, as
described in later sections, the client should expect a reply as
specified but it is not advised to wait forever for the reply; client
to server and server to server communication is essentially
asynchronous in nature.
Each IRC message may consist of up to three main parts: the prefix
(optional), the command, and the command parameters (of which there
may be up to 15). The prefix, command, and all parameters are
separated by one (or more) ASCII space character(s) (0x20).
The command must either be a valid IRC command or a three (3) digit
number represented in ASCII text.
29
Appendix A. RFC 1459: Internet Relay Chat Protocol
<crlf> ::= CR LF
NOTES:
30
Appendix A. RFC 1459: Internet Relay Chat Protocol
<nonwhite> ::= <any 8bit code except SPACE (0x20), NUL (0x0), CR
(0xd), and LF (0xa)>
3. IRC Concepts.
1--\
A D---4
2--/ \ /
B----C
/ \
3 E
Servers: A, B, C, D, E Clients: 1, 2, 3, 4
31
Appendix A. RFC 1459: Internet Relay Chat Protocol
Example 1:
A message between clients 1 and 2 is only seen by server A, which
sends it straight to client 2.
Example 2:
A message between clients 1 and 3 is seen by servers A & B, and
client 3. No other clients or servers are allowed see the message.
Example 3:
A message between clients 2 and 4 is seen by servers A, B, C & D
and client 4 only.
3.2 One-to-many
The main goal of IRC is to provide a forum which allows easy and
efficient conferencing (one to many conversations). IRC offers
several means to achieve this, each serving its own purpose.
3.2.1 To a list
Example 4:
Any channel with 1 client in it. Messages to the channel go to the
server and then nowhere else.
32
Appendix A. RFC 1459: Internet Relay Chat Protocol
Example 5:
2 clients in a channel. All messages traverse a path as if they
were private messages between the two clients outside a channel.
Example 6:
Clients 1, 2 and 3 in a channel. All messages to the channel are
sent to all clients and only those servers which must be traversed
by the message if it were a private message to a single client. If
client 1 sends a message, it goes back to client 2 and then via
server B to client 3.
3.3 One-to-all
3.3.1 Client-to-Client
3.3.2 Client-to-Server
3.3.3 Server-to-Server.
4. Message details
33
Appendix A. RFC 1459: Internet Relay Chat Protocol
In the examples below, some messages appear using the full format:
1. Pass message
2. Nick message
3. User message
Command: PASS
Parameters: <password>
34
Appendix A. RFC 1459: Internet Relay Chat Protocol
ERR_NEEDMOREPARAMS ERR_ALREADYREGISTRED
Example:
PASS secretpasswordhere
Command: NICK
Parameters: <nickname> [ <hopcount> ]
Numeric Replies:
ERR_NONICKNAMEGIVEN ERR_ERRONEUSNICKNAME
ERR_NICKNAMEINUSE ERR_NICKCOLLISION
Example:
Command: USER
35
Appendix A. RFC 1459: Internet Relay Chat Protocol
Numeric Replies:
ERR_NEEDMOREPARAMS ERR_ALREADYREGISTRED
Examples:
Command: SERVER
Parameters: <servername> <hopcount> <info>
The server message is used to tell a server that the other end of a
new connection is a server. This message is also used to pass server
data over whole net. When a new server is connected to net,
information about it be broadcast to the whole network. <hopcount>
is used to give all servers some internal information on how far away
36
Appendix A. RFC 1459: Internet Relay Chat Protocol
The SERVER message must only be accepted from either (a) a connection
which is yet to be registered and is attempting to register as a
server, or (b) an existing connection to another server, in which
case the SERVER message is introducing a new server behind that
server.
Most errors that occur with the receipt of a SERVER command result in
the connection being terminated by the destination host (target
SERVER). Error replies are usually sent using the "ERROR" command
rather than the numeric since the ERROR command has several useful
properties which make it useful here.
Numeric Replies:
ERR_ALREADYREGISTRED
Example:
4.1.5 Oper
Command: OPER
Parameters: <user> <password>
If the client sending the OPER command supplies the correct password
for the given user, the server then informs the rest of the network
of the new operator by issuing a "MODE +o" for the clients nickname.
37
Appendix A. RFC 1459: Internet Relay Chat Protocol
Numeric Replies:
ERR_NEEDMOREPARAMS RPL_YOUREOPER
ERR_NOOPERHOST ERR_PASSWDMISMATCH
Example:
4.1.6 Quit
Command: QUIT
Parameters: [<Quit message>]
A client session is ended with a quit message. The server must close
the connection to a client which sends a QUIT message. If a "Quit
Message" is given, this will be sent instead of the default message,
the nickname.
If, for some other reason, a client connection is closed without the
client issuing a QUIT command (e.g. client dies and EOF occurs
on socket), the server is required to fill in the quit message with
some sort of message reflecting the nature of the event which
caused it to happen.
Numeric Replies:
None.
Examples:
Command: SQUIT
Parameters: <server> <comment>
38
Appendix A. RFC 1459: Internet Relay Chat Protocol
Both of the servers which are on either side of the connection being
closed are required to to send out a SQUIT message (to all its other
server connections) for all other servers which are considered to be
behind that link.
Numeric replies:
ERR_NOPRIVILEGES ERR_NOSUCHSERVER
Example:
39
Appendix A. RFC 1459: Internet Relay Chat Protocol
Command: JOIN
Parameters: <channel>{,<channel>} [<key>{,<key>}]
These are discussed in more detail under the MODE command (see
section 4.2.3 for more details).
Once a user has joined a channel, they receive notice about all
commands their server receives which affect the channel. This
includes MODE, KICK, PART, QUIT and of course PRIVMSG/NOTICE. The
JOIN command needs to be broadcast to all servers so that each server
knows where to find the users who are on the channel. This allows
optimal delivery of PRIVMSG/NOTICE messages to the channel.
Numeric Replies:
ERR_NEEDMOREPARAMS ERR_BANNEDFROMCHAN
ERR_INVITEONLYCHAN ERR_BADCHANNELKEY
ERR_CHANNELISFULL ERR_BADCHANMASK
ERR_NOSUCHCHANNEL ERR_TOOMANYCHANNELS
RPL_TOPIC
Examples:
40
Appendix A. RFC 1459: Internet Relay Chat Protocol
Command: PART
Parameters: <channel>{,<channel>}
The PART message causes the client sending the message to be removed
from the list of active users for all given channels listed in the
parameter string.
Numeric Replies:
ERR_NEEDMOREPARAMS ERR_NOSUCHCHANNEL
ERR_NOTONCHANNEL
Examples:
Command: MODE
The MODE command is provided so that channel operators may change the
characteristics of ‘their’ channel. It is also required that servers
be able to change channel modes so that channel operators may be
created.
41
Appendix A. RFC 1459: Internet Relay Chat Protocol
When using the ’o’ and ’b’ options, a restriction on a total of three
per mode command has been imposed. That is, any combination of ’o’
and
The user MODEs are typically changes which affect either how the
client is seen by others or what ’extra’ messages the client is sent.
A user MODE command may only be accepted if both the sender of the
message and the nickname given as a parameter are both the same.
ERR_NEEDMOREPARAMS RPL_CHANNELMODEIS
ERR_CHANOPRIVSNEEDED ERR_NOSUCHNICK
ERR_NOTONCHANNEL ERR_KEYSET
RPL_BANLIST RPL_ENDOFBANLIST
ERR_UNKNOWNMODE ERR_NOSUCHCHANNEL
ERR_USERSDONTMATCH RPL_UMODEIS
ERR_UMODEUNKNOWNFLAG
Examples:
42
Appendix A. RFC 1459: Internet Relay Chat Protocol
channel #Finnish.
Command: TOPIC
Parameters: <channel> [<topic>]
Numeric Replies:
ERR_NEEDMOREPARAMS ERR_NOTONCHANNEL
RPL_NOTOPIC RPL_TOPIC
ERR_CHANOPRIVSNEEDED
Examples:
:Wiz TOPIC #test :New topic ;User Wiz setting the topic.
43
Appendix A. RFC 1459: Internet Relay Chat Protocol
Command: NAMES
Parameters: [<channel>{,<channel>}]
By using the NAMES command, a user can list all nicknames that are
visible to them on any channel that they can see. Channel names
which they can see are those which aren’t private (+p) or secret (+s)
or those which they are actually on. The <channel> parameter
specifies which channel(s) to return information about if valid.
There is no error reply for bad channel names.
Numerics:
RPL_NAMREPLY RPL_ENDOFNAMES
Examples:
Command: LIST
Parameters: [<channel>{,<channel>} [<server>]]
The list message is used to list channels and their topics. If the
<channel> parameter is used, only the status of that channel
is displayed. Private channels are listed (without their
topics) as channel "Prv" unless the client generating the query is
actually on that channel. Likewise, secret channels are not listed
Numeric Replies:
ERR_NOSUCHSERVER RPL_LISTSTART
RPL_LIST RPL_LISTEND
Examples:
44
Appendix A. RFC 1459: Internet Relay Chat Protocol
Command: INVITE
Parameters: <nickname> <channel>
Numeric Replies:
ERR_NEEDMOREPARAMS ERR_NOSUCHNICK
ERR_NOTONCHANNEL ERR_USERONCHANNEL
ERR_CHANOPRIVSNEEDED
RPL_INVITING RPL_AWAY
Examples:
Command: KICK
Parameters: <channel> <user> [<comment>]
Numeric Replies:
ERR_NEEDMOREPARAMS ERR_NOSUCHCHANNEL
ERR_BADCHANMASK ERR_CHANOPRIVSNEEDED
ERR_NOTONCHANNEL
Examples:
45
Appendix A. RFC 1459: Internet Relay Chat Protocol
:WiZ KICK #Finnish John ; KICK message from WiZ to remove John
from channel #Finnish
NOTE:
It is possible to extend the KICK command parameters to the
following:
Command: VERSION
Parameters: [<server>]
Numeric Replies:
ERR_NOSUCHSERVER RPL_VERSION
Examples:
46
Appendix A. RFC 1459: Internet Relay Chat Protocol
Command: STATS
Parameters: [<query> [<server>]]
Numeric Replies:
ERR_NOSUCHSERVER
RPL_STATSCLINE RPL_STATSNLINE
RPL_STATSILINE RPL_STATSKLINE
RPL_STATSQLINE RPL_STATSLLINE
RPL_STATSLINKINFO RPL_STATSUPTIME
RPL_STATSCOMMANDS RPL_STATSOLINE
RPL_STATSHLINE RPL_ENDOFSTATS
Examples:
47
Appendix A. RFC 1459: Internet Relay Chat Protocol
Command: LINKS
Parameters: [[<remote server>] <server mask>]
With LINKS, a user can list all servers which are known by the server
answering the query. The returned list of servers must match the
mask, or if no mask is given, the full list is returned.
Numeric Replies:
ERR_NOSUCHSERVER
RPL_LINKS RPL_ENDOFLINKS
Examples:
:WiZ LINKS *.bu.edu *.edu ; LINKS message from WiZ to the first
server matching *.edu for a list of
servers matching *.bu.edu.
Command: TIME
Parameters: [<server>]
The time message is used to query local time from the specified
server. If the server parameter is not given, the server handling the
command must reply to the query.
Numeric Replies:
ERR_NOSUCHSERVER RPL_TIME
Examples:
48
Appendix A. RFC 1459: Internet Relay Chat Protocol
Command: CONNECT
Parameters: <target server> [<port> [<remote server>]]
Numeric Replies:
ERR_NOSUCHSERVER ERR_NOPRIVILEGES
ERR_NEEDMOREPARAMS
Examples:
Command: TRACE
Parameters: [<server>]
Numeric Replies:
ERR_NOSUCHSERVER
49
Appendix A. RFC 1459: Internet Relay Chat Protocol
RPL_TRACELINK
A TRACE reply may be composed of any number of the following numeric
replies.
RPL_TRACECONNECTING RPL_TRACEHANDSHAKE
RPL_TRACEUNKNOWN RPL_TRACEOPERATOR
RPL_TRACEUSER RPL_TRACESERVER
RPL_TRACESERVICE RPL_TRACENEWTYPE
RPL_TRACECLASS
Examples:
Command: ADMIN
Parameters: [<server>]
Numeric Replies:
ERR_NOSUCHSERVER
RPL_ADMINME RPL_ADMINLOC1
RPL_ADMINLOC2 RPL_ADMINEMAIL
Examples:
Command: INFO
Parameters: [<server>]
50
Appendix A. RFC 1459: Internet Relay Chat Protocol
Numeric Replies:
ERR_NOSUCHSERVER
RPL_INFO RPL_ENDOFINFO
Examples:
The main purpose of the IRC protocol is to provide a base for clients
to communicate with each other. PRIVMSG and NOTICE are the only
messages available which actually perform delivery of a text message
from one client to another - the rest just make it possible and try
to ensure it happens in a reliable and structured manner.
Command: PRIVMSG
Parameters: <receiver>{,<receiver>} <text to be sent>
Numeric Replies:
ERR_NORECIPIENT ERR_NOTEXTTOSEND
ERR_CANNOTSENDTOCHAN ERR_NOTOPLEVEL
ERR_WILDTOPLEVEL ERR_TOOMANYTARGETS
ERR_NOSUCHNICK
RPL_AWAY
Examples:
51
Appendix A. RFC 1459: Internet Relay Chat Protocol
4.4.2 Notice
Command: NOTICE
Parameters: <nickname> <text>
Command: WHO
Parameters: [<name> [<o>]]
52
Appendix A. RFC 1459: Internet Relay Chat Protocol
The <name> passed to WHO is matched against users’ host, server, real
name and nickname if the channel <name> cannot be found.
Numeric Replies:
ERR_NOSUCHSERVER
RPL_WHOREPLY RPL_ENDOFWHO
Examples:
Command: WHOIS
Parameters: [<server>] <nickmask>[,<nickmask>[,...]]
Numeric Replies:
ERR_NOSUCHSERVER ERR_NONICKNAMEGIVEN
RPL_WHOISUSER RPL_WHOISCHANNELS
RPL_WHOISCHANNELS RPL_WHOISSERVER
RPL_AWAY RPL_WHOISOPERATOR
RPL_WHOISIDLE ERR_NOSUCHNICK
53
Appendix A. RFC 1459: Internet Relay Chat Protocol
RPL_ENDOFWHOIS
Examples:
4.5.3 Whowas
Command: WHOWAS
Parameters: <nickname> [<count> [<server>]]
Numeric Replies:
ERR_NONICKNAMEGIVEN ERR_WASNOSUCHNICK
RPL_WHOWASUSER RPL_WHOISSERVER
RPL_ENDOFWHOWAS
Examples:
Messages in this category do not fit into any of the above categories
but are nonetheless still a part of and required by the protocol.
Command: KILL
Parameters: <nickname> <comment>
54
Appendix A. RFC 1459: Internet Relay Chat Protocol
The comment given must reflect the actual reason for the KILL. For
server-generated KILLs it usually is made up of details concerning
the origins of the two conflicting nicknames. For users it is left
up to them to provide an adequate reason to satisfy others who see
it. To prevent/discourage fake KILLs from being generated to hide
the identify of the KILLer, the comment also shows a ’kill-path’
which is updated by each server it passes through, each prepending
its name to the path.
Numeric Replies:
ERR_NOPRIVILEGES ERR_NEEDMOREPARAMS
ERR_NOSUCHNICK ERR_CANTKILLSERVER
NOTE:
It is recommended that only Operators be allowed to kill other users
with KILL message. In an ideal world not even operators would need
to do this and it would be left to servers to deal with.
Command: PING
Parameters: <server1> [<server2>]
55
Appendix A. RFC 1459: Internet Relay Chat Protocol
(server which sent the PING message out) as quickly as possible with
an appropriate PONG message to indicate it is still there and alive.
Servers should not respond to PING commands but rely on PINGs from
the other end of the connection to indicate the connection is alive.
If the <server2> parameter is specified, the PING message gets
forwarded there.
Numeric Replies:
ERR_NOORIGIN ERR_NOSUCHSERVER
Examples:
Command: PONG
Parameters: <daemon> [<daemon2>]
Numeric Replies:
ERR_NOORIGIN ERR_NOSUCHSERVER
Examples:
tolsun.oulu.fi
4.6.4 Error
Command: ERROR
Parameters: <error message>
An ERROR message is for use for reporting errors which occur with a
server-to-server link only. An ERROR message is sent to the server
at the other end (which sends it to all of its connected operators)
and to all operators currently connected. It is not to be passed
onto any other servers by a server if it is received from a server.
56
Appendix A. RFC 1459: Internet Relay Chat Protocol
Numerics:
None.
Examples:
ERROR :Server *.fi already exists; ERROR message to the other server
which caused this error.
5. OPTIONALS
5.1 Away
Command: AWAY
Parameters: [message]
With the AWAY message, clients can set an automatic reply string for
any PRIVMSG commands directed at them (not to a channel they are on).
The automatic reply is sent by the server to client sending the
PRIVMSG command. The only replying server is the one to which the
sending client is connected to.
The AWAY message is used either with one parameter (to set an AWAY
message) or with no parameters (to remove the AWAY message).
Numeric Replies:
RPL_UNAWAY RPL_NOWAWAY
Examples:
57
Appendix A. RFC 1459: Internet Relay Chat Protocol
Command: REHASH
Parameters: None
The rehash message can be used by the operator to force the server to
re-read and process its configuration file.
Numeric Replies:
RPL_REHASHING ERR_NOPRIVILEGES
Examples:
Command: RESTART
Parameters: None
Numeric Replies:
ERR_NOPRIVILEGES
Examples:
Command: SUMMON
Parameters: <user> [<server>]
The SUMMON command can be used to give users who are on a host
running an IRC server a message asking them to please join IRC. This
message is only sent if the target server (a) has SUMMON enabled, (b)
the user is logged in and (c) the server process can write to the
user’s tty (or similar).
58
Appendix A. RFC 1459: Internet Relay Chat Protocol
Numeric Replies:
ERR_NORECIPIENT ERR_FILEERROR
ERR_NOLOGIN ERR_NOSUCHSERVER
RPL_SUMMONING
Examples:
5.5 Users
Command: USERS
Parameters: [<server>]
The USERS command returns a list of users logged into the server in a
similar format to who(1), rusers(1) and finger(1). Some people
may disable this command on their server for security related
reasons. If disabled, the correct numeric must be returned to
indicate this.
Numeric Replies:
ERR_NOSUCHSERVER ERR_FILEERROR
RPL_USERSSTART RPL_USERS
RPL_NOUSERS RPL_ENDOFUSERS
ERR_USERSDISABLED
Disabled Reply:
ERR_USERSDISABLED
Examples:
Command: WALLOPS
Parameters: Text to be sent to all operators currently online
59
Appendix A. RFC 1459: Internet Relay Chat Protocol
Numeric Replies:
ERR_NEEDMOREPARAMS
Examples:
Command: USERHOST
Parameters: <nickname>{<space><nickname>}
Numeric Replies:
RPL_USERHOST ERR_NEEDMOREPARAMS
Examples:
Command: ISON
Parameters: <nickname>{<space><nickname>}
60
Appendix A. RFC 1459: Internet Relay Chat Protocol
characters.
Numeric Replies:
RPL_ISON ERR_NEEDMOREPARAMS
Examples:
6. REPLIES
401 ERR_NOSUCHNICK
"<nickname> :No such nick/channel"
402 ERR_NOSUCHSERVER
"<server name> :No such server"
403 ERR_NOSUCHCHANNEL
"<channel name> :No such channel"
404 ERR_CANNOTSENDTOCHAN
"<channel name> :Cannot send to channel"
405 ERR_TOOMANYCHANNELS
"<channel name> :You have joined too many \
channels"
- Sent to a user when they have joined the maximum
number of allowed channels and they try to join
61
Appendix A. RFC 1459: Internet Relay Chat Protocol
another channel.
406 ERR_WASNOSUCHNICK
"<nickname> :There was no such nickname"
407 ERR_TOOMANYTARGETS
"<target> :Duplicate recipients. No message \
delivered"
409 ERR_NOORIGIN
":No origin specified"
411 ERR_NORECIPIENT
":No recipient given (<command>)"
412 ERR_NOTEXTTOSEND
":No text to send"
413 ERR_NOTOPLEVEL
"<mask> :No toplevel domain specified"
414 ERR_WILDTOPLEVEL
"<mask> :Wildcard in toplevel domain"
421 ERR_UNKNOWNCOMMAND
"<command> :Unknown command"
422 ERR_NOMOTD
":MOTD File is missing"
423 ERR_NOADMININFO
"<server> :No administrative info available"
62
Appendix A. RFC 1459: Internet Relay Chat Protocol
424 ERR_FILEERROR
":File error doing <file op> on <file>"
431 ERR_NONICKNAMEGIVEN
":No nickname given"
432 ERR_ERRONEUSNICKNAME
"<nick> :Erroneus nickname"
433 ERR_NICKNAMEINUSE
"<nick> :Nickname is already in use"
436 ERR_NICKCOLLISION
"<nick> :Nickname collision KILL"
441 ERR_USERNOTINCHANNEL
"<nick> <channel> :They aren’t on that channel"
442 ERR_NOTONCHANNEL
"<channel> :You’re not on that channel"
443 ERR_USERONCHANNEL
"<user> <channel> :is already on channel"
63
Appendix A. RFC 1459: Internet Relay Chat Protocol
444 ERR_NOLOGIN
"<user> :User not logged in"
445 ERR_SUMMONDISABLED
":SUMMON has been disabled"
446 ERR_USERSDISABLED
":USERS has been disabled"
451 ERR_NOTREGISTERED
":You have not registered"
461 ERR_NEEDMOREPARAMS
"<command> :Not enough parameters"
462 ERR_ALREADYREGISTRED
":You may not reregister"
463 ERR_NOPERMFORHOST
":Your host isn’t among the privileged"
464 ERR_PASSWDMISMATCH
":Password incorrect"
64
Appendix A. RFC 1459: Internet Relay Chat Protocol
465 ERR_YOUREBANNEDCREEP
":You are banned from this server"
467 ERR_KEYSET
"<channel> :Channel key already set"
471 ERR_CHANNELISFULL
"<channel> :Cannot join channel (+l)"
472 ERR_UNKNOWNMODE
"<char> :is unknown mode char to me"
473 ERR_INVITEONLYCHAN
"<channel> :Cannot join channel (+i)"
474 ERR_BANNEDFROMCHAN
"<channel> :Cannot join channel (+b)"
475 ERR_BADCHANNELKEY
"<channel> :Cannot join channel (+k)"
481 ERR_NOPRIVILEGES
":Permission Denied- You’re not an IRC operator"
482 ERR_CHANOPRIVSNEEDED
"<channel> :You’re not channel operator"
483 ERR_CANTKILLSERVER
":You cant kill a server!"
491 ERR_NOOPERHOST
":No O-lines for your host"
65
Appendix A. RFC 1459: Internet Relay Chat Protocol
501 ERR_UMODEUNKNOWNFLAG
":Unknown MODE flag"
502 ERR_USERSDONTMATCH
":Cant change mode for other users"
300 RPL_NONE
Dummy reply number. Not used.
302 RPL_USERHOST
":[<reply>{<space><reply>}]"
303 RPL_ISON
":[<nick> {<space><nick>}]"
301 RPL_AWAY
"<nick> :<away message>"
305 RPL_UNAWAY
":You are no longer marked as being away"
306 RPL_NOWAWAY
":You have been marked as being away"
66
Appendix A. RFC 1459: Internet Relay Chat Protocol
311 RPL_WHOISUSER
"<nick> <user> <host> * :<real name>"
312 RPL_WHOISSERVER
"<nick> <server> :<server info>"
313 RPL_WHOISOPERATOR
"<nick> :is an IRC operator"
317 RPL_WHOISIDLE
"<nick> <integer> :seconds idle"
318 RPL_ENDOFWHOIS
"<nick> :End of /WHOIS list"
319 RPL_WHOISCHANNELS
"<nick> :{[@|+]<channel><space>}"
314 RPL_WHOWASUSER
"<nick> <user> <host> * :<real name>"
369 RPL_ENDOFWHOWAS
"<nick> :End of WHOWAS"
321 RPL_LISTSTART
"Channel :Users Name"
322 RPL_LIST
"<channel> <# visible> :<topic>"
323 RPL_LISTEND
":End of /LIST"
67
Appendix A. RFC 1459: Internet Relay Chat Protocol
324 RPL_CHANNELMODEIS
"<channel> <mode> <mode params>"
331 RPL_NOTOPIC
"<channel> :No topic is set"
332 RPL_TOPIC
"<channel> :<topic>"
341 RPL_INVITING
"<channel> <nick>"
342 RPL_SUMMONING
"<user> :Summoning user to IRC"
351 RPL_VERSION
"<version>.<debuglevel> <server> :<comments>"
352 RPL_WHOREPLY
"<channel> <user> <host> <server> <nick> \
<H|G>[*][@|+] :<hopcount> <real name>"
315 RPL_ENDOFWHO
"<name> :End of /WHO list"
68
Appendix A. RFC 1459: Internet Relay Chat Protocol
the item.
353 RPL_NAMREPLY
"<channel> :[[@|+]<nick> [[@|+]<nick> [...]]]"
366 RPL_ENDOFNAMES
"<channel> :End of /NAMES list"
364 RPL_LINKS
"<mask> <server> :<hopcount> <server info>"
365 RPL_ENDOFLINKS
"<mask> :End of /LINKS list"
367 RPL_BANLIST
"<channel> <banid>"
368 RPL_ENDOFBANLIST
371 RPL_INFO
":<string>"
374 RPL_ENDOFINFO
":End of /INFO list"
375 RPL_MOTDSTART
":- <server> Message of the day - "
372 RPL_MOTD
":- <text>"
69
Appendix A. RFC 1459: Internet Relay Chat Protocol
376 RPL_ENDOFMOTD
":End of /MOTD command"
381 RPL_YOUREOPER
":You are now an IRC operator"
382 RPL_REHASHING
"<config file> :Rehashing"
391 RPL_TIME
392 RPL_USERSSTART
":UserID Terminal Host"
393 RPL_USERS
":%-8s %-9s %-8s"
394 RPL_ENDOFUSERS
":End of users"
395 RPL_NOUSERS
":Nobody logged in"
200 RPL_TRACELINK
"Link <version & debug level> <destination> \
<next server>"
70
Appendix A. RFC 1459: Internet Relay Chat Protocol
201 RPL_TRACECONNECTING
"Try. <class> <server>"
202 RPL_TRACEHANDSHAKE
"H.S. <class> <server>"
203 RPL_TRACEUNKNOWN
"???? <class> [<client IP address in dot form>]"
204 RPL_TRACEOPERATOR
"Oper <class> <nick>"
205 RPL_TRACEUSER
"User <class> <nick>"
206 RPL_TRACESERVER
"Serv <class> <int>S <int>C <server> \
<nick!user|*!*>@<host|server>"
208 RPL_TRACENEWTYPE
"<newtype> 0 <client name>"
261 RPL_TRACELOG
"File <logfile> <debug level>"
211 RPL_STATSLINKINFO
"<linkname> <sendq> <sent messages> \
<sent bytes> <received messages> \
<received bytes> <time open>"
212 RPL_STATSCOMMANDS
"<command> <count>"
213 RPL_STATSCLINE
"C <host> * <name> <port> <class>"
214 RPL_STATSNLINE
"N <host> * <name> <port> <class>"
215 RPL_STATSILINE
"I <host> * <host> <port> <class>"
216 RPL_STATSKLINE
"K <host> * <username> <port> <class>"
71
Appendix A. RFC 1459: Internet Relay Chat Protocol
218 RPL_STATSYLINE
"Y <class> <ping frequency> <connect \
frequency> <max sendq>"
219 RPL_ENDOFSTATS
"<stats letter> :End of /STATS report"
241 RPL_STATSLLINE
"L <hostmask> * <servername> <maxdepth>"
242 RPL_STATSUPTIME
":Server Up %d days %d:%02d:%02d"
243 RPL_STATSOLINE
"O <hostmask> * <name>"
244 RPL_STATSHLINE
"H <hostmask> * <servername>"
221 RPL_UMODEIS
"<user mode string>"
251 RPL_LUSERCLIENT
":There are <integer> users and <integer> \
invisible on <integer> servers"
252 RPL_LUSEROP
"<integer> :operator(s) online"
253 RPL_LUSERUNKNOWN
"<integer> :unknown connection(s)"
254 RPL_LUSERCHANNELS
"<integer> :channels formed"
255 RPL_LUSERME
":I have <integer> clients and <integer> \
servers"
256 RPL_ADMINME
"<server> :Administrative info"
257 RPL_ADMINLOC1
":<admin info>"
258 RPL_ADMINLOC2
":<admin info>"
259 RPL_ADMINEMAIL
":<admin info>"
72
Appendix A. RFC 1459: Internet Relay Chat Protocol
These numerics are not described above since they fall into one of
the following categories:
1. no longer in use;
8. Current implementations
73
Appendix A. RFC 1459: Internet Relay Chat Protocol
The rest of this section deals with issues that are mostly of
importance to those who wish to implement a server but some parts
also apply directly to clients as well.
IRC has been implemented on top of TCP since TCP supplies a reliable
network protocol which is well suited to this scale of conferencing.
The use of multicast IP is an alternative, but it is not widely
available or supported at the present time.
74
Appendix A. RFC 1459: Internet Relay Chat Protocol
kernel are not enough for the outgoing queue. To alleviate this
problem, a "send queue" is used as a FIFO queue for data to be sent.
A typical "send queue" may grow to 200 Kbytes on a large IRC network
with a slow network connection when a new server connects.
When polling its connections, a server will first read and parse all
incoming data, queuing any data to be sent out. When all available
input is processed, the queued data is sent. This reduces the number
of write() system calls and helps TCP make bigger packets.
After dealing with this, the server must then send out the new user’s
nickname and other information as supplied by itself (USER command)
and as the server could discover (from DNS/authentication servers).
The server must send this information out with NICK first followed by
USER.
75
Appendix A. RFC 1459: Internet Relay Chat Protocol
NOTE: channel topics are *NOT* exchanged here because the TOPIC
command overwrites any old topic information, so at best, the two
sides of the connection would exchange topics.
76
Appendix A. RFC 1459: Internet Relay Chat Protocol
In the above cases, the server is required to first check for the
existence of the nickname, then check its history to see who that
nick currently belongs to (if anyone!). This reduces the chances of
race conditions but they can still occur with the server ending up
affecting the wrong client. When performing a change trace for an
above command it is recommended that a time range be given and
entries which are too old ignored.
* while the timer is less than ten seconds ahead of the current
time, parse any present messages and penalize the client by
2 seconds for each message;
which in essence means that the client may send 1 message every 2
Using the standard resolver libraries from Berkeley and others has
77
Appendix A. RFC 1459: Internet Relay Chat Protocol
meant large delays in some cases where replies have timed out. To
avoid this, a separate set of DNS routines were written which were
setup for non-blocking IO operations and then polled from within the
main server IO loop.
Although there are numerous ident libraries for use and inclusion
into other programs, these caused problems since they operated in a
synchronous manner and resulted in frequent delays. Again the
solution was to write a set of routines which would cooperate with
the rest of the server and work using non-blocking IO.
The above list is the minimum requirement for any server which wishes
to make a connection with another server. Other items which may be
of use are:
78
Appendix A. RFC 1459: Internet Relay Chat Protocol
A server should use some sort of ’access control list’ (either in the
configuration file or elsewhere) that is read at startup and used to
decide what hosts clients may use to connect to it.
8.12.2 Operators
8.12.4 Administrivia
The current server allows any registered local user to join upto 10
different channels. There is no limit imposed on non-local users so
that the server remains (reasonably) consistant with all others on a
channel membership basis
9. Current problems
9.1 Scalability
79
Appendix A. RFC 1459: Internet Relay Chat Protocol
sufficiently well when used in a large arena. The main problem comes
from the requirement that all servers know about all other servers
and users and that information regarding them be updated as soon as
it changes. It is also desirable to keep the number of servers low
so that the path length between any two points is kept minimal and
the spanning tree as strongly branched as possible.
9.2 Labels
The current IRC protocol has 3 types of labels: the nickname, the
channel name and the server name. Each of the three types has its
own domain and no duplicates are allowed inside that domain.
Currently, it is possible for users to pick the label for any of the
three, resulting in collisions. It is widely recognized that this
needs reworking, with a plan for unique names for channels and nicks
that don’t collide being desirable as well as a solution allowing a
cyclic tree.
9.2.1 Nicknames
The idea of the nickname on IRC is very convenient for users to use
when talking to each other outside of a channel, but there is only a
finite nickname space and being what they are, its not uncommon for
several people to want to use the same nick. If a nickname is chosen
by two people using this protocol, either one will not succeed or
9.2.2 Channels
The current channel layout requires that all servers know about all
channels, their inhabitants and properties. Besides not scaling
well, the issue of privacy is also a concern. A collision of
channels is treated as an inclusive event (both people who create the
new channel are considered to be members of it) rather than an
exclusive one such as used to solve nickname collisions.
9.2.3 Servers
9.3 Algorithms
In some places within the server code, it has not been possible to
avoid N^2 algorithms such as checking the channel list of a set
of clients.
80
Appendix A. RFC 1459: Internet Relay Chat Protocol
Software implemenations
cs.bu.edu:/irc
nic.funet.fi:/pub/irc
coombs.anu.edu.au:/pub/irc
Newsgroup: alt.irc
Security Considerations
Security issues are discussed in sections 4.1, 4.1.1, 4.1.3, 5.5, and
7.
Jarkko Oikarinen
Tuirantie 17 as 9
90500 OULU
FINLAND
Email: jto@tolsun.oulu.fi
Darren Reed
4 Pateman Street
Watsonia, Victoria 3087
Australia
Email: avalon@coombs.anu.edu.au
81
Appendix B. Client-To-Client Protocol
*****************************************
BASIC PROTOCOL BETWEEN CLIENTS AND SERVER
*****************************************
Characters between an Internet Relay Chat (IRC) client and server are
8 bit bytes (also known as octets) and can have numeric values from
octal \000 to \377 inclusive (0 to 255 decimal). Some characters are
special:
Note: ‘\’ followed by three digits is used to denote an octal value in this
paper. ‘\’ followed by an alphabetic character is used to denote a C
language style special character, and ‘..’ denotes a range of characters.
Note: The ‘*’ is used here to denote "zero or more of the preceding class of
characters", and the ‘|’ is used to denote alternation.
*****************
LOW LEVEL QUOTING
*****************
Even though messages to and from IRC servers cannot contain NUL, NL,
or CR, it still might be desirable to send ANY character (in so called
82
Appendix B. Client-To-Client Protocol
(Ie a CNTRL/P).
Before low level quoting, a message to the server (and in the opposite
direction: after low level dequoting, a message from the server) looks
like:
***********
TAGGED DATA
***********
To send extended data inside the middle level message, we need some
way to delimit it. This is done by starting and ending extended data
with a delimiter character, defined as:
83
Appendix B. Client-To-Client Protocol
As both the starting and ending delimiter looks the same, the first
X-DELIM is called the odd delimiter, and the one that follows, the
even delimiter. The next one after that, an odd delimiter, then and
even, and so on.
When data are quoted (and conversely, before being dequoted) any number
of characters of any kind except X-DELIM can be used in the extended
data inside the X-DELIM pair.
An extended message is either empty (nothing between the odd and even
delimiter), has one or more non-space characters (any character but
’\040’) or has one or more non-space characters followed by a space
followed by zero or more characters.
Note: Here ‘+’ is used to denote "one or more of the previous class of
characters", and ‘*’ is used to denote "zero or more of the previous
class of characters".
The characters up until the first SPC (or if no SPC, all of the X-MSG)
is called the tag of the extended message. The tag is used to denote
what kind of extended data is used.
******************
CTCP LEVEL QUOTING
******************
84
Appendix B. Client-To-Client Protocol
When quoting on the CTCP level, only the actual CTCP message (extended
data, queries, replies) are quoted. This enables users to actually
send X-QUOTE characters at will. The following translations should be
used:
and when dequoting on the CTCP level, only CTCP messages are dequoted
whereby the following table is used.
****************
QUOTING EXAMPLES
****************
There are three levels of messages. The highest level (H) is the text
on the user-to-client level. The middle layer (M) is on the level
where CTCP quoting has been applied to the H-level message. The lowest
level (L) is on the client-to-server level, where low level quoting
has been applied to the M-level message.
L = lowQuote(M)
M = ctcpDequote(L)
M = ctcpQuote(H)
H = ctcpDequote(ctcpExtract(M))
Of course, there might be zero or more normal text messages and zero
85
Appendix B. Client-To-Client Protocol
to user victim, i.e. a message where the user has entered an inline
newline (how this is done, if at all, differs from client to client),
will result internaly in the client in the command:
(where the \\K would look similar to OK in SIS D47 et. al.) which after
low level dequoting becomes:
If actor’s client wants to send the string "Emacs wins" this might
become the string "\n\t\big\020\001\000\\:" when being SED-encrypted
[SED is a simple encryption protocol between IRC clients implemented
with CTCP. I don’t have any reference for it -- Ben] using some key,
so the client starts by CTCP-quoting this string into the string
"\n\t\big\020\\a\000\\\\:" and builds the M-level message:
86
Appendix B. Client-To-Client Protocol
will be received from the server and low level dequoted into:
If the user actor wants to query the USERINFO of user victim, and is
in the middle of a conversation, the client may decide to tack on
USERINFO request on the end of a normal text message. Let’s say actor
wants to send the textmessage "Say hi to Ron\n\t/actor" and the CTCP
request "USERINFO" to victim:
plus:
USERINFO
plus:
USERINFO
87
Appendix B. Client-To-Client Protocol
plus:
USERINFO
USERINFO
At this point, all CTCP replies get extracted, giving 1 CTCP reply and
no normal NOTICE:
88
Appendix B. Client-To-Client Protocol
*******************
KNOWN EXTENDED DATA
*******************
ACTION
======
This is used by losers on IRC to simulate "role playing" games. An
action message looks like the following:
Clients that recieve such a message should format them to indicate the
user who did this is performing an "action". For example, if the user
"actor" sent the above message to the channel "#twilight_zone", other
users clients might display the message as:
DCC
===
DCC stands for something like "Direct Client Connection". CTCP DCC
extended data messages are used to negotiate file transfers between
clients and to negotiate chat connections over tcp connections between
two clients, with no IRC server involved. Connections between clients
involve protocols other than the usual IRC protocol. Due to this
complexity, a full description of the DCC protocol is included
separately at the end of this document in Appendix A.
SED
===
SED probably stands for something like "Simple Encryption D???". It is
used by clients to exchange encrypted messages between clients. A
message encoded by SED probably looks something like:
\001SED encrypted-text-goes-here\001
89
Appendix B. Client-To-Client Protocol
*************************
KNOWN REQUEST/REPLY PAIRS
*************************
FINGER
======
This is used to get a user’s real name, and perhaps also the idle time
of the user (this usage has been obsoleted by enhancements to the IRC
protocol. The request is in a "privmsg" and looks like
\001FINGER\001
\001FINGER :#\001
where the # denotes contains information about the users real name,
login name at clientmachine and idle time and is of type X-N-AS.
VERSION
=======
This is used to get information about the name of the other client and
the version of it. The request in a "privmsg" is simply
\001VERSION\001
\001VERSION #:#:#\001
where the first # denotes the name of the client, the second # denotes
the version of the client, the third # the enviroment the client is
running in.
90
Appendix B. Client-To-Client Protocol
Using
the client name is a string of type X-N-CLN saying things like "Kiwi"
or "ircII", the version saying things like "5.2" or "2.1.5c", the
enviroment saying things like "GNU Emacs 18.57.19 under SunOS 4.1.1 on
Sun SLC" or "Compiled with gcc -ansi under Ultrix 4.0 on VAX-11/730".
SOURCE
\001SOURCE\001
\001SOURCE #:#:#\001
\001SOURCE\001
where the first # is the name of an Internet host where the client can
be gotten from with anonymous FTP the second # a directory names, and
the third # a space separated list of files to be gotten from that
directory.
Using
USERINFO
========
91
Appendix B. Client-To-Client Protocol
\001USERINFO\001
\001USERINFO :#\001
where the # is the value of the string the client’s user has set.
CLIENTINFO
==========
This is for client developers use to make it easier to show other
client hackers what a certain client knows when it comes to CTCP. The
replies should be fairly verbose explaining what CTCP commands are
understood, what arguments are expected of what type, and what replies
might be expected from the client.
\001CLIENTINFO\001
ERRMSG
======
This is used as a reply whenever an unknown query is seen. Also, when
used as a query, the reply should echo back the text in the query,
together with an indication that no error has happened. Should the
query form be used, it is
\001ERRMSG #\001
\001ERRMSG # :#\001
where the first # is the same string as in the query and the second #
a short text notifying the user that no error has occurred.
\001ERRMSG # :#\001
92
Appendix B. Client-To-Client Protocol
where the first # is the the failed query or corrupted extended data
and the second # a text explaining what the problem is, like "unknown
query" or "failed decrypting text".
PING
====
Ping is used to measure the time delay between clients on the IRC
network. A ping query is encoded in a privmsg, and has the form:
\001PING timestamp\001
where ‘timestamp’ is the current time encoded in any form the querying
client finds convienent. The replying client sends back an identical
message inside a notice:
\001PING timestamp\001
The querying client can then subtract the recieved timestamp from the
current time to obtain the delay between clients over the IRC network.
TIME
====
Time queries are used to determine what time it is where another
user’s client is running. This can be useful to determine if someone
is probably awake or not, or what timezone they are in. A time query
has the form:
\001TIME\001
\001TIME :human-readable-time-string\001
For example:
********
EXAMPLES
********
Sending
might return
93
Appendix B. Client-To-Client Protocol
Sending
might return
Sending
might return
while sending
Sending
might return
Sending
94
Appendix B. Client-To-Client Protocol
Sending
might return:
if the client is named Kiwi of version 5.2 and is used under GNU Emacs
18.57.19 running on a Sun SLCwith SunOS 4.1.1. The client claims a
copy of it can be found with anonymous FTP on FTP.Lysator.LiU.SE after
giving the FTP command "cd /pub/emacs/". There, one should get files
Kiwi-5.2.el.Z and Kiwi.README; presumably one of the files tells how to
proceed with building the client after having gotten the files.
**********************************************************************
Appendix A -- A description of the DCC protocol
**********************************************************************
Why DCC?
========
95
Appendix B. Client-To-Client Protocol
How?
====
96
Appendix B. Client-To-Client Protocol
Implementation
==============
Older IRCII clients send the entire pathname of the file being
transmitted. This is annoying, and newer clients should simply send
the filename portion of the file being transmitted.
The following are the steps which should occur in the clients
(this description assumes use of the BSD socket interface on a UNIX
system).
Initiator:
DCC command issued.
Create a socket, bind it to INADDR_ANY, port 0, and
make it passive (a listening socket).
Send the recipient a DCC request via CTCP supplying
the address and port of the socket. (This
is ideally taken from the address of the local
side of the socket which is connected to a
server. This is presumably the interface on
the host which is closest to the rest of
the net, and results in one less routing hop
in the case of gateway nodes).
Continue normally until a connection is received.
On a connection:
Accept the connection.
Close the original passive socket.
Conduct transaction on the new socket.
Acceptor:
CTCP DCC request received.
Record information on the DCC request and notify the user.
97
Appendix B. Client-To-Client Protocol
Older IRCII clients do not send the file size of the file
being transmitted via DCC. For those clients, note that it is
not possible for the recipient to tell if the entire file has
been received - only the sender has that information, although
IRCII does not report it. Users generally verify the transfer
by checking file sizes. Authors of clients are urged to use
the size feature.
The original block size used by IRCII was 1024. Other clients
have adopted this. Note, however, that an implementation should accept
any blocksize. IRCII currently allows a user-settable blocksize.
98