2.3 KiB
2.3 KiB
quotebot
A simple quotes IRC bot for 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
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:
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 <id> |
Quote by number |
!addquote <text> |
Store a new quote, returns its id |
!grabquote [user] |
Grab the last line a user said (!grab alias); no user = last speaker |
!delquote <id> |
Delete a quote |
!search <term> |
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). !grabquotereads 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<nick> 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_DELAYseconds 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:
- Connect once, then
/msg NickServ REGISTER <password> <email>. - Confirm via the emailed code.
- Put the password in
config.envasIRC_NICKSERV_PASSand restart.