Conditions
connection-closed
Signalled by the disconnect
function.
Disconnecting is the default action whenever an error occurs, so this signal can for example be handled to reconnect.
client
Client whose connection was closed
connection-failed
connect
.client
Client whose connection failederror
Reason for failure
connection-lost
Signalled when connection is lost.
Currently signalled when an error occurs during trying to receive a message from the server.
client
Client whose connection was lost
Macros
define-handler
((command class-spec prefix-var arguments-var) &body body)
Define handling for command
.
This is currently a convenience for specializing on the generic
function handle
. An example is the handler for PING
messages (which by default is the only handler specialization).
(define-handler (:ping client prefix arguments)
(send-pong client (first arguments)))
If you wanted to use a different variable-name for the client variable, you could also have written it as
(define-handler (:ping (client client) prefix arguments)
(send-pong client (first arguments)))
Generics
change-nick
(client new-nickname)
nickname
of client
connect
(client)
Connect and register client
with an IRC server.
This also sets up some of the slots, and opens the log-stream.
connected-p
(client)
t
if client
is connected, nil
otherwise.disconnect
(client &key message)
Send QUIT message to server, close the socket and close the log-stream.
Always signals connection-closed
.
handle
(command client prefix arguments)
Called by receive-message
after parsing the raw message.
Specialize on this function with the macro define-handler
for customizing
behaviour.
There is a default method that spits out the unhandled message
to *standard-output*
.
nickname
(client)
client
.receive-message
(client)
Read a message from connection, parse it,
handle
, and return a list with the following 3 elements:
- the raw prefix string, or
nil
if prefix wasn't present - command is a keyword with a name corresponding to the command from the RFC and
- parsed-parameters is a list of strings representing the arguments in the message.
If an error occurs during the reading, the client will be
disconnected, and connection-closed
will be signalled.
send-join
(client channel &key password)
send-privmsg
(client victim message)
message
to victim
, where victim
is either a
channel- or nick-name.socket
(client)
client
's socket.Functions
parse-prefix
(prefix)
Return a list of the components in prefix.
The elements of the list are as follows:
- servername or nickname as string
- username string, or
nil
- a hostname string, or
nil
send-raw-message
(client raw-message)
Send raw-message
and CRLF to the socket associated with client
.
Outside of the few send-* functions, this is what you have to use to send messages to the server.
Class
client
A client connection to an IRC server.
Valid initargs are:
:nickname
-- the nickname use when connecting (required):server
-- the hostname of the server to connect to as a string (required):port
-- the port to connect to as an integer (optional):username
-- the username to register with (optional):realname
-- the realname to register with (optional):password
-- the password to regiseter with (optional):log-pathname
-- pathname for packet-log pathname (optional)
Please note that you call connect
on a client
instance, rather than
having connect
return a client
instance.
nickname
Nickname of client (mandatory). Sent at beginning of connection, and bychange-nick
password
Password used during registration (optional)username
Username sent at beginning of connection. Defaults to nickname.realname
Realname sent at beginning of connection. Defaults to username.server
Address of the IRC serverport
Port of client connectionsocket
Socket of an active connectionlog-pathname
Pathname of log-filelog-stream
Stream of log-file