1
0
Fork 0
forked from murx/irc9

Suppress mode-change notices in silent mode

This commit is contained in:
Johannes Findeisen 2026-11-29 07:34:25 +01:00
commit eb4e78f269
2 changed files with 11 additions and 9 deletions

View file

@ -16,7 +16,7 @@ make
``` ```
`-s` and `--silent` hide channel join, quit, leave, and sync notices, as well as `-s` and `--silent` hide channel join, quit, leave, and sync notices, as well as
nickname-change notices. nickname-change and mode-change notices.
`-C` and `--colored` color nicknames in channel and private chats and in `-C` and `--colored` color nicknames in channel and private chats and in
nicklists. Your own nick is always green in this mode, including in the status nicklists. Your own nick is always green in this mode, including in the status
line. line.

12
irc9.c
View file

@ -1365,17 +1365,19 @@ static void handle_line(Server *s, char *line)
if (strcasecmp(cmd, "MODE") == 0 && narg >= 2) { if (strcasecmp(cmd, "MODE") == 0 && narg >= 2) {
Window *w = window_find(s, arg[0]); Window *w = window_find(s, arg[0]);
if (!w) w = is_channel(arg[0]) ? window_get(s, arg[0], W_CHANNEL) : sw; if (!w) w = is_channel(arg[0]) ? window_get(s, arg[0], W_CHANNEL) : sw;
char params[MAXLINE]; if (w->type == W_CHANNEL) member_modes(w, arg[1], arg + 2, narg - 2);
params[0] = 0; else if (strcasecmp(arg[0], s->nick) == 0)
snprintf(s->umode, sizeof s->umode, "%s", arg[1]);
if (!silent) {
char params[MAXLINE] = "";
for (int i = 1; i < narg; i++) { for (int i = 1; i < narg; i++) {
if (i > 1) strncat(params, " ", sizeof params - strlen(params) - 1); if (i > 1) strncat(params, " ", sizeof params - strlen(params) - 1);
strncat(params, arg[i], sizeof params - strlen(params) - 1); strncat(params, arg[i], sizeof params - strlen(params) - 1);
} }
if (w->type == W_CHANNEL) member_modes(w, arg[1], arg + 2, narg - 2);
else if (strcasecmp(arg[0], s->nick) == 0)
snprintf(s->umode, sizeof s->umode, "%s", arg[1]);
append_nickf(w, "* ", *nick ? nick : "server", " ", "sets mode %s on %s", append_nickf(w, "* ", *nick ? nick : "server", " ", "sets mode %s on %s",
params, arg[0]); params, arg[0]);
}
dirty = 1;
return; return;
} }