Skip to content

Lesson 7: Create an alias integration

Goal: a /hi command that runs your /slap alias. (/slap is one of the default aliases; any enabled alias of yours works.)

--! name: Alias bridge
--! description: /hi <nick> runs your slap alias
--! api: 1
--! permissions: aliases
swizzin.command("hi", function(ctx, args)
if ctx.target == nil or args[1] == nil then return end
swizzin.alias("slap", args[1], ctx.network, ctx.target)
end, "Run the slap alias on a nick")

swizzin.alias(name, args?, network?, target?) runs one of your own native aliases through the normal command path, with the same expansion, credential checks and nesting limits as typed input. target is the conversation it runs in (used for $chan).

  • Needs the aliases permission.
  • Only enabled aliases without the “Allow raw and connection commands” option qualify, so a script can never reach /quit, /quote, /server or connection control.
  • The result may only be chat lines, joins and parts, at most 10 lines, and only while the network is connected.
  • If an alias has the same name as a script command, the alias wins.

/hi Sam in a channel runs the slap alias for Sam there.

  • Refusals are written to the Console with the reason. Check that the alias exists, is enabled, and does not use raw or connection commands.
  • See Native alias integration.