Trivial IRC ยป Reference

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
Signalled by connect.
  • client
    Client whose connection failed
  • error
    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)
Send NICK message to server, and set the 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)
Return 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)
Return current nickname of client.
receive-message(client)

Read a message from connection, parse it, handle, and return a list with the following 3 elements:

  1. the raw prefix string, or nil if prefix wasn't present
  2. command is a keyword with a name corresponding to the command from the RFC and
  3. 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 JOIN message.
send-privmsg(client victim message)
Send message to victim, where victim is either a channel- or nick-name.
socket(client)
Return the 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 by change-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 server
  • port
    Port of client connection
  • socket
    Socket of an active connection
  • log-pathname
    Pathname of log-file
  • log-stream
    Stream of log-file