sigildocs

(sigil irc connection)

(sigil irc connection) - IRC Connection Management

Handles IRC connections with TLS support, message buffering, SASL authentication, and event dispatching.

Exports

Construct a irc-connection struct.

Test if a value is a irc-connection struct.

Get the server field of a irc-connection struct.

Get the port field of a irc-connection struct.

Get the nick field of a irc-connection struct.

Get the user field of a irc-connection struct.

Get the realname field of a irc-connection struct.

Get the tls? field of a irc-connection struct.

Get the sasl-username field of a irc-connection struct.

Get the sasl-password field of a irc-connection struct.

Get the state field of a irc-connection struct.

Get the socket field of a irc-connection struct.

Get the buffer field of a irc-connection struct.

Get the current-nick field of a irc-connection struct.

Get the channels field of a irc-connection struct.

Get the message-handlers field of a irc-connection struct.

Get the command-handlers field of a irc-connection struct.

Set the state field of a irc-connection struct.

Set the socket field of a irc-connection struct.

Set the buffer field of a irc-connection struct.

Set the current-nick field of a irc-connection struct.

Set the channels field of a irc-connection struct.

Set the message-handlers field of a irc-connection struct.

Set the command-handlers field of a irc-connection struct.

Create 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)

Check if connection is in connected state.

irc-connectprocedure

Connect 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.

Disconnect from the IRC server.

Optionally sends a QUIT message before closing.

Register 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)))
irc-onprocedure

Register a handler for a specific IRC command.

(irc-on conn 'PRIVMSG
  (lambda (msg)
    (display (irc-message-text msg))))
irc-send-rawprocedure

Send a raw IRC command (must include trailing CRLF).

Process 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.

irc-privmsgprocedure

Send a PRIVMSG to a channel or user.

irc-noticeprocedure

Send a NOTICE to a channel or user.

irc-joinprocedure

Join a channel.

irc-partprocedure

Leave a channel.

irc-quitprocedure

Send QUIT and disconnect.

irc-nickprocedure

Change nickname.

irc-modeprocedure

Set mode.

Identify with NickServ.

Can be called with just password (uses current nick) or with nick and password (for grouped nicks).

irc-tickprocedure

Process 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.

irc-runprocedure

Run 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.