static void cmd_unignore(const char *data) { IGNORE_REC *rec; GSList *tmp; char *key; if (is_numeric(data, ' ')) { /* with index number */ tmp = g_slist_nth(ignores, atoi(data)-1); rec = tmp == NULL ? NULL : tmp->data; } else { /* with mask */ char *chans[2] = { "*", NULL }; if (ischannel(*data)) chans[0] = (char *) data; rec = ignore_find("*", ischannel(*data) ? NULL : data, chans); } if (rec == NULL) printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_IGNORE_NOT_FOUND, data); else { key = ignore_get_key(rec); printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_UNIGNORED, key); g_free(key); rec->level = 0; rec->except_level = 0; ignore_update_rec(rec); } }
static PyObject *PyIgnore_update_rec(PyIgnore *self, PyObject *args) { RET_NULL_IF_INVALID(self->data); ignore_update_rec(self->data); Py_RETURN_NONE; }
/* SYNTAX: UNIGNORE <id>|<mask> */ static void cmd_unignore(const char *data) { IGNORE_REC *rec; GSList *tmp; char *mask, *mask_orig; void *free_arg; if (!cmd_get_params(data, &free_arg, 1, &mask)) return; if (*mask == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); /* Save the mask string here since it might be modified in the code * below and we need it to print meaningful error messages. */ mask_orig = mask; if (is_numeric(mask, ' ')) { /* with index number */ tmp = g_slist_nth(ignores, atoi(mask)-1); rec = tmp == NULL ? NULL : tmp->data; } else { /* with mask */ const char *chans[2] = { "*", NULL }; if (active_win->active_server != NULL && server_ischannel(active_win->active_server, mask)) { chans[0] = mask; mask = NULL; } rec = ignore_find_full("*", mask, NULL, (char **) chans, 0); if (rec == NULL) { rec = ignore_find_full("*", mask, NULL, (char **) chans, IGNORE_FIND_NOACT); } } if (rec != NULL) { rec->level = 0; ignore_update_rec(rec); } else { printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, TXT_IGNORE_NOT_FOUND, mask_orig); } cmd_params_free(free_arg); }
static int unignore_timeout(void) { GSList *tmp, *next; time_t now; now = time(NULL); for (tmp = ignores; tmp != NULL; tmp = next) { IGNORE_REC *rec = tmp->data; next = tmp->next; if (rec->unignore_time > 0 && now >= rec->unignore_time) { rec->level = 0; ignore_update_rec(rec); } } return TRUE; }
void autoignore_add(IRC_SERVER_REC *server, const char *nick, int level) { MODULE_SERVER_REC *mserver; AUTOIGNORE_REC *rec; IGNORE_REC *irec; int igtime; g_return_if_fail(server != NULL); g_return_if_fail(nick != NULL); if (level == 0) return; igtime = settings_get_int("autoignore_time"); if (igtime <= 0) return; irec = ignore_find_server(server, nick); if (irec == NULL) { irec = g_new0(IGNORE_REC, 1); irec->servertag = g_strdup(server->tag); irec->mask = g_strdup(nick); irec->level = level; ignore_add_rec(irec); } else { irec->level |= level; ignore_update_rec(irec); } rec = autoignore_find(server, nick); if (rec != NULL) { /* already being ignored */ rec->timeleft = igtime; return; } rec = g_new(AUTOIGNORE_REC, 1); rec->nick = g_strdup(nick); rec->timeleft = igtime; rec->level = level; mserver = MODULE_DATA(server); mserver->ignorelist = g_slist_append(mserver->ignorelist, rec); signal_emit("autoignore new", 2, server, rec); }
/* SYNTAX: UNIGNORE <id>|<mask> */ static void cmd_unignore(const char *data) { IGNORE_REC *rec; GSList *tmp; char *mask; void *free_arg; if (!cmd_get_params(data, &free_arg, 1, &mask)) return; if (*mask == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); if (is_numeric(mask, ' ')) { /* with index number */ tmp = g_slist_nth(ignores, atoi(mask)-1); rec = tmp == NULL ? NULL : tmp->data; } else { /* with mask */ const char *chans[2] = { "*", NULL }; if (active_win->active_server != NULL && server_ischannel(active_win->active_server, mask)) { chans[0] = mask; mask = NULL; } rec = ignore_find_noact("*", mask, (char **) chans, 0); if (rec == NULL) { rec = ignore_find_noact("*", mask, (char **) chans, 1); } } if (rec != NULL) { rec->level = 0; ignore_update_rec(rec); } else { printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, TXT_IGNORE_NOT_FOUND, mask); } cmd_params_free(free_arg); }
int autoignore_remove(IRC_SERVER_REC *server, const char *mask, int level) { AUTOIGNORE_REC *rec; IGNORE_REC *irec; g_return_val_if_fail(server != NULL, FALSE); g_return_val_if_fail(mask != NULL, FALSE); irec = ignore_find_server(server, mask); if (irec != NULL) { irec->level &= ~level; ignore_update_rec(irec); } rec = autoignore_find(server, mask); if (rec != NULL && (level & rec->level)) { rec->level &= ~level; if (rec->level == 0) autoignore_remove_rec(server, rec); return TRUE; } return FALSE; }
/* NOTE: -network replaces the old -ircnet flag. */ static void cmd_ignore(const char *data) { GHashTable *optlist; IGNORE_REC *rec; char *patternarg, *chanarg, *mask, *levels, *timestr, *servertag; char **channels; void *free_arg; int new_ignore, msecs, level, flags; if (*data == '\0') { cmd_ignore_show(); return; } if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_OPTIONS | PARAM_FLAG_GETREST | PARAM_FLAG_STRIP_TRAILING_WS, "ignore", &optlist, &mask, &levels)) return; patternarg = g_hash_table_lookup(optlist, "pattern"); chanarg = g_hash_table_lookup(optlist, "channels"); servertag = g_hash_table_lookup(optlist, "network"); /* Allow -ircnet for backwards compatibility */ if (!servertag) servertag = g_hash_table_lookup(optlist, "ircnet"); if (*mask == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); if (*levels == '\0') levels = "ALL"; level = level2bits(levels, NULL); msecs = 0; timestr = g_hash_table_lookup(optlist, "time"); if (timestr != NULL) { if (!parse_time_interval(timestr, &msecs)) cmd_param_error(CMDERR_INVALID_TIME); } if (active_win->active_server != NULL && server_ischannel(active_win->active_server, mask)) { chanarg = mask; mask = NULL; } channels = (chanarg == NULL || *chanarg == '\0') ? NULL : g_strsplit(chanarg, ",", -1); flags = IGNORE_FIND_PATTERN; if (level & MSGLEVEL_NO_ACT) flags |= IGNORE_FIND_NOACT; if (level & MSGLEVEL_HIDDEN) flags |= IGNORE_FIND_HIDDEN; rec = ignore_find_full(servertag, mask, patternarg, channels, flags); new_ignore = rec == NULL; if (rec == NULL) { rec = g_new0(IGNORE_REC, 1); rec->mask = mask == NULL || *mask == '\0' || g_strcmp0(mask, "*") == 0 ? NULL : g_strdup(mask); rec->channels = channels; } else { g_free_and_null(rec->pattern); g_strfreev(channels); } rec->level = combine_level(rec->level, levels); if (rec->level == MSGLEVEL_NO_ACT) { /* If only NO_ACT was specified add all levels; it makes no * sense on its own. */ rec->level |= MSGLEVEL_ALL; } if (rec->level == MSGLEVEL_HIDDEN) { /* If only HIDDEN was specified add all levels; it makes no * sense on its own. */ rec->level |= MSGLEVEL_ALL; } if (new_ignore && rec->level == 0) { /* tried to unignore levels from nonexisting ignore */ printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, TXT_IGNORE_NOT_FOUND, rec->mask); g_free(rec->mask); g_strfreev(rec->channels); g_free(rec); cmd_params_free(free_arg); return; } rec->servertag = (servertag == NULL || *servertag == '\0') ? NULL : g_strdup(servertag); rec->pattern = (patternarg == NULL || *patternarg == '\0') ? NULL : g_strdup(patternarg); rec->exception = g_hash_table_lookup(optlist, "except") != NULL; rec->regexp = g_hash_table_lookup(optlist, "regexp") != NULL; rec->fullword = g_hash_table_lookup(optlist, "full") != NULL; rec->replies = g_hash_table_lookup(optlist, "replies") != NULL; if (msecs != 0) rec->unignore_time = time(NULL)+msecs/1000; if (new_ignore) ignore_add_rec(rec); else ignore_update_rec(rec); cmd_params_free(free_arg); }
static void cmd_ignore(const char *data) { /* /IGNORE [-regexp | -word] [-pattern <pattern>] [-except] [-replies] [-channels <channel>] <mask> <levels> OR /IGNORE [-regexp | -word] [-pattern <pattern>] [-except] [-replies] <channels> <levels> */ GHashTable *optlist; IGNORE_REC *rec; char *patternarg, *chanarg, *mask, *levels, *key; char **channels; void *free_arg; int new_ignore; if (*data == '\0') { cmd_ignore_show(); return; } if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_OPTIONS | PARAM_FLAG_GETREST, "ignore", &optlist, &mask, &levels)) return; patternarg = g_hash_table_lookup(optlist, "pattern"); chanarg = g_hash_table_lookup(optlist, "channels"); if (*levels == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); if (ischannel(*mask)) { chanarg = mask; mask = ""; } channels = (chanarg == NULL || *chanarg == '\0') ? NULL : g_strsplit(replace_chars(chanarg, ',', ' '), " ", -1); rec = ignore_find(NULL, mask, channels); new_ignore = rec == NULL; if (rec == NULL) { rec = g_new0(IGNORE_REC, 1); rec->mask = *mask == '\0' ? NULL : g_strdup(mask); rec->channels = channels; } else { g_free_and_null(rec->pattern); g_strfreev(channels); } if (g_hash_table_lookup(optlist, "except") != NULL) { rec->except_level = combine_level(rec->except_level, levels); } else { ignore_split_levels(levels, &rec->level, &rec->except_level); } rec->pattern = (patternarg == NULL || *patternarg == '\0') ? NULL : g_strdup(patternarg); rec->regexp = g_hash_table_lookup(optlist, "regexp") != NULL; rec->fullword = g_hash_table_lookup(optlist, "word") != NULL; rec->replies = g_hash_table_lookup(optlist, "replies") != NULL; if (rec->level == 0 && rec->except_level == 0) { printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_UNIGNORED, rec->mask == NULL ? "" : rec->mask); } else { key = ignore_get_key(rec); levels = ignore_get_levels(rec->level, rec->except_level); printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_IGNORED, key, levels); g_free(key); g_free(levels); } if (new_ignore) ignore_add_rec(rec); else ignore_update_rec(rec); cmd_params_free(free_arg); }
static void cmd_ignore(const char *data) { /* /IGNORE [-regexp | -word] [-pattern <pattern>] [-except] [-channels <channel>] <mask> <levels> OR /IGNORE [-regexp | -word] [-pattern <pattern>] [-except] <channels> <levels> */ char *params, *args, *patternarg, *chanarg, *mask, *levels, *key; char **channels; IGNORE_REC *rec; int new_ignore; if (*data == '\0') { cmd_ignore_show(); return; } args = "pattern channels"; params = cmd_get_params(data, 5 | PARAM_FLAG_MULTIARGS | PARAM_FLAG_GETREST, &args, &patternarg, &chanarg, &mask, &levels); if (*levels == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); if (ischannel(*mask)) { chanarg = mask; mask = ""; } channels = *chanarg == '\0' ? NULL : g_strsplit(replace_chars(chanarg, ',', ' '), " ", -1); rec = ignore_find(NULL, mask, channels); new_ignore = rec == NULL; if (rec == NULL) { rec = g_new0(IGNORE_REC, 1); rec->mask = *mask == '\0' ? NULL : g_strdup(mask); rec->channels = channels; } else { g_free_and_null(rec->pattern); g_strfreev(channels); } if (stristr(args, "-except") != NULL) { rec->except_level = combine_level(rec->except_level, levels); } else { ignore_split_levels(levels, &rec->level, &rec->except_level); } rec->pattern = *patternarg == '\0' ? NULL : g_strdup(patternarg); rec->regexp = stristr(args, "-regexp") != NULL; rec->fullword = stristr(args, "-word") != NULL; rec->replies = stristr(args, "-replies") != NULL; if (rec->level == 0 && rec->except_level == 0) { printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_UNIGNORED, rec->mask == NULL ? "" : rec->mask); } else { key = ignore_get_key(rec); levels = ignore_get_levels(rec->level, rec->except_level); printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_IGNORED, key, levels); g_free(key); g_free(levels); } if (new_ignore) ignore_add_rec(rec); else ignore_update_rec(rec); g_free(params); }
/* SYNTAX: IGNORE [-regexp | -full] [-pattern <pattern>] [-except] [-replies] [-channels <channel>] [-time <secs>] <mask> [<levels>] IGNORE [-regexp | -full] [-pattern <pattern>] [-except] [-replies] [-time <secs>] <channels> [<levels>] */ static void cmd_ignore(const char *data) { GHashTable *optlist; IGNORE_REC *rec; char *patternarg, *chanarg, *mask, *levels, *timestr; char **channels; void *free_arg; int new_ignore, msecs; if (*data == '\0') { cmd_ignore_show(); return; } if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_OPTIONS | PARAM_FLAG_GETREST, "ignore", &optlist, &mask, &levels)) return; patternarg = g_hash_table_lookup(optlist, "pattern"); chanarg = g_hash_table_lookup(optlist, "channels"); if (*mask == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); if (*levels == '\0') levels = "ALL"; msecs = 0; timestr = g_hash_table_lookup(optlist, "time"); if (timestr != NULL) { if (!parse_time_interval(timestr, &msecs)) cmd_return_error(CMDERR_INVALID_TIME); } if (active_win->active_server != NULL && server_ischannel(active_win->active_server, mask)) { chanarg = mask; mask = NULL; } channels = (chanarg == NULL || *chanarg == '\0') ? NULL : g_strsplit(replace_chars(chanarg, ',', ' '), " ", -1); rec = patternarg != NULL ? NULL: ignore_find(NULL, mask, channels); new_ignore = rec == NULL; if (rec == NULL) { rec = g_new0(IGNORE_REC, 1); rec->mask = mask == NULL || *mask == '\0' || strcmp(mask, "*") == 0 ? NULL : g_strdup(mask); rec->channels = channels; } else { g_free_and_null(rec->pattern); g_strfreev(channels); } rec->level = combine_level(rec->level, levels); if (new_ignore && rec->level == 0) { /* tried to unignore levels from nonexisting ignore */ printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, TXT_IGNORE_NOT_FOUND, rec->mask); g_free(rec->mask); g_strfreev(rec->channels); g_free(rec); cmd_params_free(free_arg); return; } rec->pattern = (patternarg == NULL || *patternarg == '\0') ? NULL : g_strdup(patternarg); rec->exception = g_hash_table_lookup(optlist, "except") != NULL; rec->regexp = g_hash_table_lookup(optlist, "regexp") != NULL; rec->fullword = g_hash_table_lookup(optlist, "full") != NULL; rec->replies = g_hash_table_lookup(optlist, "replies") != NULL; if (msecs != 0) rec->unignore_time = time(NULL)+msecs/1000; if (new_ignore) ignore_add_rec(rec); else ignore_update_rec(rec); cmd_params_free(free_arg); }