summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2000-07-23 14:41:42 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2000-07-23 14:41:42 +0000
commit30afa4a6114913f08e794faba5399045403ffb27 (patch)
treed663c746545393494ff9a577bc2199fe01575e36 /src
parentf9d4b9d8c8d82c6931f34cac2aa982420b7e7a32 (diff)
downloadirssi-30afa4a6114913f08e794faba5399045403ffb27.zip
Implemented /IGNORE -time <seconds>, patch by fuchs.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@527 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src')
-rw-r--r--src/fe-common/irc/fe-ignore.c46
-rw-r--r--src/irc/core/ignore.c4
-rw-r--r--src/irc/core/ignore.h3
3 files changed, 39 insertions, 14 deletions
diff --git a/src/fe-common/irc/fe-ignore.c b/src/fe-common/irc/fe-ignore.c
index b926e351..9056df15 100644
--- a/src/fe-common/irc/fe-ignore.c
+++ b/src/fe-common/irc/fe-ignore.c
@@ -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)
diff --git a/src/irc/core/ignore.c b/src/irc/core/ignore.c
index 7d45d662..705d60c3 100644
--- a/src/irc/core/ignore.c
+++ b/src/irc/core/ignore.c
@@ -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);
diff --git a/src/irc/core/ignore.h b/src/irc/core/ignore.h
index 699bc445..bac02047 100644
--- a/src/irc/core/ignore.h
+++ b/src/irc/core/ignore.h
@@ -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 */