2
0
Fork 0
forked from zynk/zynk
An IRC bot in C. Features a key-value store backed by SQLite3, weather lookups via wttr.in, stock quotes, calculator, time, user tracking, and AI-powered replies.
  • C 98%
  • CMake 2%
Find a file
hanez c4d9011bdb Show full AI error output instead of generic error message
When an AI query fails (opencode exits non-zero), the bot previously
sent a generic 'AI query failed (opencode exited with error)' message
to IRC, discarding all useful output. Users had no way to diagnose why
the query failed.

Changes:
- Redirect opencode's stderr into the capture pipe instead of /dev/null,
  so error messages that go to stderr are no longer lost.
- On non-zero exit, include the actual captured output in the error
  message sent to IRC: 'AI error (exit N): <output>' (truncated to
  4000 chars). If no output was captured, show 'AI error (exit N, no
  output)' instead.
- Applied strip_formatting() to the error output before sending so
  ANSI codes and markdown don't leak into IRC.
- Bumped VERSION to 0.34.3.
2026-07-19 23:01:55 +02:00
.gitignore Renamed calc to zynk and refactored all relevant parts. 2026-07-14 23:52:56 +02:00
AGENTS.md v0.33.1: fix hot reload re-registration, add !hello, comprehensive docs 2026-07-19 01:29:22 +02:00
CHANGELOG.md Show full AI error output instead of generic error message 2026-07-19 23:01:55 +02:00
LICENSE update LICENSE / README 2026-06-07 01:52:28 +02:00
Makefile v0.33.1: fix hot reload re-registration, add !hello, comprehensive docs 2026-07-19 01:29:22 +02:00
README.md Added !help command to list available bot commands. 2026-07-15 21:12:29 +02:00
zynk.c Show full AI error output instead of generic error message 2026-07-19 23:01:55 +02:00

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 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
  • TLS: Secure connections via OpenSSL
  • Rate Limiting: Per-nick protection against spam
  • Single File: Easy to deploy and modify

Requirements

  • gcc (or any C99 compiler)
  • libssl-dev (OpenSSL)
  • libdl (dynamic linker)
  • libsqlite3 (loaded at runtime via dlopen)
  • curl (for weather lookups)
  • opencode (for AI queries)

Build

make

Set custom compiler or flags:

make CC=clang CFLAGS="-O2 -Wall -Wextra"

Usage

./zynk [options]

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: calc)
-join <c> Auto-join channels, comma-separated (default: #calctest)
-h Show help

Example

./zynk -ssl -nick mybot -join "#mychan,#myotherchan"

IRC Commands

Command Description
zynk <key> Look up a stored value
zynk <key> = <value> Store a value (key is lowercased)
!ping Responds with pong
!version Show the program version in IRC
!weather [city] Current weather (default: Berlin)
!forecast [city] 3-day forecast (default: Berlin)
!ai <question> Ask the AI a question
!quit / !die Shut down the bot
<nick>: hi Greeting response
<nick>: <question> Ask the bot anything (AI)

Installation

make install

Installs to $(PREFIX)/bin (default: /usr/local/bin).

Override the prefix:

make install PREFIX=$HOME/.local

Database

Data is stored in zynk.db (SQLite3) in the working directory. The bot creates two tables:

  • zynk - key-value pairs with nick and timestamp metadata
  • ai_pending - single-row table for managing in-flight AI queries

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.

License

MIT - see LICENSE file.