2
0
Fork 0
forked from zynk/zynk

Added !help command to list available bot commands.

This commit is contained in:
Johannes Findeisen 2026-07-15 21:12:29 +02:00
commit 999814e5df
3 changed files with 26 additions and 11 deletions

View file

@ -9,3 +9,4 @@
- Fixed IRC op cache bugs around nick changes and long NAMES entries.
- Added !version command to report the bot's version via IRC.
- Fixed the malformed VERSION macro definition to ensure successful builds.
- Added !help command to list available bot commands.

View file

@ -60,17 +60,18 @@ make CC=clang CFLAGS="-O2 -Wall -Wextra"
## IRC Commands
| Command | Description |
|---|---|
| `zynk <key>` | Look up a stored value |
| Command | Description |
|------------------------|-----------------------------------|
| `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) |
| `!ai <question>` | Ask the AI a question |
| `!quit` / `!die` | Shut down the bot |
| `<nick>: hi` | Greeting response |
| `<nick>: <question>` | Ask the bot anything (AI) |
| `!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

15
zynk.c
View file

@ -29,7 +29,7 @@ int asprintf(char **, const char *, ...);
/* ---- constants ---- */
#define VERSION "0.30"
#define VERSION "0.31"
#define DEFAULT_SERVER "irc.libera.chat"
#define OPENCODE_BIN "/home/hanez/bin/opencode"
#define CLR_RESET "\033[0m"
@ -1112,6 +1112,18 @@ static int cmd_version(Session *s, const char *msg, const char *reply_target, co
return 1;
}
static int cmd_help(Session *s, const char *msg, const char *reply_target, const char *src_nick) {
if (strncmp(msg, "!help", 5) != 0) return 0;
if (msg[5] != ' ' && msg[5] != '\0') return 0;
if (rate_limit_check(src_nick) < 0) return 1;
char buf[512];
snprintf(buf, sizeof buf,
"Commands: !help, !version, !ping, !weather [city], !forecast [city], !ai <question>, !code <change> (ops), !quit/!die (ops)");
irc_msg(s, reply_target, buf);
log_stamp(); fprintf(stderr, CLR_CYAN "HELP from %s in %s" CLR_RESET "\n", src_nick, reply_target);
return 1;
}
static int cmd_quit(Session *s, const char *msg, const char *reply_target, const char *src_nick, const char *tgt) {
if (strcmp(msg, "!quit") != 0 && strcmp(msg, "!die") != 0) return 0;
if (tgt[0] == '#' && !chan_is_op(tgt, src_nick)) {
@ -1269,6 +1281,7 @@ static void handle_privmsg(Session *s, const char *params, const char *src_nick)
if (cmd_zynk(s, msg, reply_target, src_nick, tgt)) return;
if (cmd_ping(s, msg, reply_target, src_nick)) return;
if (cmd_version(s, msg, reply_target, src_nick)) return;
if (cmd_help(s, msg, reply_target, src_nick)) return;
if (cmd_quit(s, msg, reply_target, src_nick, tgt)) return;
if (cmd_weather(s, msg, reply_target, src_nick)) return;
if (cmd_forecast(s, msg, reply_target, src_nick)) return;