> ## Documentation Index
> Fetch the complete documentation index at: https://docs.flumeirc.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Scripting Overview

> Extend Flume with Lua and Python scripts

Flume has a dual scripting engine supporting both **Lua 5.4** and **Python 3.10+**. Both languages share the same API surface — a script written in Lua is trivially portable to Python.

## How It Works

Scripts register event handlers and custom commands through the `flume` module. When IRC events occur, Flume calls your handlers. Scripts can also queue actions (send messages, print to buffers, show notifications) that Flume processes on the next tick.

## Script Directories

All scripts live under `~/.local/share/flume/scripts/`:

| Directory          | Purpose                                        |
| ------------------ | ---------------------------------------------- |
| `lua/autoload/`    | Lua scripts loaded automatically on startup    |
| `python/autoload/` | Python scripts loaded automatically on startup |
| `available/`       | Installed but not auto-loaded                  |
| `generated/`       | Created by `/generate script`                  |

## Managing Scripts

```
/script load highlight       # load by name from scripts dirs
/script load /path/to/my.lua # load by path
/script unload highlight     # unload
/script reload highlight     # reload from disk
/script list                 # list loaded scripts and commands
```

## Your First Script

**Lua** (`~/.local/share/flume/scripts/lua/autoload/hello.lua`):

```lua theme={null}
flume.event.on("message", function(e)
    if e.text:find("!hello") then
        flume.channel.say(e.server, e.channel, "Hello, " .. e.nick .. "!")
    end
end)
```

**Python** (`~/.local/share/flume/scripts/python/autoload/hello.py`):

```python theme={null}
import flume

def on_message(e):
    if "!hello" in e.get("text", ""):
        flume.channel.say(e["server"], e["channel"], f"Hello, {e['nick']}!")

flume.event.on("message", on_message)
```

## Don't Know How to Code?

Use `/generate script` to have an AI write the script for you:

```
/generate script respond with a greeting when someone says hello
```

See [LLM Generation](/commands/generate) for setup.
