(sigil irc)
(sigil irc) - IRC Client Library
A complete IRC client library with TLS support, SASL authentication, and cooperative non-blocking I/O for concurrent applications.
Quick Start
(import (sigil irc))
(define conn (make-irc-connection
server: "irc.libera.chat"
port: 6697
nick: "mybot"
tls: #t))
(irc-on conn 'PRIVMSG
(lambda (msg)
(display (irc-message-nick msg))
(display ": ")
(display (irc-message-text msg))
(newline)))
(irc-connect conn)
(irc-join conn "#mychannel")
(irc-run conn)With SASL Authentication
(define conn (make-irc-connection
server: "irc.libera.chat"
port: 6697
nick: "mybot"
tls: #t
sasl-username: "mybot"
sasl-password: "secret"))Integration with HTTP Server
(let loop ()
(let* ((irc-sock (irc-connection-socket conn))
(http-sock server-socket)
(ready (socket-select (list irc-sock http-sock) '() 100)))
(when (memq irc-sock (car ready))
(irc-process-input conn))
(when (memq http-sock (car ready))
(handle-http-client))
(loop)))Exports
irc-messageprocedureConstruct a irc-message struct.
Re-exported from (sigil irc message)
irc-message?procedureTest if a value is a irc-message struct.
Re-exported from (sigil irc message)
irc-message-rawprocedureGet the raw field of a irc-message struct.
Re-exported from (sigil irc message)
irc-message-prefixprocedureGet the prefix field of a irc-message struct.
Re-exported from (sigil irc message)
irc-message-nickprocedureGet the nick field of a irc-message struct.
Re-exported from (sigil irc message)
irc-message-userprocedureGet the user field of a irc-message struct.
Re-exported from (sigil irc message)
irc-message-hostprocedureGet the host field of a irc-message struct.
Re-exported from (sigil irc message)
irc-message-commandprocedureGet the command field of a irc-message struct.
Re-exported from (sigil irc message)
irc-message-paramsprocedureGet the params field of a irc-message struct.
Re-exported from (sigil irc message)
irc-message-trailingprocedureGet the trailing field of a irc-message struct.
Re-exported from (sigil irc message)
irc-message-targetprocedureGet the target of a message (first param, usually channel or nick).
For PRIVMSG, JOIN, PART, etc., this is the channel or user.
(irc-message-target msg) ; => "#channel" or "nickname"Re-exported from (sigil irc message)
irc-message-textprocedureGet the text content of a message (alias for trailing).
(irc-message-text msg) ; => "Hello world"Re-exported from (sigil irc message)
parse-irc-messageprocedureParse a raw IRC message line into an irc-message record.
Returns an irc-message record, or #f if parsing fails.
(parse-irc-message ":nick!user@host PRIVMSG #chan :Hello")
; => #<irc-message nick: "nick" command: PRIVMSG ...>Re-exported from (sigil irc message)
make-irc-commandprocedureCreate an IRC command string from parts.
(make-irc-command "PRIVMSG" "#channel" "Hello world")
; => "PRIVMSG #channel :Hello world"Re-exported from (sigil irc message)
irc-command->stringprocedureConvert an IRC command to a wire-format string (with CRLF).
(irc-command->string "PRIVMSG" "#channel" "Hello")
; => "PRIVMSG #channel :Hello\r\n"Re-exported from (sigil irc message)
irc-connectionprocedureConstruct a irc-connection struct.
Re-exported from (sigil irc connection)
make-irc-connectionvariableCreate a new IRC connection (does not connect yet).
Options: server: - IRC server hostname (required) port: - Port number (default: 6667, or 6697 for TLS) nick: - Nickname (required) user: - Username (default: same as nick) realname: - Real name (default: "") tls: - Use TLS (default: #f) sasl-username: - SASL username (optional) sasl-password: - SASL password (optional)
(make-irc-connection
server: "irc.libera.chat"
port: 6697
nick: "mybot"
tls: #t)Re-exported from (sigil irc connection)
irc-connection?procedureTest if a value is a irc-connection struct.
Re-exported from (sigil irc connection)
irc-connection-serverprocedureGet the server field of a irc-connection struct.
Re-exported from (sigil irc connection)
irc-connection-portprocedureGet the port field of a irc-connection struct.
Re-exported from (sigil irc connection)
irc-connection-nickprocedureGet the nick field of a irc-connection struct.
Re-exported from (sigil irc connection)
irc-connection-userprocedureGet the user field of a irc-connection struct.
Re-exported from (sigil irc connection)
irc-connection-realnameprocedureGet the realname field of a irc-connection struct.
Re-exported from (sigil irc connection)
irc-connection-tls?procedureGet the tls? field of a irc-connection struct.
Re-exported from (sigil irc connection)
irc-connection-stateprocedureGet the state field of a irc-connection struct.
Re-exported from (sigil irc connection)
irc-connection-socketprocedureGet the socket field of a irc-connection struct.
Re-exported from (sigil irc connection)
irc-connection-current-nickprocedureGet the current-nick field of a irc-connection struct.
Re-exported from (sigil irc connection)
irc-connectprocedureConnect to the IRC server.
Establishes the connection, performs TLS handshake if enabled, and begins IRC registration (NICK/USER or CAP/SASL).
Returns #t on success, #f on failure.
Re-exported from (sigil irc connection)
irc-disconnectprocedureDisconnect from the IRC server.
Optionally sends a QUIT message before closing.
Re-exported from (sigil irc connection)
irc-connected?procedureCheck if connection is in connected state.
Re-exported from (sigil irc connection)
irc-on-messageprocedureRegister a handler for all incoming messages.
The handler receives an irc-message record.
(irc-on-message conn
(lambda (msg)
(display (irc-message-command msg))
(newline)))Re-exported from (sigil irc connection)
irc-onprocedureRegister a handler for a specific IRC command.
(irc-on conn 'PRIVMSG
(lambda (msg)
(display (irc-message-text msg))))Re-exported from (sigil irc connection)
irc-send-rawprocedureSend a raw IRC command (must include trailing CRLF).
Re-exported from (sigil irc connection)
irc-process-inputprocedureProcess available input from the IRC connection.
Reads data from the socket, parses complete lines, and dispatches messages to handlers. Call this when socket-select indicates the connection is readable.
Returns #t if connection is still alive, #f if disconnected.
Re-exported from (sigil irc connection)
irc-privmsgprocedureSend a PRIVMSG to a channel or user.
Re-exported from (sigil irc connection)
irc-noticeprocedureSend a NOTICE to a channel or user.
Re-exported from (sigil irc connection)
irc-joinprocedureJoin a channel.
Re-exported from (sigil irc connection)
irc-partprocedureLeave a channel.
Re-exported from (sigil irc connection)
irc-quitprocedureSend QUIT and disconnect.
Re-exported from (sigil irc connection)
irc-nickprocedureChange nickname.
Re-exported from (sigil irc connection)
irc-modeprocedureSet mode.
Re-exported from (sigil irc connection)
irc-nickserv-identifyprocedureIdentify with NickServ.
Can be called with just password (uses current nick) or with nick and password (for grouped nicks).
Re-exported from (sigil irc connection)
irc-runprocedureRun the IRC connection event loop.
Processes messages until disconnected. When running inside a channel-run context, cooperates with other tasks via await-readable. Otherwise blocks in a traditional event loop.
Re-exported from (sigil irc connection)
irc-tickprocedureProcess one tick of the IRC connection (non-blocking).
Checks if data is available and processes it. Returns #t if connection is alive, #f if disconnected.
Re-exported from (sigil irc connection)