2
0
Fork 0
forked from zynk/zynk

Added VERSION to zynk.c and a !command to request the program version in IRC.

This commit is contained in:
Johannes Findeisen 2026-07-15 21:03:42 +02:00
commit 00e2153ee8
2 changed files with 23 additions and 0 deletions

12
zynk.c
View file

@ -29,6 +29,7 @@ int asprintf(char **, const char *, ...);
/* ---- constants ---- */
#define VERSION "0.30"
#define DEFAULT_SERVER "irc.libera.chat"
#define OPENCODE_BIN "/home/hanez/bin/opencode"
#define CLR_RESET "\033[0m"
@ -1101,6 +1102,16 @@ static int cmd_ping(Session *s, const char *msg, const char *reply_target, const
return 1;
}
static int cmd_version(Session *s, const char *msg, const char *reply_target, const char *src_nick) {
if (strncmp(msg, "!version", 8) != 0) return 0;
if (msg[8] != ' ' && msg[8] != '\0') return 0;
if (rate_limit_check(src_nick) < 0) return 1;
char buf[96]; snprintf(buf, sizeof buf, "zynk %s", VERSION);
irc_msg(s, reply_target, buf);
log_stamp(); fprintf(stderr, CLR_BLUE "VERSION 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)) {
@ -1257,6 +1268,7 @@ static void handle_privmsg(Session *s, const char *params, const char *src_nick)
const char *reply_target = (tgt[0] == '#') ? tgt : 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_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;