Skip to main content

Limits and safety

Plugins are other people's code running inside a chat client that is logged into your Twitch account. This page is what stops that being a bad idea.

The shape of it​

Chattscript is not JavaScript with the dangerous parts removed. It is its own language with a tokeniser, a parser and an interpreter written for Chattler, and the only things a script can name are its own variables and the builtins.

There is no import, no require, no eval, no file paths, no URLs, no way to reach the page the app is drawn with. Writing fetch, window, document or account in a script gives you nothing, because they are just names that were never defined.

What a plugin cannot do​

  • Moderate. No timeouts, bans, deletions, warnings, chat-mode changes or shoutouts.
  • Speak. No messages, whispers or replies.
  • Use your login. It cannot read your token, and there is no API for it to call with one.
  • Reach the internet. No requests, of any kind, to anywhere.
  • Touch your files. It cannot read or write anything, including its own file.
  • See the rest of the app. Not your settings, your channels, your history or your other plugins.

A plugin sees the event it was handed. That is all.

The budgets​

Every time an event fires, each listening plugin gets its own budget:

LimitValue
Steps per run20,000
Time per run12 milliseconds
Turns of one loop1,000
Function call depth16
Longest text8,192 characters
Longest list512 items
Counters and notes per plugin200 keys, 120 timestamps each
Alerts per plugin6 per 10 seconds
Remembered log lines60

Go past the first two and the run stops with an error naming the line. The plugin is not disabled for it - the next event gets a fresh budget - so a plugin that is too slow only ever costs you a few milliseconds.

This is why an accidental infinite loop is harmless:

on message do
let n = 0
repeat 1000 times do
repeat 1000 times do
set n = n + 1
end
end
end

That asks for a million turns. It stops after 20,000 steps, in about two milliseconds, and writes This plugin did too much in one go and was stopped to the plugin's log.

When plugins run​

Plugin code runs on the same thread as the rest of the app, right after Chattler has finished its own work for that event. The message event is the one to be careful with, because a big chat sends thousands a minute - but with a 12ms ceiling, the worst a plugin can do is use a slice of one frame.

Chattler also skips the work entirely when nothing is listening: if no enabled plugin has an on message block, no message event is ever built.

The five-second events (speed, automod_waiting, tick) only run while the window is visible.

Failing plugins​

  • A plugin that does not compile is switched off, with the line number shown in Settings.
  • A plugin that fails while running has the error written to its log, and keeps going.
  • A plugin that fails ten times is switched off, with a message saying so. Fix it, reload, and turn it back on.

What is still worth checking​

The sandbox stops a plugin harming you. It does not stop one being wrong, noisy, or written by somebody having a laugh. A plugin can:

  • raise alerts about the wrong people, or at the wrong time
  • put someone's chat message on your screen in an alert, which matters if you stream
  • be named one thing and do another

So: read the file before you enable it. Plugins are short and plain on purpose, and the description at the top is written by the same person who wrote the rest, so trust the code over the description.

Streaming

Streamer mode silences plugin chimes and desktop notifications along with everything else. Alerts still appear in the app, and an alert can contain a chat message, so think about which plugins are on before you go live.

Themes​

Themes carry no code at all. A .theme file is a name, a base, and a list of colours - there is nothing in the format that can run. The worst a bad theme can do is look terrible, and you switch back in Settings.