2
0
Fork 0
forked from zynk/zynk

Renamed calc to zynk and refactored all relevant parts.

This commit is contained in:
Johannes Findeisen 2026-07-14 23:52:56 +02:00
commit 2247b9a480
5 changed files with 63 additions and 63 deletions

View file

@ -1,10 +1,10 @@
# calc - Companion AI Logic Chatbot
# zynk - Companion AI Logic Chatbot
A single-file IRC bot in C. Features a key-value store backed by SQLite3, weather lookups via wttr.in, and AI-powered replies.
## Features
- **Key-Value Store**: Persist facts, notes, or any data with `calc key = value`
- **Key-Value Store**: Persist facts, notes, or any data with `zynk key = value`
- **Weather**: Current conditions and 3-day forecasts via `wttr.in`
- **AI Queries**: Ask questions via `!ai` or by addressing the bot; powered by `opencode`
- **Chat Greetings**: Responds to `hi`, `hello`, `hey`, `bye`, and more
@ -19,7 +19,7 @@ A single-file IRC bot in C. Features a key-value store backed by SQLite3, weathe
- `libdl` (dynamic linker)
- `libsqlite3` (loaded at runtime via `dlopen`)
- `curl` (for weather lookups)
- `opencode` (for AI queries - see `calc.c:229` to configure path)
- `opencode` (for AI queries)
## Build
@ -36,7 +36,7 @@ make CC=clang CFLAGS="-O2 -Wall -Wextra"
## Usage
```sh
./calc [options]
./zynk [options]
```
### Options
@ -55,15 +55,15 @@ make CC=clang CFLAGS="-O2 -Wall -Wextra"
### Example
```sh
./calc -ssl -nick mybot -join "#mychan,#myotherchan"
./zynk -ssl -nick mybot -join "#mychan,#myotherchan"
```
## IRC Commands
| Command | Description |
|---|---|
| `calc <key>` | Look up a stored value |
| `calc <key> = <value>` | Store a value (key is lowercased) |
| `zynk <key>` | Look up a stored value |
| `zynk <key> = <value>` | Store a value (key is lowercased) |
| `!ping` | Responds with `pong` |
| `!weather [city]` | Current weather (default: Berlin) |
| `!forecast [city]` | 3-day forecast (default: Berlin) |
@ -88,14 +88,14 @@ make install PREFIX=$HOME/.local
## Database
Data is stored in `calc.db` (SQLite3) in the working directory. The bot creates two tables:
Data is stored in `zynk.db` (SQLite3) in the working directory. The bot creates two tables:
- `calc` - key-value pairs with nick and timestamp metadata
- `zynk` - key-value pairs with nick and timestamp metadata
- `ai_pending` - single-row table for managing in-flight AI queries
## Architecture
`calc` 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.
`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.
## License