API reference (API version 1)
Everything SwizzinIRC-specific is under the global table swizzin. Where a network argument is accepted, it is a network id (a number) or an exact network name (a string). A name that matches no network, or more than one, is refused.
Registration
Section titled “Registration”| Function | Description |
|---|---|
swizzin.on(event, fn, opts?) |
Handle an event. opts is {own = false, playback = false}. See IRC events |
swizzin.command(name, fn, description?) |
Add /name. fn(ctx, args). See Registering commands |
Actions
Section titled “Actions”Actions need the permission shown and a network context: the event or command that is running, or an explicit network argument. Each action counts against the send-rate limit.
| Function | Needs | Notes |
|---|---|---|
swizzin.send(target, text, network?) |
send |
Message. target is a channel or nickname without spaces; text is 1 to 2000 characters on one line |
swizzin.notice(target, text, network?) |
send |
NOTICE |
swizzin.action(target, text, network?) |
send |
The text of a /me |
swizzin.join(channel, key?, network?) |
channels |
|
swizzin.part(channel, reason?, network?) |
channels |
|
swizzin.alias(name, args?, network?, target?) |
aliases |
Runs one of your own native aliases. See Native alias integration |
swizzin.notify(text) |
notify |
A notification labelled with the script’s name (at most 200 characters) |
Refused regardless of permission: text that looks like an authentication command to a services bot (IDENTIFY, LOGIN, PASS, AUTH, REGISTER, OPER and similar) and any message to a ZNC *module pseudo-user. Scripts cannot send raw IRC lines.
Information
Section titled “Information”| Function | Returns |
|---|---|
swizzin.networks() |
A list of {id, name, state, nick} |
swizzin.me(network?) |
Your nickname on that network, or nil |
swizzin.api_version, swizzin.app |
Version information |
swizzin.wildmatch(pattern, text) |
true if the text matches (* and ?, case-insensitive) |
swizzin.strip(text) |
The text without IRC colours and formatting |
Console
Section titled “Console”| Function | Description |
|---|---|
swizzin.log(...) |
Write to the Script Console |
swizzin.warn(text) |
Write a warning |
swizzin.error(text) |
Write an error |
print(...) is the same as swizzin.log(...).
Timers
Section titled “Timers”swizzin.timer.after(ms, fn), swizzin.timer.every(ms, fn) and swizzin.timer.cancel(id). See Timers.
Saved data (needs storage)
Section titled “Saved data (needs storage)”| Function | Description |
|---|---|
swizzin.data.get(key) |
Read a value |
swizzin.data.set(key, value) |
Store a string, number or boolean |
swizzin.data.keys() |
List keys |
At most 64 keys, values up to 4096 characters, and 64 KB per script.
Errors
Section titled “Errors”An error inside a callback is written to the Console with the script name and line, and the script keeps running. After 10 failures in a row the script is stopped.