Skip to content

Creating a script

Comment lines at the top of a script describe it:

--! name: Display name
--! description: One line
--! api: 1
--! permissions: send, channels
  • name and description are shown in the Script Manager.
  • api is the SwizzScript API version the script was written for. A script written for a newer API than your build is refused with a clear message.
  • permissions lists what the script needs: any of send, channels, notify, storage, aliases.
--! name: Hello
--! api: 1
--! permissions: send
swizzin.on("message", function(e)
if e.text == "!hello" then
swizzin.send(e.target, "Hello, " .. e.nick .. "!")
end
end)
  1. Open Scripts, choose New…, and paste or write your script.
  2. Save, then turn the script On.
  3. Read the permissions the panel lists and choose Approve and allow.
  4. Check the Console for errors.

With the storage permission:

local n = (swizzin.data.get("count") or 0) + 1
swizzin.data.set("count", n)
swizzin.log("run number", n)

Values are strings, numbers or booleans. Each script has its own file and cannot read another script’s data. Limits: 64 keys, values up to 4096 characters, 64 KB per script.

  • The top level of a script must finish within 1 second; do work in handlers.
  • Each callback must finish within 250 ms.
  • A script is stopped after 10 failures in a row.
  • Text you send must be a single line of 1 to 2000 characters, and text that looks like an authentication command is refused.