# quotebot A simple quotes IRC bot for [Libera.Chat](https://libera.chat). Standard-library Python only — no pip install, no virtualenv. Connects over TLS, joins a channel, and serves quotes from a local SQLite database via `!` commands. ## Run it ```bash python3 bot.py ``` That connects to `irc.libera.chat:6697` as `treesquotes` and joins `#r.trees`. To override anything, copy the example config and source it first: ```bash cp config.example.env config.env # config.env is gitignored # edit config.env as needed set -a; source config.env; set +a python3 bot.py ``` ## Commands (in-channel) | Command | Does | |--------------------|-------------------------------------------| | `!quote` | Random quote | | `!quote ` | Quote by number | | `!addquote ` | Store a new quote, returns its id | | `!grabquote [user]`| Grab the last line a user said (`!grab` alias); no user = last speaker | | `!delquote ` | Delete a quote | | `!search ` | First quote containing a substring | | `!quotecount` | How many quotes are stored | | `!help` | List commands | ## Notes - Quotes live in `quotes.db` (SQLite, created on first run, gitignored). - `!grabquote` reads an in-memory buffer of each user's last channel line; that buffer is per-session and resets on reconnect. Grabbed lines are stored as ` message`. Bot commands are never recorded, so you can't grab one. - The bot auto-reconnects with exponential backoff and answers `PING`. - If the nick is taken it appends `_` and retries. - A NickServ password, if set via `IRC_NICKSERV_PASS`, is sent on connect — keep it in the environment, never in the repo. - Outbound messages are spaced by `QUOTEBOT_SEND_DELAY` seconds to avoid tripping Libera's flood limits. ## Registering the nick (recommended) Libera lets unregistered bots connect, but channels can be set to block unregistered users. To register `treesquotes`: 1. Connect once, then `/msg NickServ REGISTER `. 2. Confirm via the emailed code. 3. Put the password in `config.env` as `IRC_NICKSERV_PASS` and restart.