Scripts Tutorial
This document describes Rete’s Tcl scripting API: how to bind to events, how return values influence client behaviour, what globals are available, and which helper commands you can call from Tcl.
Event binding
- Bind a handler:
bind EVENT handlerProc
- Unbind a handler:
unbind EVENT handlerProc
- Multiple handlers may be bound to the same
EVENT; they run in bind order. - Handler procs are called as:
proc handlerProc {arg1 arg2 ...} {
# return 0 to let Rete continue normal processing
# return 1 to stop further processing of this event
}
Return convention
- Return
0→ Rete continues processing (other Tcl handlers, then its own logic). - Return
1→ Rete stops processing this event in Swift; no further handlers are run and the built‑in behaviour is skipped. - Any non‑integer or missing return value is treated like
0(continue).
Event arguments
Each event passes a fixed list of string arguments to your handler.
Timestamps are passed as ISO‑8601 strings when available, otherwise "".
Optional values (like account, reason) are passed as "" when absent.
RAWIN
proc my_rawin {line} {
# line: raw line from server before any parsing
return 0
}
REGISTERED
proc my_registered {} {
# No arguments
return 0
}
SILENCE
proc my_silence {action hostmask} {
# action: "add" or "rem"
# hostmask: the hostmask being added/removed
return 0
}
ERROR
proc my_error {text} {
# text: server error message
return 0
}
RPL (numeric replies)
proc my_rpl {code text buffer serverTime} {
# code: numeric code as string (e.g., "001", "005"), or ""
# text: reply text
# buffer: target buffer name (channel/DM) if applicable, or ""
# serverTime: ISO-8601 timestamp or ""
return 0
}
SERVERNOTICE
proc my_servernotice {from text channel serverTime} {
# from: sender prefix or ""
# text: notice text
# channel: associated channel if applicable, or ""
# serverTime: ISO-8601 timestamp or ""
return 0
}
JOIN
proc my_join {channel nick user host account realname serverTime} {
# channel: channel name
# nick: nickname of person who joined
# user: ident/username
# host: hostname
# account: services account name or ""
# realname: realname/GECOS
# serverTime: ISO-8601 timestamp or ""
return 0
}
PART
proc my_part {channel nick reason serverTime} {
# channel: channel name
# nick: nickname of person who left
# reason: part reason or ""
# serverTime: ISO-8601 timestamp or ""
return 0
}
QUIT
proc my_quit {nick message serverTime} {
# nick: nickname of person who quit
# message: quit message or ""
# serverTime: ISO-8601 timestamp or ""
return 0
}
CHANMSG (channel PRIVMSG)
proc my_chanmsg {from channel text serverTime} {
# from: sender nickname
# channel: channel name
# text: message text
# serverTime: ISO-8601 timestamp or ""
return 0
}
DIRECTMSG (direct PRIVMSG)
proc my_directmsg {from target text serverTime} {
# from: sender nickname
# target: recipient (your nick or theirs)
# text: message text
# serverTime: ISO-8601 timestamp or ""
return 0
}
CHANNOTICE (channel NOTICE)
proc my_channotice {from channel target text serverTime} {
# from: sender nickname or server prefix
# channel: channel name
# target: target nickname or ""
# text: notice text
# serverTime: ISO-8601 timestamp or ""
return 0
}
DIRECTNOTICE (direct NOTICE)
proc my_directnotice {from target text serverTime} {
# from: sender nickname or server prefix
# target: recipient nickname
# text: notice text
# serverTime: ISO-8601 timestamp or ""
return 0
}
NICK (nick change)
proc my_nick {oldNick newNick serverTime} {
# oldNick: previous nickname
# newNick: new nickname
# serverTime: ISO-8601 timestamp or ""
return 0
}
TOPIC (topic info/update)
proc my_topic {channel topic who serverTime} {
# channel: channel name
# topic: topic text or ""
# who: nickname who set topic, or "" for topic info (RPL 332/333)
# serverTime: ISO-8601 timestamp or ""
return 0
}
MODE (channel mode change)
proc my_mode {channel setter modeString params serverTime} {
# channel: channel name
# setter: nickname who set the mode
# modeString: mode string (e.g., "+o", "+nt-lk"), or ""
# params: space-separated mode parameters, or ""
# serverTime: ISO-8601 timestamp or ""
return 0
}
AWAY (away status change)
proc my_away {nick isAway message serverTime} {
# nick: nickname
# isAway: "1" if now away, "0" if back
# message: away message or ""
# serverTime: ISO-8601 timestamp or ""
return 0
}
ACCOUNT (account change)
proc my_account {nick account serverTime} {
# nick: nickname
# account: services account name, or "" if logged out
# serverTime: ISO-8601 timestamp or ""
return 0
}
CHGHOST (user/host change)
proc my_chghost {nick user host serverTime} {
# nick: nickname
# user: new ident/username
# host: new hostname
# serverTime: ISO-8601 timestamp or ""
return 0
}
OPER (oper status change)
proc my_oper {nick isOper} {
# nick: nickname
# isOper: "1" if now oper, "0" if no longer oper
# NOTE: No serverTime for OPER events
return 0
}
INVITE
proc my_invite {inviter target channel serverTime} {
# inviter: nickname who sent invite
# target: nickname who was invited (may be you)
# channel: channel name
# serverTime: ISO-8601 timestamp or ""
return 0
}
KICK
proc my_kick {channel kicker victim reason serverTime} {
# channel: channel name
# kicker: nickname who kicked, or ""
# victim: nickname who was kicked
# reason: kick reason or ""
# serverTime: ISO-8601 timestamp or ""
return 0
}
WALLOPS
proc my_wallops {from text serverTime} {
# from: sender nickname or server prefix
# text: wallops message text
# serverTime: ISO-8601 timestamp or ""
return 0
}
ACTION (ACTION, /me)
proc my_action {from target text serverTime} {
# from: sender nickname
# target: channel name or nickname (where action was sent)
# text: action text (without the `/me` prefix)
# serverTime: ISO-8601 timestamp or ""
return 0
}
CTCPREQ (CTCP request)
proc my_ctcpreq {from target command params serverTime} {
# from: sender nickname
# target: recipient (channel or nickname)
# command: CTCP command name (uppercased, e.g., "VERSION", "PING")
# params: command parameters or ""
# serverTime: ISO-8601 timestamp or ""
return 0
}
CTCPRPL (CTCP reply)
proc my_ctcprpl {from target command params serverTime} {
# from: sender nickname
# target: recipient (channel or nickname)
# command: CTCP command name (uppercased, e.g., "VERSION", "PING")
# params: reply parameters or ""
# serverTime: ISO-8601 timestamp or ""
return 0
}
Globals
Identity variables:
mynick– your current nicknamemyuser– your user/identmyhost– your hostmyaccount– your services account name (or""if not authenticated)
Server variables:
server– the current server’s real nameserveraddress– the current server’s internet address and port from config (format:host:port)serverdaemon– the detected IRC daemon type (e.g.,"ircu","ratbox","hybrid","bahamut","unrealircd","inspircd","solanum","snircd", or"unknown")server-online– unixtime when connected to current server, or"0"if disconnected
Version variables:
version– current Rete version string (e.g.,"1.0+pl100")numversion– numeric version inM.NN.RR.PPformat (e.g.,"1.00.00.00")uptime– unixtime when the store/script engine was created
Access them from Tcl as normal variables:
debug "I am $mynick!$myuser@$myhost (account=$myaccount)"
debug "Connected to $server at $serveraddress (daemon: $serverdaemon)"
debug "Uptime: $uptime, Server online: $server-online"
Helper commands (getters)
- Channel topic
topic #channel
Returns the current topic for #channel as a string, or "" if none is known.
- Channel modes
getchanmode #channel
Returns a human‑readable mode string for #channel if available, or "" if
no cached information is available.
- ISUPPORT
isupport_get KEY ;# returns string or ""
isupport_isset KEY ;# returns 1 if the key is present, 0 otherwise
These map directly onto the server’s ISUPPORT tokens as seen in RPL 005.
- IRC string comparison
rfcequal string1 string2
Checks if two strings are equal using IRC case-insensitive comparison (RFC 1459
matching). This uses the same comparison logic as Rete’s internal IRCCompare
function, which respects the server’s CASEMAPPING ISUPPORT token.
Returns 1 if the strings are equal (case-insensitive, with RFC 1459 character
equivalences: {}|~ == []\^), 0 otherwise.
Example:
# These all return 1 (equal)
rfcequal "Nick" "nick"
rfcequal "Test" "test"
rfcequal "User[Name" "user{name" ;# [ == { under RFC 1459
rfcequal "Chan^el" "chan~el" ;# ^ == ~ under RFC 1459
- Theme settings
theme_get <option>
Returns the value of a theme setting from the current theme. This allows scripts to access theme configuration values such as colors, badge icons, and theme information.
Options:
-
Badge icons (returns SF Symbol names):
operatorBadge,awayBadge,secureBadge,botBadge,blockedBadge,joinBadge,partBadge,quitBadge,actionBadge,noticeBadge,infoBadge,topicBadge -
UI colors (returns hex color strings):
background,foreground,accent,divider,topicBarBackground,topicBarForeground,badgeBackground,badgeForeground,sidebarSelectionBackground,sidebarSelectionForeground,highlightRowBackground,expandedGroupRowBackground -
Badge colors (returns hex color strings):
operatorBadgeColor,awayBadgeColor,secureBadgeColor,botBadgeColor,blockedBadgeColor -
Theme information:
themeorthemename(current theme name),scriptEditorHighlightrTheme(Highlightr theme name for script editor)
Returns a string value, or an empty string if the option is not found. Colors are
returned in hex format (e.g., "#FF0000"). The command automatically uses the
appropriate light/dark palette based on the current appearance mode.
Example:
# Get current theme name
set themeName [theme_get theme]
debug "Current theme: $themeName"
# Get accent color
set accentColor [theme_get accent]
debug "Accent color: $accentColor"
# Get bot badge icon
set botBadge [theme_get botBadge]
debug "Bot badge: $botBadge"
# Respond with theme information
proc on_chanmsg_info {from channel text serverTime} {
if {$text eq "!theme"} {
set themeName [theme_get theme]
set highlightTheme [theme_get scriptEditorHighlightrTheme]
msg $channel "Theme: $themeName, Highlight theme: $highlightTheme"
}
return 0
}
bind CHANMSG on_chanmsg_info
For complete documentation, see the “Accessing Theme Settings from TCL Scripts” section in Themes.md.
- Channel status
isop nick #channel
ishalfop nick #channel
isvoice nick #channel
Each returns 1 if the nick has the corresponding privilege on the channel,
0 otherwise. nick may be "" to mean “me”.
- User status
isaway nick
isbot nick
isoper nick
issecure nick
getaccount nick
These query Rete’s cached Person entry for nick and return:
isaway/isbot/isoper/issecure:1or0.getaccount: account string or""if not known.
issecure checks if the user has a secure (TLS/SSL) connection to the server.
- Channel list modes
ischanban ban #channel
ischanexempt exempt #channel
ischaninvite invite #channel
These commands check if a specific mask is present on the channel’s ban list,
exception list, or invite-exempt list. Each returns 1 if found, 0 otherwise.
chanbans #channel
chanexempts #channel
chaninvites #channel
These commands return Tcl lists of entries for the respective channel lists.
Each entry is a sublist of the form {mask bywho age}:
mask: the ban/exempt/invite maskbywho: the nickname or server that set the entry (may be empty)age: seconds since the entry was set (may be empty if timestamp is unknown)
Example:
# Check if a ban exists
if {[ischanban *!*@*.example.com #channel]} {
debug "User is banned"
}
# List all bans
set bans [chanbans #channel]
foreach entry $bans {
set mask [lindex $entry 0]
set bywho [lindex $entry 1]
set age [lindex $entry 2]
debug "Ban: $mask (set by $bywho, age: $age seconds)"
}
Helper commands (setters)
Scripts can also update certain fields on Person entries (Rete’s cached
view of users on the current connection).
- Color
setcolor nick #RRGGBB
Sets color for nick to the given hex color (normalized by Rete).
This affects how that nick is rendered in the UI (subject to theme rules).
- Bot flag
setbot nick 0|1
Sets Person.isBot for nick to 1 (true) or 0 (false). This can be used
by themes or scripts to treat known bots differently.
Helper commands (buffer manipulation)
- Append message to buffer
appendmsg <buffer> <sender> <message> <category> ?tags...?
Appends a message to the specified buffer. This allows scripts to add messages to buffers programmatically, which can be useful for custom logging, notifications, or bot responses.
buffer: Buffer identifier. This can be either:- A buffer name (channel name like
#channel, DM peer name likenickname, or system/script/web buffer name), or - A buffer UUID string returned by
getbuffer
- A buffer name (channel name like
sender: Sender nickname (use""for no sender, i.e., server/system messages)message: Message text contentcategory: Message category (see below for valid categories)tags: Optional space-separated list of message tags (see below for valid tags)
Valid categories:
normal– Regular channel or DM messageserverNotice– Server notice messageserverReply– Server numeric replyinfo– Informational messageerror– Error messagejoin– User join eventpart– User part eventquit– User quit eventtopic– Topic change/infonick– Nickname changenotice– Notice messagemode– Mode changekick– Kick eventaction– CTCP ACTION (/me)ctcp– CTCP messageinvite– Invite event
Valid tags:
server– Server/system messagechannel– Channel messagedm– Direct messagenotice– Notice messagereply– Reply messageerror– Error messageinfo– Info messagescript– Script-generated messageraw– Raw messagein– Incoming messageout– Outgoing messagebold– Bold texthighlight– Highlighted messagesilence– Silenced user
Returns nothing on success. If the buffer is not found, an error message is written to the Script Debug buffer.
- Create buffer
createbuffer name type ?inputCallback? ?hidden?
Creates a new buffer with the specified name and type.
name: Buffer name (string)type: Buffer type (one of:channel,directMessage,web,script)inputCallback(optional): For script buffers only - TCL function name to call when input is sent. Use empty string""to explicitly disable input, or omit to disable by default.hidden(optional):"1"or"true"to create buffer hidden,"0"or omitted for visible
Buffer Types:
channel- Creates a channel buffer (equivalent to joining a channel)directMessage- Creates a direct message buffer (equivalent to opening a DM)web- Creates a web content buffer for displaying URLsscript- Creates a script-controlled buffer with optional input callback
Script Buffers:
Script buffers are special buffers that can have an optional input callback function. When a callback function is provided and the user sends input in the buffer:
- The callback function is called with two arguments:
bufferName: The name of the bufferinputText: The text that was entered
- If no callback is provided (or an empty string is passed), input is disabled for the buffer.
Notes:
- Buffers created by scripts are automatically removed when the script is unloaded
- On script reload (rehash), callback functions are validated - if a callback function no longer exists, input is automatically disabled for that buffer
- Only script buffers can have input callbacks; other buffer types use their standard input behavior
Example (create/append):
# Append a normal message to a channel
appendmsg "#channel" "BotName" "Hello from script!" "normal" "channel"
# Append a server notice-style message (no sender)
appendmsg "#channel" "" "This is a system message" "serverNotice" "server"
# Append an error message
appendmsg "#channel" "" "Something went wrong!" "error" "error"
# Append a join event
appendmsg "#channel" "SomeUser" "has joined" "join" "channel"
# Append to a DM buffer
appendmsg "nickname" "BotName" "Private message" "normal" "dm"
# Create a script buffer with input callback
proc my_buffer_input {bufferName text} {
msg #channel "Received: $text"
}
createbuffer "MyBuffer" script "my_buffer_input"
# Create a channel buffer
createbuffer "#test" channel
# Create a hidden script buffer without input
createbuffer "LogBuffer" script "" 1
- Resolve buffer to UUID
getbuffer <name> <type>
Resolves a buffer by name and type and returns its UUID string. This is useful
to avoid name collisions (e.g. a DM and a script buffer both called “nick”)
when using commands like appendmsg, hidebuffer, or setbuffericon.
name: Buffer name (channel name like#channel, DM peer name likenickname, script buffer name, etc.)type: One ofchannel,direct,dm,directMessage,web,script,system,raw
Returns the buffer UUID as a string on success, or an empty string if no matching buffer is found.
Example:
# Get the UUID for a script buffer called "test"
set bufId [getbuffer "test" script]
if {$bufId ne ""} {
# Append a message using the UUID
appendmsg $bufId "" "Hello from script buffer" "normal" "script"
# Hide the buffer using the UUID
hidebuffer $bufId 1
# Set a custom icon using the UUID
setbuffericon $bufId "star.fill"
}
- Set buffer icon
setbuffericon <buffer> <iconName>
Sets a custom SF Symbol icon for a buffer. If the icon name is invalid (SF Symbol doesn’t exist) or empty, resets to the default icon based on buffer kind.
buffer: Buffer identifier (name or UUID fromgetbuffer)iconName: SF Symbol name (e.g.,"star.fill","heart.circle"). Use empty string""to reset to default.
If the specified SF Symbol doesn’t exist, the command will log a warning and reset to the default icon for that buffer type.
Example:
# Set a custom icon for a script buffer
setbuffericon "MyBuffer" "star.fill"
# Set a different icon
setbuffericon "MyBuffer" "heart.circle"
# Reset to default icon
setbuffericon "MyBuffer" ""
- Hide/show buffer
hidebuffer <buffer> <hidden>
Hide or show a buffer in the sidebar. This works for any buffer type.
buffer: Buffer identifier (name or UUID fromgetbuffer)hidden:"1"or"true"to hide,"0"or"false"to show
Example:
# Hide a buffer
hidebuffer "MyBuffer" 1
# Show a buffer
hidebuffer "MyBuffer" 0
# Hide a channel
hidebuffer "#test" true
# Show a channel
hidebuffer "#test" false
- Delete buffer
delbuffer <buffer>
Delete (close) a buffer. This will remove the buffer from the sidebar and discard its messages from the current session.
buffer: Buffer identifier (name or UUID fromgetbuffer)
Notes:
delbuffercannot deletesystemorrawbuffers; attempts will log an error to the Script Debug buffer and do nothing.- For
channelanddirectMessagebuffers this behaves like closing the tab: the channel/DM is closed in the UI but the server state (join/part) is not affected. - For
webbuffers it removes the web tab. -
For
scriptbuffers it removes the script-controlled buffer and its messages; if the script is still loaded it can re-create the buffer. - Set web buffer URL
setweburl <buffer> <url>
Sets the URL for a web buffer.
buffer: Either- A buffer name (web buffer name), or
- A buffer UUID string returned by
getbuffer
url: The website URL to load inside the web buffer (e.g.https://example.com).
If the buffer is not found or is not a web buffer, an error is logged to the Script Debug buffer and the command is otherwise ignored.
Example:
proc open_rete_website {} {
# Create or find a web buffer
createbuffer "Rete Website" web
# Point it to the desired URL
setweburl "Rete Website" "https://rete.chat/"
}
- Add nicklist menu item
addnickmenu <label> <callback>
Adds a custom menu item to the nicklist context menu (right-click on nickname).
label: Menu item label/textcallback: Tcl function name to call when the menu item is clicked. The function must exist whenaddnickmenuis called.
The callback function will be called with three arguments:
proc my_nick_action {bufferId bufferName nick} {
# bufferId - UUID of the buffer where the nick was right-clicked
# bufferName - Name of that buffer (e.g. #channel)
# nick - The nickname that was right-clicked
}
Notes:
- Menu items are automatically removed when the script is unloaded
- On script reload (rehash), callback functions are validated - if a callback function no longer exists, the menu item is automatically removed
- Multiple scripts can add menu items; they will all appear in the context menu
- Menu items appear after the built-in menu items (Whois, Block/Unblock) and before the Control menu (if you’re an op)
Example:
# Define a callback function
proc my_nick_action {bufferId bufferName nick} {
msg $bufferName "Hello $nick from script! (buffer $bufferName / $bufferId)"
}
# Add the menu item
addnickmenu "Say Hello" "my_nick_action"
Dynamic nicklist menu providers
For fully dynamic, per-nick context menus that are computed only when a nick is right-clicked, you can register a nickmenu provider:
setnickmenuprovider <callback>
callback: Tcl function name to call when a nick is right-clicked. The function must exist whensetnickmenuprovideris called.
The provider function will be called with three arguments:
proc my_nickmenu_provider {bufferId bufferName nick} {
# bufferId - UUID of the buffer where the nick was right-clicked
# bufferName - Name of that buffer (e.g. #channel)
# nick - The nickname that was right-clicked
# Return a Tcl list of label/callback pairs:
# {label1 callback1 label2 callback2 ...}
set items {}
lappend items "Whois $nick" my_whois_proc
lappend items "Greet $nick" my_greet_proc
return $items
}
proc my_whois_proc {bufferId bufferName nick} {
putserv "WHOIS $nick"
}
proc my_greet_proc {bufferId bufferName nick} {
msg $bufferName "Hello $nick from dynamic menu (buffer $bufferName / $bufferId)"
}
# Register the provider
setnickmenuprovider my_nickmenu_provider
Notes:
- Multiple scripts may call
setnickmenuprovider; all providers will be invoked and their menu items concatenated. - Providers are called only when the nicklist context menu is opened, not on every UI re-render.
- Providers and their menu items are automatically cleaned up when the owning script is unloaded or rehashed.
Dynamic hover-card (user info tooltip) buttons
You can also add buttons to the hover card that appears when hovering over nicknames (user info tooltip). These are computed dynamically when the tooltip is shown, similar to dynamic nicklist menu providers:
setnickhoverprovider <callback>
callback: Tcl function name to call when the hover card is shown. The function must exist whensetnickhoverprovideris called.
The provider function will be called with three arguments:
proc my_nickhover_provider {bufferId bufferName nick} {
# bufferId - UUID of the buffer context (channel or DM), or "" if unknown
# bufferName - Name of that buffer (e.g. #channel or nick), or "" if unknown
# nick - The nickname being hovered
# Return a Tcl list of label/callback pairs:
# {label1 callback1 label2 callback2 ...}
set items {}
lappend items "Whois" my_whois_proc
lappend items "Greet" my_greet_proc
return $items
}
proc my_whois_proc {bufferId bufferName nick} {
putserv "WHOIS $nick"
}
proc my_greet_proc {bufferId bufferName nick} {
# Send greeting to the current buffer if known, or fall back to using the nick
if {$bufferName ne ""} {
msg $bufferName "Hello $nick from hover card (buffer $bufferName / $bufferId)"
} else {
msg $nick "Hello from hover card"
}
}
# Register the provider
setnickhoverprovider my_nickhover_provider
Notes:
- Providers are called only when the hover card is visible, not for every mouse-move event.
- For nicklist hovers,
bufferId/bufferNamewill be the channel buffer. - For message hovers:
- If the message is in a channel buffer,
bufferId/bufferNamerefer to that channel. - If the message is in a direct-message buffer with this nick, they refer to that DM.
- Otherwise, both may be empty strings (
""), so scripts should handle that case.
- If the message is in a channel buffer,
- Providers and their buttons are automatically cleaned up when the owning script is unloaded or rehashed.
Helper commands (sending commands)
In addition to getters, Tcl scripts can send commands to the IRC server via
the following helpers. All of them operate on the current connection
(IRCStore.transport).
- Raw lines
putserv RAWLINE...
Example:
putserv PRIVMSG #channel :Hello from Tcl
- Basic commands
join #channel ?key?
part #channel ?reason...?
msg target text...
notice target text...
ctcp target command ?params...?
action target text...
topic_set #channel ?newTopic...?
nick newNick
quit ?message...?
mode target modes ?params...?
kick #channel nick ?reason...?
silence ?input...?
These are thin wrappers around Rete’s internal command/transport layer and
behave like the corresponding /join, /part, /msg, /notice, /ctcp,
/me, /topic, /nick, /quit, /mode, /kick and /silence commands
typed in the client, with putserv exposing raw access to the underlying
connection.
- CAP capability management
cap ls
cap values
cap values <capability>
cap enabled
cap req "cap1 cap2 ..."
cap raw "CAP SUBCOMMAND ..."
Manages IRCv3 capabilities (CAP):
cap ls– Returns a list of capabilities the server supports (from CAP LS).cap values– Returns a Tcl dict of all capabilities and their associated values (CAP 302 format). Each entry is{capability {value1 value2 ...}}.cap values <capability>– Returns a list of values for the specified capability, or empty list if the capability has no values or doesn’t exist.cap enabled– Returns a list of capabilities currently enabled/negotiated with the server.cap req "cap1 cap2 ..."– Requests the specified capabilities from the server. The argument should be a space-separated string of capability names.cap raw "CAP SUBCOMMAND ..."– Sends a raw CAP command to the server. For example:cap raw "REQ :foo bar".
Examples:
# List server capabilities
set caps [cap ls]
debug "Server supports: $caps"
# Check if SASL is enabled
set enabled [cap enabled]
if {"sasl" in $enabled} {
debug "SASL is enabled"
}
# Get SASL mechanisms
set mechs [cap values sasl]
debug "SASL mechanisms: $mechs"
# Request a capability
cap req "cap-notify"
# Send raw CAP command
cap raw "LS 302"
Timer commands
Rete provides timer functionality similar to Eggdrop’s timer and utimer
commands, allowing scripts to schedule Tcl commands to execute at regular
intervals.
- Minute-based timers
timer minutes commandName ?count? ?timerName?
Creates a timer that fires every minutes minutes, aligned to the top of the
minute. The first fire occurs at the next minute boundary plus minutes.
minutes: positive number (can be fractional, e.g.,0.5for 30 seconds)commandName: Tcl command or procedure name to executecount(optional): number of times to fire (default: infinite). Use0for infinite repeats.timerName(optional): unique identifier for this timer. If omitted, Rete generates one automatically.
Returns the timer name (useful when auto-generated).
Example:
# Fire every 5 minutes, 10 times
timer 5 my_periodic_task 10 mytask
# Fire every 30 seconds, infinite
timer 0.5 check_status 0
- Second-based timers (utimer)
utimer seconds commandName ?count? ?timerName?
Creates a timer that fires every seconds seconds, starting immediately
(now + seconds).
seconds: positive numbercommandName: Tcl command or procedure name to executecount(optional): number of times to fire (default: infinite). Use0for infinite repeats.timerName(optional): unique identifier for this timer
Returns the timer name.
Example:
# Fire every 10 seconds, 5 times
utimer 10 check_connection 5 conncheck
# Fire once after 30 seconds
utimer 30 delayed_action 1
- List active timers
timers
utimers
Returns a space-separated list of active timers. Each entry contains:
timerName intervalSeconds count nextFireAt command
timerName: the timer’s identifierintervalSeconds: the interval in secondscount: remaining fires (infiniteif unlimited)nextFireAt: ISO-8601 timestamp of next fire-
command: the command that will be executed - Kill timers
killtimer timerName
killutimer timerName
Cancels and removes the specified timer. Returns nothing on success, or an error if the timer doesn’t exist.
Example:
set t [timer 5 my_task 0]
# ... later ...
killtimer $t
Notes:
- Timers are automatically cleaned up when the interpreter is destroyed (e.g., when the IRCStore is deallocated).
- Timer commands execute in the Tcl interpreter context. Errors in the command are logged to the Script Debug buffer but do not stop the timer.
- For
timer(minute-based), the first fire is aligned to the top of the minute. For example, if you create atimer 5at 12:34:20, it will first fire at 12:35:00, then every 5 minutes thereafter. - For
utimer(second-based), the first fire occurssecondsafter creation, then repeats everysecondsthereafter.
The debug command
Scripts can write to the per‑store Script Debug buffer using:
debug ?level? text...
level(optional): one oferror,warning,info,debug.- Default is
infoif no level or an unknown level is given.`
- Default is
text...: free‑form text; all remaining arguments are joined with spaces.
Rete maps debug verbosity levels with script as the theme category and error, warning, debug and infoas theme tags.