Add silent mode for channel join and quit notices
This commit is contained in:
parent
634dd92bd4
commit
ef5c97ecac
2 changed files with 23 additions and 4 deletions
22
irc9.c
22
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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue