Rendered 2008-08-30 23:42:09
common-lisp
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.
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 an instance of client
, instead of
having connect
return a an instance instance.
Signalled by disconnect
.
Disconnecting is the default action whenever an error occurs, so this signal can for example be handled to reconnect.
Signalled by connect
.
Signalled when connection is lost.
Currently signalled when an error occurs during trying to receive a message from the server.
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)))
Connect and register client with an IRC server.
This also sets up some of the slots, and opens the log-stream.
Return t
if client is connected, nil
otherwise.
Send QUIT message to server, close the socket and close the log-stream.
Always signals connection-closed
.
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*
.
Return current nickname of client.
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
nil
if prefix wasn't present,If an error occurs during the reading, the client will be
disconnected, and the connection-closed
will be signalled.
Send JOIN message.
Send PONG command to server.
Send message to victim.
victim can be either a channel-name or a nickname.
Return a list of the components in prefix.
It is a list on the form ( server-or-nickname username host) where
nil
nil
This can potentially be used to build other abstractions later.
Return the nickname in extracted from prefix.
Return the servername extracted from prefix.
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.