Rendered 2008-08-30 23:42:09

The TRIVIAL-IRC package.

Uses

Description

Trivial IRC client library.

See examples/echobot/ in the distribution directory for a simple example of how to use it.

Currently, the exposed API is a very thin abstraction of the IRC protocol, and you probably need the IRC RFC to make use of it.

The current version was slapped together in a few hours, to fill a specific need I had. It's not certain that it will evolve with much, but I'm open to suggestions and requests.

If you have a better fit for trivial-irc and want to claim the name, just let me know and I'll retire this.

Classes

client ()

A client connection to an IRC server.

Valid initargs are:

Please note that you call connect on an instance of client, instead of having connect return a an instance instance.

Conditions

connection-closed (condition)

Signalled by disconnect.

Disconnecting is the default action whenever an error occurs, so this signal can for example be handled to reconnect.

connection-failed (error)

Signalled by connect.

connection-lost (error)

Signalled when connection is lost.

Currently signalled when an error occurs during trying to receive a message from the server.

Macros

define-handler(command class-spec prefix-var arguments-var) &body body

Define handling for command.

This is currently a convenience for specializing on 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)))

Generic functions

connectclient

Connect and register client with an IRC server.

This also sets up some of the slots, and opens the log-stream.

connected-pclient

Return t if client is connected, nil otherwise.

disconnectclient &key message

Send QUIT message to server, close the socket and close the log-stream.

Always signals connection-closed.

handlecommand client prefix arguments

Called by receive-message after parsing the raw message.

Specialize this with the macro define-handler for customizing the behaviour.

There is a default method that spits out the unhandled message to *standard-output*.

nicknameclient

Return current nickname of client.

receive-messageclient

Read a message from connnection, parse it, handle, and return the parsed bits.

The return value is a list with (/raw-prefix/ command parsed-parameters), where

If an error occurs during the reading, the client will be disconnected, and the connection-closed will be signalled.

send-joinclient channel &key password

Send JOIN message.

send-pongclient message

Send PONG command to server.

send-privmsgclient victim message

Send message to victim.

victim can be either a channel-name or a nickname.

Functions

parse-prefixprefix

Return a list of the components in prefix.

It is a list on the form ( server-or-nickname username host) where

This can potentially be used to build other abstractions later.

prefix-nicknameprefix

Return the nickname in extracted from prefix.

prefix-servernameprefix

Return the servername extracted from prefix.

send-raw-messageclient 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.