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(command, action, opts?) -- first word matches literallyrune.alias.regex(pattern, action, opts?) -- Go regexp on the full input lineBoth constructors return a handle and accept the common options.
Matching
Section titled “Matching”Regex aliases are checked first, in priority order; if none match,
the first word of the input is looked up among exact aliases. 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(command, action, opts?) -> handlecommand(string) — matched literally against the first word of the input. Registering the same word 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 command word.opts(table, optional) — common options.
rune.alias.exact("heal", function(args, ctx) rune.send("cast heal " .. (args ~= "" and args or "self"))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).
Managing
Section titled “Managing”Standard registry management applies:
rune.alias.enable/disable/remove(name), .list(), .count(),
.clear(), .remove_group(group) — see
Registries. /aliases lists everything.
Related: Aliases guide · rune.trigger · rune.regex · Core