rune.alias
Aliases match your input and transform or expand it before it reaches the server. For a task-oriented introduction, see Aliases.
Quick reference
Section titled “Quick reference”rune.alias.exact(phrase, action, opts?) -- leading command phrase matches literallyrune.alias.regex(pattern, action, opts?) -- Go regexp on the full input linerune.alias.get(name) -- the alias's handle, or nilBoth constructors return a handle and accept
the common options. They differ in how they
are named: an exact alias is named for its
normalized phrase, so rune.alias.disable("chat off") addresses it and a
name in opts is ignored with a notice. A regex alias is a matcher
rather than a phrase, and several can match one line, so it takes name
as usual.
Matching
Section titled “Matching”Regex aliases are checked first, in priority order. If none match, an
exact alias can match one or more complete words at the beginning of what
you type. When more than one matches, the longest active phrase wins, so
"chat off" takes precedence over "chat". Only one alias fires per
command. A string result — whether from a string action or returned by a
function — is fed back through
rune.send, so aliases can expand to other
aliases; a depth limit catches loops.
rune.alias.exact
Section titled “rune.alias.exact”rune.alias.exact(phrase, action, opts?) -> handlephrase(string) — one or more words matched literally at the start of the input. Whitespace separates words and is normalized, sochat offalso matcheschat off. Registering the same normalized phrase again replaces the previous exact alias.action(string | function) — an expansion string (trailing arguments are appended: withrune.alias.exact("g", "get"), typingg swordsendsget sword), orfunction(args, ctx)whereargsis everything after the matched phrase.opts(table, optional) — common options.
rune.alias.exact("chat off", function(args, ctx) rune.echo("chatlog: off" .. (args ~= "" and " (" .. args .. ")" or ""))end)rune.alias.regex
Section titled “rune.alias.regex”rune.alias.regex(pattern, action, opts?) -> handlepattern(string) — Go regexp (RE2, not Lua patterns), matched against the full input line. Validated at registration; a bad pattern raises immediately.action(string | function) — a command string (%1…%nsubstituted from captures), orfunction(matches, ctx)wherematchesis the capture array.opts(table, optional) — common options.
-- "give 5 coins to bob" → sends "give coins bob" 5 timesrune.alias.regex("^give\\s+(\\d+)\\s+(\\w+)\\s+to\\s+(\\w+)", function(m) for i = 1, tonumber(m[1]) do rune.send("give " .. m[2] .. " " .. m[3]) endend)Actions and return values
Section titled “Actions and return values”A string action is the replacement command. A function action receives
(args, ctx) for exact aliases or (matches, ctx) for regex aliases —
see the context object — and
its return value controls what happens next: return a string to have
it processed and sent in place of the input, or return nothing to
consume the input entirely (the function already did the work).
History expansion runs only on commands typed into
Rune’s normal input, before aliases. Text sent with rune.send, including the
result of an alias, does not go through history expansion again.
Managing
Section titled “Managing”Standard registry management applies:
rune.alias.get/enable/disable/remove(name), .list(), .count(),
.clear(), .remove_group(group). See
Registries. /aliases lists everything.
Related: Aliases guide · rune.trigger · rune.regex · Core