Skip to content

rune.alias

Aliases match your input and transform or expand it before it reaches the server. For a task-oriented introduction, see Aliases.

rune.alias.exact(phrase, action, opts?) -- leading command phrase matches literally
rune.alias.regex(pattern, action, opts?) -- Go regexp on the full input line
rune.alias.get(name) -- the alias's handle, or nil

Both 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.

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(phrase, action, opts?) -> handle
  • phrase (string) — one or more words matched literally at the start of the input. Whitespace separates words and is normalized, so chat off also matches chat off. Registering the same normalized phrase again replaces the previous exact alias.
  • action (string | function) — an expansion string (trailing arguments are appended: with rune.alias.exact("g", "get"), typing g sword sends get sword), or function(args, ctx) where args is 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(pattern, action, opts?) -> handle
  • pattern (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%n substituted from captures), or function(matches, ctx) where matches is the capture array.
  • opts (table, optional) — common options.
-- "give 5 coins to bob" → sends "give coins bob" 5 times
rune.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])
end
end)

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.

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