From ef5c97ecac08841cc558468fb5b4e7bf50c8fb68 Mon Sep 17 00:00:00 2001 From: Johannes Findeisen Date: Fri, 27 Nov 2026 20:31:23 +0100 Subject: [PATCH] Add silent mode for channel join and quit notices --- README.md | 5 ++++- irc9.c | 22 +++++++++++++++++++--- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index cfc79f3..d0543ef 100644 --- a/README.md +++ b/README.md @@ -12,9 +12,12 @@ around. make ./irc9 # finds a config automatically (see below) ./irc9 myconfig.conf # or point at a config explicitly +./irc9 -s myconfig.conf # hide join and quit notices in channel windows ``` -With no argument, irc9 looks next to the executable, in this order: +`-s` and `--silent` hide JOIN and QUIT notices in channel windows. + +With no config path, irc9 looks next to the executable, in this order: `irc9rc`, `config`, then `~/.irc9rc`. Paths are relative to the binary, not to the current working directory. diff --git a/irc9.c b/irc9.c index 888660c..bd5b874 100644 --- a/irc9.c +++ b/irc9.c @@ -166,6 +166,7 @@ static char g_nick[NICKLEN] = "irc9"; static char g_user[NICKLEN] = "irc9"; static char g_real[128] = "irc9 user"; static int strip_formatting = 1; +static int silent; static char input[MAXINPUT]; static int input_len, input_pos; @@ -1140,7 +1141,7 @@ static void handle_line(Server *s, char *line) if (narg < 1) return; Window *w = window_get(s, arg[0], W_CHANNEL); member_add(w, nick); - appendf(w, "* %s joined %s", hostmask ? hostmask : "someone", arg[0]); + if (!silent) appendf(w, "* %s joined %s", hostmask ? hostmask : "someone", arg[0]); return; } @@ -1160,7 +1161,7 @@ static void handle_line(Server *s, char *line) int shown = 0; for (Window *w = s->windows; w; w = w->next) if (w->type == W_CHANNEL && member_find(w, nick)) { - appendf(w, "* %s quit%s", hostmask ? hostmask : nick, why); + if (!silent) appendf(w, "* %s quit%s", hostmask ? hostmask : nick, why); member_remove(w, nick); shown = 1; } @@ -2507,7 +2508,22 @@ static const char *find_config(void) int main(int argc, char **argv) { - const char *path = argc > 1 ? argv[1] : find_config(); + const char *path = NULL; + int options = 1; + for (int i = 1; i < argc; i++) { + const char *arg = argv[i]; + if (options && strcmp(arg, "--") == 0) { + options = 0; + } else if (options && (strcmp(arg, "-s") == 0 || strcmp(arg, "--silent") == 0)) { + silent = 1; + } else if (!path && (!options || arg[0] != '-' || arg[1] == 0)) { + path = arg; + } else { + fprintf(stderr, "usage: %s [-s|--silent] [config]\n", argv[0]); + return 1; + } + } + if (!path) path = find_config(); signal(SIGPIPE, SIG_IGN); signal(SIGINT, on_signal);