(sigil irc chathistory)
(sigil irc chathistory) - CHATHISTORY command helpers (IRCv3 draft)
CHATHISTORY lets clients query history without disconnecting. The capability tag draft/chathistory advertises a chathistory=<MAX> integer for the server's per-query message limit.
Subcommands (per https://ircv3.net/specs/extensions/chathistory):
CHATHISTORY BEFORE <target> <selector> <limit> CHATHISTORY AFTER <target> <selector> <limit> CHATHISTORY LATEST <target> <selector> <limit> CHATHISTORY AROUND <target> <selector> <limit> CHATHISTORY BETWEEN <target> <selector1> <selector2> <limit> CHATHISTORY TARGETS <selector1> <selector2> <limit>
A selector is one of:
timestamp=<RFC-3339-UTC> msgid=<msgid-string> * (means "current" / endpoint)
Server responses are wrapped in a chathistory batch tagged with the target channel/nick (a single param after the type), and the messages within it carry their original msgid and time tags so the client can re-anchor its view.
Failures use the IRCv3 standard-replies format:
FAIL CHATHISTORY <error-code> <subcommand> [<params>...] :<text>
with <error-code> from a small enum: INVALIDPARAMS, INVALIDTARGET, MESSAGEERROR, NEEDMORE_PARAMS.
This module provides:
- Subcommand and selector enumerated constants
- A
chathistory-queryrecord + parser/serializer for the client→server line - Helpers to build the server's batch+messages response
- Helpers to build the FAIL standard-reply
Exports
chathistory-selectorprocedureSelectors identify positions in history. kind is one of:
'timestamp value is an RFC 3339 UTC timestamp string 'msgid value is a server-assigned msgid string 'star value is #f (selector is `*`, meaning "now")
chathistory-selector?procedureTest if a value is a chathistory-selector struct.
chathistory-selector-kindprocedureGet the kind field of a chathistory-selector struct.
chathistory-selector-valueprocedureGet the value field of a chathistory-selector struct.
parse-chathistory-selectorprocedureParse a single selector token. Returns a selector record on success or #f on malformed input.
chathistory-selector->stringprocedureSerialize a selector back to its wire form.
%chathistory-query--typevariableSerialize a selector back to its wire form.
chathistory-queryprocedureA parsed CHATHISTORY query.
subcommand: string, one of CHATHISTORY-* constants target: string, channel or nick (#f for TARGETS subcommand) selector1: chathistory-selector selector2: chathistory-selector or #f (BETWEEN/TARGETS only) limit: integer
chathistory-query?procedureTest if a value is a chathistory-query struct.
chathistory-query-subcommandprocedureGet the subcommand field of a chathistory-query struct.
chathistory-query-targetprocedureGet the target field of a chathistory-query struct.
chathistory-query-selector1procedureGet the selector1 field of a chathistory-query struct.
chathistory-query-selector2procedureGet the selector2 field of a chathistory-query struct.
chathistory-query-limitprocedureGet the limit field of a chathistory-query struct.
parse-chathistory-lineprocedureParse an incoming CHATHISTORY message into a query record. Returns the query on success, or #f if malformed.
(parse-chathistory-line
(parse-irc-message "CHATHISTORY BEFORE #chan timestamp=2026-04-27T12:00:00Z 50"))
; => #<chathistory-query subcommand: "BEFORE" target: "#chan"
; selector1: #<sel timestamp> selector2: #f limit: 50>chathistory-lineprocedureSerialize a chathistory-query back to a wire-format CHATHISTORY line (with CRLF). Useful for client-side construction.
CHATHISTORY-BATCH-TYPEvariable(No description)
CHATHISTORY-BEFOREvariable(No description)
CHATHISTORY-AFTERvariable(No description)
CHATHISTORY-LATESTvariable(No description)
CHATHISTORY-AROUNDvariable(No description)
CHATHISTORY-BETWEENvariable(No description)
CHATHISTORY-TARGETSvariable(No description)
CHATHISTORY-FAIL-INVALID-PARAMSvariable(No description)
CHATHISTORY-FAIL-INVALID-TARGETvariable(No description)
CHATHISTORY-FAIL-MESSAGE-ERRORvariable(No description)
(No description)
make-chathistory-selectorvariable(No description)