IRC Client Library
(require irc) | package: irc |
The irc library allows you to develop IRC clients and communicate over IRC.
1 Quick Start
To use the IRC client library, first create a connection with irc-connect. For example, to connect to the Freenode (chat.freenode.net, port 6667) with nickname "rackbot", username "rbot", and real name "Racket Bot", do
(define-values (connection ready) (irc-connect "chat.freenode.net" 6667 "rackbot" "rbot" "Racket Bot"))
This defines an irc-connection object which must be used for all future communication with this server, as well as an event that will be ready for synchronization when the server is ready to accept more commands (i.e. when the connection has been fully established).
Once the returned event fires, you can use other IRC commands. For example, if you have a connection object named connection, you can join the #racket channel with
(irc-join-channel connection "#racket")
Once you have joined, you can send a message on that channel with the following:
(irc-send-message connection "#racket" "Hello, world!")
2 Data Structures
struct
(struct irc-message (prefix command parameters content))
prefix : (or/c string? #f) command : string? parameters : (listof string?) content : string?
3 Procedures
procedure
(irc-connection? object) → boolean?
object : any
procedure
(irc-connect server port nick username real-name [ #:return-eof return-eof]) →
irc-connection? evt? server : string?
port :
(and/c exact-nonnegative-integer? (integer-in 1 65535)) nick : string? username : string? real-name : string? return-eof : boolean? = #f
procedure
(irc-connection-incoming connection) → async-channel?
connection : irc-connection?
procedure
(irc-join-channel connection channel) → void?
connection : irc-connection? channel : string?
procedure
(irc-part-channel connection channel) → void?
connection : irc-connection? channel : string?
procedure
(irc-send-message connection target message) → void?
connection : irc-connection? target : string? message : string?
procedure
(irc-send-notice connection target notice) → void?
connection : irc-connection? target : string? notice : string?
procedure
(irc-get-connection host port [ #:return-eof return-eof]) → irc-connection? host : string?
port :
(and/c exact-nonnegative-integer? (integer-in 1 65535)) return-eof : boolean? = #f
Use this form instead of irc-connect when you want more control over when to send the NICK and USER commands.
procedure
(irc-set-nick connection nick) → void?
connection : irc-connection? nick : string?
procedure
(irc-set-user-info connection username real-name) → void? connection : irc-connection? username : string? real-name : string?
procedure
connection : irc-connection? quit-message : string? = ""
procedure
(irc-send-command connection command args ...) → void? connection : irc-connection? command : string? args : string?
4 Further Information
For more information on the IRC client protocol, see RFC 2812.