mirror of
https://github.com/irssi/irssi.git
synced 2024-10-27 05:20:20 -04:00
Implemented /IGNORE -time <seconds>, patch by fuchs.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@527 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
f9d4b9d8c8
commit
30afa4a611
@ -29,6 +29,8 @@
|
||||
#include "irc-server.h"
|
||||
#include "ignore.h"
|
||||
|
||||
static void fe_unignore(IGNORE_REC *rec);
|
||||
|
||||
static char *ignore_get_key(IGNORE_REC *rec)
|
||||
{
|
||||
char *chans, *ret;
|
||||
@ -125,6 +127,12 @@ static void ignore_print(int index, IGNORE_REC *rec)
|
||||
g_free(levels);
|
||||
}
|
||||
|
||||
static int unignore_timeout(IGNORE_REC *rec)
|
||||
{
|
||||
fe_unignore(rec);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void cmd_ignore_show(void)
|
||||
{
|
||||
GSList *tmp;
|
||||
@ -143,14 +151,14 @@ static void cmd_ignore_show(void)
|
||||
static void cmd_ignore(const char *data)
|
||||
{
|
||||
/* /IGNORE [-regexp | -word] [-pattern <pattern>] [-except]
|
||||
[-replies] [-channels <channel>] <mask> <levels>
|
||||
[-replies] [-channels <channel>] [-time <secs>] <mask> <levels>
|
||||
OR
|
||||
|
||||
/IGNORE [-regexp | -word] [-pattern <pattern>] [-except] [-replies]
|
||||
<channels> <levels> */
|
||||
[-time <secs>] <channels> <levels> */
|
||||
GHashTable *optlist;
|
||||
IGNORE_REC *rec;
|
||||
char *patternarg, *chanarg, *mask, *levels, *key;
|
||||
char *patternarg, *chanarg, *mask, *levels, *key, *timestr;
|
||||
char **channels;
|
||||
void *free_arg;
|
||||
int new_ignore;
|
||||
@ -201,6 +209,8 @@ static void cmd_ignore(const char *data)
|
||||
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;
|
||||
timestr = g_hash_table_lookup(optlist, "time");
|
||||
rec->time = timestr == NULL ? 0 : atoi(timestr);
|
||||
|
||||
if (rec->level == 0 && rec->except_level == 0) {
|
||||
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_UNIGNORED,
|
||||
@ -213,6 +223,9 @@ static void cmd_ignore(const char *data)
|
||||
g_free(levels);
|
||||
}
|
||||
|
||||
if (rec->time > 0)
|
||||
rec->time_tag = g_timeout_add(rec->time*1000, (GSourceFunc) unignore_timeout, rec);
|
||||
|
||||
if (new_ignore)
|
||||
ignore_add_rec(rec);
|
||||
else
|
||||
@ -221,11 +234,23 @@ static void cmd_ignore(const char *data)
|
||||
cmd_params_free(free_arg);
|
||||
}
|
||||
|
||||
static void fe_unignore(IGNORE_REC *rec)
|
||||
{
|
||||
char *key;
|
||||
|
||||
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 void cmd_unignore(const char *data)
|
||||
{
|
||||
IGNORE_REC *rec;
|
||||
GSList *tmp;
|
||||
char *key;
|
||||
|
||||
if (is_numeric(data, ' ')) {
|
||||
/* with index number */
|
||||
@ -241,15 +266,8 @@ static void cmd_unignore(const char *data)
|
||||
|
||||
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);
|
||||
}
|
||||
else
|
||||
fe_unignore(rec);
|
||||
}
|
||||
|
||||
void fe_ignore_init(void)
|
||||
@ -257,7 +275,7 @@ void fe_ignore_init(void)
|
||||
command_bind("ignore", NULL, (SIGNAL_FUNC) cmd_ignore);
|
||||
command_bind("unignore", NULL, (SIGNAL_FUNC) cmd_unignore);
|
||||
|
||||
command_set_options("ignore", "regexp word except replies -pattern -channels");
|
||||
command_set_options("ignore", "regexp word except replies -time -pattern -channels");
|
||||
}
|
||||
|
||||
void fe_ignore_deinit(void)
|
||||
|
@ -197,6 +197,9 @@ static void ignore_set_config(IGNORE_REC *rec)
|
||||
if (rec->level == 0 && rec->except_level == 0)
|
||||
return;
|
||||
|
||||
if (rec->time > 0)
|
||||
return;
|
||||
|
||||
node = iconfig_node_traverse("(ignores", TRUE);
|
||||
node = config_node_section(node, NULL, NODE_TYPE_BLOCK);
|
||||
|
||||
@ -263,6 +266,7 @@ static void ignore_destroy(IGNORE_REC *rec)
|
||||
ignores = g_slist_remove(ignores, rec);
|
||||
signal_emit("ignore destroyed", 1, rec);
|
||||
|
||||
if (rec->time_tag > 0) g_source_remove(rec->time_tag);
|
||||
if (rec->channels != NULL) g_strfreev(rec->channels);
|
||||
g_free_not_null(rec->mask);
|
||||
g_free_not_null(rec->servertag);
|
||||
|
@ -10,6 +10,9 @@ typedef struct {
|
||||
int level; /* ignore these levels */
|
||||
int except_level; /* don't ignore these levels */
|
||||
|
||||
int time; /* time in sec for temp ignores */
|
||||
int time_tag;
|
||||
|
||||
int regexp:1;
|
||||
int fullword:1;
|
||||
int replies:1; /* ignore replies to nick in channel */
|
||||
|
Loading…
Reference in New Issue
Block a user