Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/AresChat/sb0t/llms.txt

Use this file to discover all available pages before exploring further.

Link is a static singleton that exposes the Hub/Leaf linking subsystem to scripts. When sb0t is configured in hub mode, remote servers connect to it as leaves and their users appear in the shared room. When configured in leaf mode, this server connects to a hub and mirrors its user population. Link lets scripts inspect the current connection state, initiate or terminate connections, and iterate the leaf list (hub mode only). All properties return safe defaults — null, -1, or false — when the server is not currently linked.
Calling Link.connect() while Link.linked is already true will be silently ignored. Always call Link.disconnect() and confirm the state has changed before attempting a new connection.

Properties

true if this server is currently connected to a hub (leaf mode). false when running standalone or acting as a hub. Read-only.
The display name of the hub this server is connected to. Returns null when not linked. Read-only.
The external IP address of the hub, as a dotted-decimal string. Returns null when not linked. Read-only.
The port on which the hub is listening. Returns -1 when not linked. Read-only.
A fully-formed arlnk:// deep-link that resolves to the hub room. Returns null when not linked. Read-only.

Methods

Instructs the server to connect to a hub identified by address. The address may be an IP:port string or an arlnk:// hashlink.
ParameterTypeDescription
addressstringThe hub address or arlnk:// hashlink to connect to.
Disconnects from the currently connected hub. All leaf-user ghost entries are removed from the local user list. Has no effect when not linked.
Iterates over all leaf servers currently connected to this hub and calls fn(leaf) for each one. Only produces results when this server is operating in hub mode and has active leaf connections. The leaf argument is a Leaf object.
ParameterTypeDescription
fnfunctionCallback invoked with a Leaf object for each connected leaf.
Looks up a single leaf by name and returns its Leaf object, or null if no matching leaf is found. The lookup first tries an exact match, then falls back to a prefix match.
ParameterTypeDescription
namestringThe leaf server name (or name prefix) to search for.
Returns: Leaf object, or null.

Leaf Object

Each Leaf object represents one connected leaf server and provides messaging and user-iteration capabilities.

Leaf Properties

leaf.name
string
The display name of the leaf server. Read-only.
leaf.externalIp
string
The external IP address of the leaf server. Read-only.
leaf.port
int
The port the leaf server is listening on. Read-only.
A fully-formed arlnk:// deep-link that resolves to this leaf’s room. Read-only.

Leaf Methods

leaf.users(fn)
function
Iterates over every user connected to this leaf and calls fn(user) for each one. The user argument is a full User object.
ParameterTypeDescription
fnfunctionCallback invoked with a User object for each user on the leaf.
leaf.user(name)
function
Finds a single user on this leaf by name. Tries an exact match first, then a prefix match. Returns the User object or null.
ParameterTypeDescription
namestringThe username (or name prefix) to search for.
leaf.print(text)
function
Sends a system message to all users on this leaf. Pass an optional first argument as a virtual room number to restrict delivery to users in that vroom.
ParameterTypeDescription
textstringThe system message to send.
leaf.printAdmins(level, text)
function
Sends a system message only to users on this leaf whose admin level is at or above level. If only one argument is provided, defaults to Moderator level (1) and above.
ParameterTypeDescription
levelintMinimum admin level: 1=Mod, 2=Admin, 3=Host.
textstringThe message to deliver.
leaf.sendText(sender, text)
function
Broadcasts a public chat line to all users on this leaf, attributed to sender.
ParameterTypeDescription
senderstringName to attribute the message to.
textstringMessage content.
leaf.sendEmote(sender, text)
function
Broadcasts an emote action line to all users on this leaf, attributed to sender.
ParameterTypeDescription
senderstringName to attribute the emote to.
textstringEmote content.
leaf.scribble(sender, img)
function
Sends a scribble drawing to all users on this leaf. The first argument can be either a JSScribbleImage (sender defaults to Room.botName) or a sender name string followed by a JSScribbleImage.
ParameterTypeDescription
senderstring | JSScribbleImageSender name, or the scribble image itself.
imgJSScribbleImageScribble image (only required when sender is a string).

Examples

function onTimer() {
  if (Link.linked) {
    print("Connected to hub: " + Link.name + " (" + Link.externalIp + ":" + Link.port + ")");
  } else {
    print("Not currently linked to any hub.");
  }
}

Build docs developers (and LLMs) love