Add multi-network support
Connect to several IRC networks at once. The config file gains optional `[network]` section headers: keys before the first header are shared defaults, and each section defines one network that inherits and overrides them. A file with no sections is a single network exactly as before, so existing configs are unaffected. main spawns one supervisor thread per network, each with its own connect/reconnect/backoff loop, so a failure on one network never disturbs the others. The blocking Bot/Connection are reused unchanged — no async runtime, no new dependencies. With more than one network, wire logs are tagged with the section name; a lone network stays unprefixed.
This commit is contained in:
parent
ab02a5436e
commit
b9e95430f5
4 changed files with 318 additions and 74 deletions
35
README.md
35
README.md
|
|
@ -9,7 +9,7 @@ protocol layer built to the [modern IRC client spec](https://modern.ircdocs.hors
|
|||
|---------------|------------------|-----------------------------------------------------------|
|
||||
| `src/irc.rs` | protocol + I/O | Parse/serialize IRC messages (incl. IRCv3 tags), TCP transport |
|
||||
| `src/bot.rs` | behavior | Registration, event loop, command handling |
|
||||
| `src/main.rs` | wiring | Config from env vars, connect/reconnect supervisor |
|
||||
| `src/main.rs` | wiring | Layered config, one connect/reconnect supervisor thread per network |
|
||||
|
||||
The layers are deliberately separable: `irc.rs` knows nothing about the bot, and
|
||||
`bot.rs` knows nothing about how the process is launched.
|
||||
|
|
@ -40,8 +40,37 @@ RUSTBOT_CONFIG=/etc/rustbot.conf cargo run
|
|||
```
|
||||
|
||||
Config file keys: `server`, `port`, `tls`, `nick`, `user`, `realname`,
|
||||
`channels` (comma/space-separated), `prefix`, `password`, `sasl_user`, `sasl_pass`.
|
||||
Whole-line `#`/`;` comments only — inline comments would clash with channel `#`s.
|
||||
`channels` (comma/space-separated), `prefix`, `password`, `sasl_user`,
|
||||
`sasl_pass`, and `name` (a network's log label). Whole-line `#`/`;` comments
|
||||
only — inline comments would clash with channel `#`s.
|
||||
|
||||
### Multiple networks
|
||||
|
||||
Group keys under `[name]` section headers to connect to several networks at
|
||||
once — one supervisor thread each, with independent reconnect/backoff. Keys
|
||||
*before* the first header are shared defaults every network inherits; each
|
||||
section overrides them. A file with no headers is a single network (the
|
||||
historical behaviour), and its logs stay unprefixed.
|
||||
|
||||
```ini
|
||||
# shared defaults, inherited by every network below
|
||||
nick = rubot
|
||||
realname = rubot
|
||||
|
||||
[tchatou]
|
||||
server = irc.tchatou.fr
|
||||
tls = true
|
||||
channels = #devs
|
||||
|
||||
[libera]
|
||||
server = irc.libera.chat
|
||||
tls = true
|
||||
channels = #rust, #rust-beginners
|
||||
nick = rubot_ # override just for this network
|
||||
```
|
||||
|
||||
With more than one network, each network's log lines are tagged with its
|
||||
section name (`[libera] << …`) so the interleaved output stays readable.
|
||||
|
||||
Environment overrides: `IRC_SERVER`, `IRC_PORT`, `IRC_TLS`, `IRC_NICK`,
|
||||
`IRC_REALNAME`, `IRC_CHANNELS`, `IRC_PREFIX`, `IRC_PASSWORD`,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue