Add !changelog command, reduce GITLOG_MAX and CHANGELOG_MAX (0.38.0)
- Added !changelog [count] command: displays the latest changelog entries from CHANGELOG.md. Defaults to 5 entries (CHANGELOG_COUNT), accepts 1-10 as count. Each entry title is sent as a separate IRC message with a 200ms delay to avoid IRC server flood protection. - Reduced GITLOG_MAX and CHANGELOG_MAX from 20 to 10. - Rewrote cmd_changelog to use getline() for robust line reading and isdigit() checks for reliable date pattern detection. - Updated !help to list !changelog. - Updated README.md with !changelog documentation and corrected max values. - Added CHANGELOG.md entry for v0.38.0. - Version bumped to 0.38.0.
This commit is contained in:
parent
caa70ee448
commit
e254b64745
3 changed files with 200 additions and 134 deletions
261
README.md
261
README.md
|
|
@ -53,17 +53,17 @@ make CC=clang CFLAGS="-O2 -Wall -Wextra"
|
|||
|
||||
### Options
|
||||
|
||||
| Option | Description |
|
||||
|---|---|
|
||||
| `-ssl` | Enable TLS (auto-enabled on ports 6697/7000) |
|
||||
| `-noverify` | Skip TLS certificate verification |
|
||||
| `-server <host>` | IRC server (default: `irc.libera.chat`) |
|
||||
| `-port <p>` | Port (default: `6697`) |
|
||||
| `-pass <p>` | Server password |
|
||||
| `-nick <n>` | Nickname (default: `zynk`) |
|
||||
| `-join <c>` | Auto-join channels, comma-separated (default: `#zynk`) |
|
||||
| `-opencode <p>` | Path to opencode binary (default: `/usr/bin/opencode`) |
|
||||
| `-h` | Show help |
|
||||
| Option | Description |
|
||||
|------------------|--------------------------------------------------------|
|
||||
| `-ssl` | Enable TLS (auto-enabled on ports 6697/7000) |
|
||||
| `-noverify` | Skip TLS certificate verification |
|
||||
| `-server <host>` | IRC server (default: `irc.libera.chat`) |
|
||||
| `-port <p>` | Port (default: `6697`) |
|
||||
| `-pass <p>` | Server password |
|
||||
| `-nick <n>` | Nickname (default: `zynk`) |
|
||||
| `-join <c>` | Auto-join channels, comma-separated (default: `#zynk`) |
|
||||
| `-opencode <p>` | Path to opencode binary (default: `/usr/bin/opencode`) |
|
||||
| `-h` | Show help |
|
||||
|
||||
### Example
|
||||
|
||||
|
|
@ -75,40 +75,41 @@ make CC=clang CFLAGS="-O2 -Wall -Wextra"
|
|||
|
||||
### General
|
||||
|
||||
| Command | Description |
|
||||
|---|---|
|
||||
| `!help` | List all available commands |
|
||||
| `!version` | Show the bot version |
|
||||
| `!ping` | Responds with `pong` |
|
||||
| `!uptime` | Show bot uptime |
|
||||
| Command | Description |
|
||||
|------------------|------------------------------|
|
||||
| `!help` | List all available commands |
|
||||
| `!version` | Show the bot version |
|
||||
| `!ping` | Responds with `pong` |
|
||||
| `!uptime` | Show bot uptime |
|
||||
| `!quit` / `!die` | Shut down the bot (ops only) |
|
||||
|
||||
### Key-Value Store
|
||||
|
||||
| Command | Description |
|
||||
|---|---|
|
||||
| `zynk <key>` | Look up a stored value |
|
||||
| `zynk <key> = <value>` | Store a value (key is lowercased) |
|
||||
| Command | Description |
|
||||
|-------------------------|-----------------------------------------------|
|
||||
| `zynk <key>` | Look up a stored value |
|
||||
| `zynk <key> = <value>` | Store a value (key is lowercased) |
|
||||
| `zynk! <key> = <value>` | Overwrite an existing value (ops in channels) |
|
||||
| `zynk` | Get a random stored entry |
|
||||
| `zynk` | Get a random stored entry |
|
||||
|
||||
### Weather & Finance
|
||||
|
||||
| Command | Description |
|
||||
|---|---|
|
||||
| `!weather [city]` | Current weather (default: Berlin) |
|
||||
| `!forecast [city]` | 3-day forecast (default: Berlin) |
|
||||
| Command | Description |
|
||||
|-------------------------------|---------------------------------------------------------|
|
||||
| `!weather [city]` | Current weather (default: Berlin) |
|
||||
| `!forecast [city]` | 3-day forecast (default: Berlin) |
|
||||
| `!stock <SYMBOL>[,SYMBOL...]` | Stock quotes, up to 3 symbols (e.g. `!stock AAPL,MSFT`) |
|
||||
|
||||
### Utilities
|
||||
|
||||
| Command | Description |
|
||||
|---|---|
|
||||
| `!calc <expression>` | Evaluate math (see below) |
|
||||
| `!time [timezone]` | Show current time (see below) |
|
||||
| `!seen <nick>` | Check when a user was last seen |
|
||||
| `!tell <nick> <message>` | Leave a message for an offline user |
|
||||
| `!gitlog [count]` | Show recent git commits (default: 5, max: 20) |
|
||||
| Command | Description |
|
||||
|--------------------------|-----------------------------------------------|
|
||||
| `!calc <expression>` | Evaluate math (see below) |
|
||||
| `!time [timezone]` | Show current time (see below) |
|
||||
| `!seen <nick>` | Check when a user was last seen |
|
||||
| `!tell <nick> <message>` | Leave a message for an offline user |
|
||||
| `!gitlog [count]` | Show recent git commits (default: 5, max: 10) |
|
||||
| `!changelog [count]` | Show changelog entries (default: 5, max: 10) |
|
||||
|
||||
#### Time (`!time`)
|
||||
|
||||
|
|
@ -118,63 +119,63 @@ Shows the current date and time. Without arguments, displays the bot's local tim
|
|||
|
||||
**Examples:**
|
||||
|
||||
| Command | Description |
|
||||
|---|---|
|
||||
| `!time` | Bot's local time |
|
||||
| `!time UTC` | Current UTC time |
|
||||
| `!time US/Eastern` | US Eastern time |
|
||||
| `!time US/Pacific` | US Pacific time |
|
||||
| `!time Europe/Berlin` | Central European time |
|
||||
| `!time Europe/London` | UK time |
|
||||
| `!time Asia/Tokyo` | Japan time |
|
||||
| Command | Description |
|
||||
|--------------------------|-------------------------|
|
||||
| `!time` | Bot's local time |
|
||||
| `!time UTC` | Current UTC time |
|
||||
| `!time US/Eastern` | US Eastern time |
|
||||
| `!time US/Pacific` | US Pacific time |
|
||||
| `!time Europe/Berlin` | Central European time |
|
||||
| `!time Europe/London` | UK time |
|
||||
| `!time Asia/Tokyo` | Japan time |
|
||||
| `!time Australia/Sydney` | Australian Eastern time |
|
||||
|
||||
If the system has `tzdata` installed, any IANA/Olson timezone name works. Otherwise, the bot falls back to a built-in table with the following timezones:
|
||||
|
||||
**Built-in timezones (no tzdata required):**
|
||||
|
||||
| Timezone | Region | Offset | DST |
|
||||
|---|---|---|---|
|
||||
| `UTC` / `GMT` | Global | +0 | No |
|
||||
| `EST` / `CST` / `MST` / `PST` / `HST` | US (fixed) | -5 to -10 | No |
|
||||
| `US/Eastern` | US Eastern | -5 / -4 | Yes |
|
||||
| `US/Central` | US Central | -6 / -5 | Yes |
|
||||
| `US/Mountain` | US Mountain | -7 / -6 | Yes |
|
||||
| `US/Pacific` | US Pacific | -8 / -7 | Yes |
|
||||
| `US/Alaska` | US Alaska | -9 / -8 | Yes |
|
||||
| `US/Honolulu` | US Hawaii | -10 | No |
|
||||
| `Canada/Toronto` | Canada Eastern | -5 / -4 | Yes |
|
||||
| `Canada/Vancouver` | Canada Pacific | -8 / -7 | Yes |
|
||||
| `America/Sao_Paulo` | Brazil | -3 / -2 | Yes |
|
||||
| `America/Mexico_City` | Mexico | -6 / -5 | Yes |
|
||||
| `America/Argentina/Buenos_Aires` | Argentina | -3 | No |
|
||||
| `Europe/London` | UK | 0 / +1 | Yes |
|
||||
| `Europe/Berlin` | Central Europe | +1 / +2 | Yes |
|
||||
| `Europe/Paris` | France | +1 / +2 | Yes |
|
||||
| `Europe/Moscow` | Russia | +3 | No |
|
||||
| `Europe/Istanbul` | Turkey | +3 | No |
|
||||
| `Asia/Tokyo` | Japan | +9 | No |
|
||||
| `Asia/Shanghai` | China | +8 | No |
|
||||
| `Asia/Kolkata` | India | +5:30 | No |
|
||||
| `Asia/Dubai` | UAE | +4 | No |
|
||||
| `Asia/Singapore` | Singapore | +8 | No |
|
||||
| `Asia/Seoul` | South Korea | +9 | No |
|
||||
| `Asia/Hong_Kong` | Hong Kong | +8 | No |
|
||||
| `Asia/Taipei` | Taiwan | +8 | No |
|
||||
| `Australia/Sydney` | Australia Eastern | +10 / +11 | Yes |
|
||||
| `Australia/Melbourne` | Australia Eastern | +10 / +11 | Yes |
|
||||
| `Australia/Brisbane` | Australia Eastern | +10 | No |
|
||||
| `Australia/Perth` | Australia Western | +8 | No |
|
||||
| `Australia/Adelaide` | Australia Central | +9:30 / +10:30 | Yes |
|
||||
| `Australia/Darwin` | Australia Central | +9:30 | No |
|
||||
| `Pacific/Auckland` | New Zealand | +12 / +13 | Yes |
|
||||
| `Pacific/Honolulu` | Hawaii | -10 | No |
|
||||
| `Pacific/Fiji` | Fiji | +12 / +13 | Yes |
|
||||
| `Africa/Cairo` | Egypt | +2 | No |
|
||||
| `Africa/Johannesburg` | South Africa | +2 | No |
|
||||
| `Africa/Lagos` | West Africa | +1 | No |
|
||||
| `Africa/Nairobi` | East Africa | +3 | No |
|
||||
| `Atlantic/Reykjavik` | Iceland | +0 | No |
|
||||
| Timezone | Region | Offset | DST |
|
||||
|---------------------------------------|-------------------|----------------|-----|
|
||||
| `UTC` / `GMT` | Global | +0 | No |
|
||||
| `EST` / `CST` / `MST` / `PST` / `HST` | US (fixed) | -5 to -10 | No |
|
||||
| `US/Eastern` | US Eastern | -5 / -4 | Yes |
|
||||
| `US/Central` | US Central | -6 / -5 | Yes |
|
||||
| `US/Mountain` | US Mountain | -7 / -6 | Yes |
|
||||
| `US/Pacific` | US Pacific | -8 / -7 | Yes |
|
||||
| `US/Alaska` | US Alaska | -9 / -8 | Yes |
|
||||
| `US/Honolulu` | US Hawaii | -10 | No |
|
||||
| `Canada/Toronto` | Canada Eastern | -5 / -4 | Yes |
|
||||
| `Canada/Vancouver` | Canada Pacific | -8 / -7 | Yes |
|
||||
| `America/Sao_Paulo` | Brazil | -3 / -2 | Yes |
|
||||
| `America/Mexico_City` | Mexico | -6 / -5 | Yes |
|
||||
| `America/Argentina/Buenos_Aires` | Argentina | -3 | No |
|
||||
| `Europe/London` | UK | 0 / +1 | Yes |
|
||||
| `Europe/Berlin` | Central Europe | +1 / +2 | Yes |
|
||||
| `Europe/Paris` | France | +1 / +2 | Yes |
|
||||
| `Europe/Moscow` | Russia | +3 | No |
|
||||
| `Europe/Istanbul` | Turkey | +3 | No |
|
||||
| `Asia/Tokyo` | Japan | +9 | No |
|
||||
| `Asia/Shanghai` | China | +8 | No |
|
||||
| `Asia/Kolkata` | India | +5:30 | No |
|
||||
| `Asia/Dubai` | UAE | +4 | No |
|
||||
| `Asia/Singapore` | Singapore | +8 | No |
|
||||
| `Asia/Seoul` | South Korea | +9 | No |
|
||||
| `Asia/Hong_Kong` | Hong Kong | +8 | No |
|
||||
| `Asia/Taipei` | Taiwan | +8 | No |
|
||||
| `Australia/Sydney` | Australia Eastern | +10 / +11 | Yes |
|
||||
| `Australia/Melbourne` | Australia Eastern | +10 / +11 | Yes |
|
||||
| `Australia/Brisbane` | Australia Eastern | +10 | No |
|
||||
| `Australia/Perth` | Australia Western | +8 | No |
|
||||
| `Australia/Adelaide` | Australia Central | +9:30 / +10:30 | Yes |
|
||||
| `Australia/Darwin` | Australia Central | +9:30 | No |
|
||||
| `Pacific/Auckland` | New Zealand | +12 / +13 | Yes |
|
||||
| `Pacific/Honolulu` | Hawaii | -10 | No |
|
||||
| `Pacific/Fiji` | Fiji | +12 / +13 | Yes |
|
||||
| `Africa/Cairo` | Egypt | +2 | No |
|
||||
| `Africa/Johannesburg` | South Africa | +2 | No |
|
||||
| `Africa/Lagos` | West Africa | +1 | No |
|
||||
| `Africa/Nairobi` | East Africa | +3 | No |
|
||||
| `Atlantic/Reykjavik` | Iceland | +0 | No |
|
||||
|
||||
#### Calculator (`!calc`)
|
||||
|
||||
|
|
@ -182,83 +183,83 @@ The calculator uses `bc -l` (POSIX arbitrary-precision calculator with the math
|
|||
|
||||
**Basic arithmetic:**
|
||||
|
||||
| Expression | Result |
|
||||
|---|---|
|
||||
| `!calc 2+2` | `4` |
|
||||
| `!calc 100-37` | `63` |
|
||||
| `!calc 6*7` | `42` |
|
||||
| `!calc 100/3` | `33.3333333333333333333` |
|
||||
| `!calc 10%3` | `1` |
|
||||
| Expression | Result |
|
||||
|----------------|--------------------------|
|
||||
| `!calc 2+2` | `4` |
|
||||
| `!calc 100-37` | `63` |
|
||||
| `!calc 6*7` | `42` |
|
||||
| `!calc 100/3` | `33.3333333333333333333` |
|
||||
| `!calc 10%3` | `1` |
|
||||
|
||||
**Parentheses for grouping:**
|
||||
|
||||
| Expression | Result |
|
||||
|---|---|
|
||||
| `!calc (3+7)*2` | `20` |
|
||||
| `!calc (100-50)/5` | `10` |
|
||||
| Expression | Result |
|
||||
|--------------------|--------|
|
||||
| `!calc (3+7)*2` | `20` |
|
||||
| `!calc (100-50)/5` | `10` |
|
||||
|
||||
**Powers:**
|
||||
|
||||
| Expression | Result |
|
||||
|---|---|
|
||||
| Expression | Result |
|
||||
|--------------|--------|
|
||||
| `!calc 2^10` | `1024` |
|
||||
| `!calc 3^3` | `27` |
|
||||
| `!calc 3^3` | `27` |
|
||||
|
||||
**Constants:**
|
||||
|
||||
| Expression | Description |
|
||||
|---|---|
|
||||
| `!calc pi()` | Pi (3.14159...) |
|
||||
| Expression | Description |
|
||||
|----------------|--------------------------------|
|
||||
| `!calc pi()` | Pi (3.14159...) |
|
||||
| `!calc pi()*2` | Circumference of a unit circle |
|
||||
| `!calc pi()^2` | Pi squared |
|
||||
| `!calc pi()^2` | Pi squared |
|
||||
|
||||
**Math library functions** (enabled by `-l`):
|
||||
|
||||
| Expression | Description |
|
||||
|---|---|
|
||||
| `!calc s(1)` | Sine of 1 (radians) |
|
||||
| `!calc c(0)` | Cosine of 0 |
|
||||
| `!calc a(1)` | Arctangent of 1 |
|
||||
| Expression | Description |
|
||||
|----------------|--------------------------|
|
||||
| `!calc s(1)` | Sine of 1 (radians) |
|
||||
| `!calc c(0)` | Cosine of 0 |
|
||||
| `!calc a(1)` | Arctangent of 1 |
|
||||
| `!calc l(100)` | Natural logarithm of 100 |
|
||||
| `!calc e(1)` | e^1 |
|
||||
| `!calc e(1)` | e^1 |
|
||||
|
||||
**Scale (decimal places):**
|
||||
|
||||
| Expression | Description |
|
||||
|---|---|
|
||||
| `!calc scale=4; 1/3` | `0.3333` |
|
||||
| Expression | Description |
|
||||
|----------------------|-------------|
|
||||
| `!calc scale=4; 1/3` | `0.3333` |
|
||||
|
||||
**Variables and multi-statement:**
|
||||
|
||||
| Expression | Description |
|
||||
|---|---|
|
||||
| `!calc x=5; x*2` | `10` |
|
||||
| Expression | Description |
|
||||
|------------------|----------------------------|
|
||||
| `!calc x=5; x*2` | `10` |
|
||||
| `!calc 2+2; 3*3` | `4` (first line of output) |
|
||||
|
||||
### AI
|
||||
|
||||
| Command | Description |
|
||||
|---|---|
|
||||
| `!ai <question>` | Ask the AI a question (plan mode, read-only) |
|
||||
| Command | Description |
|
||||
|-----------------------|------------------------------------------------------------|
|
||||
| `!ai <question>` | Ask the AI a question (plan mode, read-only) |
|
||||
| `!code <instruction>` | AI code change with auto-recompile (ops only, in channels) |
|
||||
| `<nick>: <question>` | Address the bot by nick to ask the AI |
|
||||
| `<nick>: <question>` | Address the bot by nick to ask the AI |
|
||||
|
||||
### Admin (Ops Only)
|
||||
|
||||
| Command | Description |
|
||||
|---|---|
|
||||
| `!reload` | Hot reload (save TLS state, fork new process) |
|
||||
| `!restart` | Restart the bot |
|
||||
| `!rebuild` | Git pull, rebuild, and restart (ops only, in channels) |
|
||||
| `!code <instruction>` | Make AI-powered code changes |
|
||||
| Command | Description |
|
||||
|-----------------------|--------------------------------------------------------|
|
||||
| `!reload` | Hot reload (save TLS state, fork new process) |
|
||||
| `!restart` | Restart the bot |
|
||||
| `!rebuild` | Git pull, rebuild, and restart (ops only, in channels) |
|
||||
| `!code <instruction>` | Make AI-powered code changes |
|
||||
|
||||
### Chat
|
||||
|
||||
| Command | Description |
|
||||
|---|---|
|
||||
| `<nick>: hi/hello/hey` | Greeting response |
|
||||
| `<nick>: bye` | Farewell response |
|
||||
| `<nick>: <anything>` | AI-powered conversation |
|
||||
| Command | Description |
|
||||
|------------------------|-------------------------|
|
||||
| `<nick>: hi/hello/hey` | Greeting response |
|
||||
| `<nick>: bye` | Farewell response |
|
||||
| `<nick>: <anything>` | AI-powered conversation |
|
||||
|
||||
## Database
|
||||
|
||||
|
|
@ -271,7 +272,7 @@ Data is stored in `zynk.db` (SQLite3) in the working directory. The bot creates
|
|||
|
||||
## Architecture
|
||||
|
||||
`zynk` uses a single `poll()` loop with a 100ms timeout. AI queries fork a child process that runs the `opencode` CLI; the parent picks up the result on the next poll iteration. SQLite3 is loaded at runtime via `dlopen` to avoid a compile-time dependency. The bot supports hot reload: `!reload` and `!restart` save TLS session state, fork a new process with the inherited socket, and resume without dropping from IRC.
|
||||
`zynk` uses a single `poll()` loop with a 100 ms timeout. AI queries fork a child process that runs the `opencode` CLI; the parent picks up the result on the next poll iteration. SQLite3 is loaded at runtime via `dlopen` to avoid a compile-time dependency. The bot supports hot reload: `!reload` and `!restart` save TLS session state, fork a new process with the inherited socket, and resume without dropping from IRC.
|
||||
|
||||
## License
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue