1
0
Fork 0
forked from murx/irc9

Add silent mode for channel join and quit notices

This commit is contained in:
Johannes Findeisen 2026-11-27 20:31:23 +01:00
commit ef5c97ecac
2 changed files with 23 additions and 4 deletions

View file

@ -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.

22
irc9.c
View file

@ -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);