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: aliasesswizzin.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")What it does
Section titled “What it does”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).
Rules to know
Section titled “Rules to know”- Needs the
aliasespermission. - Only enabled aliases without the “Allow raw and connection commands” option qualify, so a script can never reach
/quit,/quote,/serveror 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.
Expected result
Section titled “Expected result”/hi Sam in a channel runs the slap alias for Sam there.
Troubleshooting
Section titled “Troubleshooting”- 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.