mirror of
https://github.com/irssi/irssi.git
synced 2024-12-04 14:46:39 -05: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 "irc-server.h"
|
||||||
#include "ignore.h"
|
#include "ignore.h"
|
||||||
|
|
||||||
|
static void fe_unignore(IGNORE_REC *rec);
|
||||||
|
|
||||||
static char *ignore_get_key(IGNORE_REC *rec)
|
static char *ignore_get_key(IGNORE_REC *rec)
|
||||||
{
|
{
|
||||||
char *chans, *ret;
|
char *chans, *ret;
|
||||||
@ -125,6 +127,12 @@ static void ignore_print(int index, IGNORE_REC *rec)
|
|||||||
g_free(levels);
|
g_free(levels);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int unignore_timeout(IGNORE_REC *rec)
|
||||||
|
{
|
||||||
|
fe_unignore(rec);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
static void cmd_ignore_show(void)
|
static void cmd_ignore_show(void)
|
||||||
{
|
{
|
||||||
GSList *tmp;
|
GSList *tmp;
|
||||||
@ -143,14 +151,14 @@ static void cmd_ignore_show(void)
|
|||||||
static void cmd_ignore(const char *data)
|
static void cmd_ignore(const char *data)
|
||||||
{
|
{
|
||||||
/* /IGNORE [-regexp | -word] [-pattern <pattern>] [-except]
|
/* /IGNORE [-regexp | -word] [-pattern <pattern>] [-except]
|
||||||
[-replies] [-channels <channel>] <mask> <levels>
|
[-replies] [-channels <channel>] [-time <secs>] <mask> <levels>
|
||||||
OR
|
OR
|
||||||
|
|
||||||
/IGNORE [-regexp | -word] [-pattern <pattern>] [-except] [-replies]
|
/IGNORE [-regexp | -word] [-pattern <pattern>] [-except] [-replies]
|
||||||
<channels> <levels> */
|
[-time <secs>] <channels> <levels> */
|
||||||
GHashTable *optlist;
|
GHashTable *optlist;
|
||||||
IGNORE_REC *rec;
|
IGNORE_REC *rec;
|
||||||
char *patternarg, *chanarg, *mask, *levels, *key;
|
char *patternarg, *chanarg, *mask, *levels, *key, *timestr;
|
||||||
char **channels;
|
char **channels;
|
||||||
void *free_arg;
|
void *free_arg;
|
||||||
int new_ignore;
|
int new_ignore;
|
||||||
@ -201,6 +209,8 @@ static void cmd_ignore(const char *data)
|
|||||||
rec->regexp = g_hash_table_lookup(optlist, "regexp") != NULL;
|
rec->regexp = g_hash_table_lookup(optlist, "regexp") != NULL;
|
||||||
rec->fullword = g_hash_table_lookup(optlist, "word") != NULL;
|
rec->fullword = g_hash_table_lookup(optlist, "word") != NULL;
|
||||||
rec->replies = g_hash_table_lookup(optlist, "replies") != 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) {
|
if (rec->level == 0 && rec->except_level == 0) {
|
||||||
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_UNIGNORED,
|
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_UNIGNORED,
|
||||||
@ -213,6 +223,9 @@ static void cmd_ignore(const char *data)
|
|||||||
g_free(levels);
|
g_free(levels);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (rec->time > 0)
|
||||||
|
rec->time_tag = g_timeout_add(rec->time*1000, (GSourceFunc) unignore_timeout, rec);
|
||||||
|
|
||||||
if (new_ignore)
|
if (new_ignore)
|
||||||
ignore_add_rec(rec);
|
ignore_add_rec(rec);
|
||||||
else
|
else
|
||||||
@ -221,11 +234,23 @@ static void cmd_ignore(const char *data)
|
|||||||
cmd_params_free(free_arg);
|
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)
|
static void cmd_unignore(const char *data)
|
||||||
{
|
{
|
||||||
IGNORE_REC *rec;
|
IGNORE_REC *rec;
|
||||||
GSList *tmp;
|
GSList *tmp;
|
||||||
char *key;
|
|
||||||
|
|
||||||
if (is_numeric(data, ' ')) {
|
if (is_numeric(data, ' ')) {
|
||||||
/* with index number */
|
/* with index number */
|
||||||
@ -241,15 +266,8 @@ static void cmd_unignore(const char *data)
|
|||||||
|
|
||||||
if (rec == NULL)
|
if (rec == NULL)
|
||||||
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_IGNORE_NOT_FOUND, data);
|
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_IGNORE_NOT_FOUND, data);
|
||||||
else {
|
else
|
||||||
key = ignore_get_key(rec);
|
fe_unignore(rec);
|
||||||
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_UNIGNORED, key);
|
|
||||||
g_free(key);
|
|
||||||
|
|
||||||
rec->level = 0;
|
|
||||||
rec->except_level = 0;
|
|
||||||
ignore_update_rec(rec);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void fe_ignore_init(void)
|
void fe_ignore_init(void)
|
||||||
@ -257,7 +275,7 @@ void fe_ignore_init(void)
|
|||||||
command_bind("ignore", NULL, (SIGNAL_FUNC) cmd_ignore);
|
command_bind("ignore", NULL, (SIGNAL_FUNC) cmd_ignore);
|
||||||
command_bind("unignore", NULL, (SIGNAL_FUNC) cmd_unignore);
|
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)
|
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)
|
if (rec->level == 0 && rec->except_level == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (rec->time > 0)
|
||||||
|
return;
|
||||||
|
|
||||||
node = iconfig_node_traverse("(ignores", TRUE);
|
node = iconfig_node_traverse("(ignores", TRUE);
|
||||||
node = config_node_section(node, NULL, NODE_TYPE_BLOCK);
|
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);
|
ignores = g_slist_remove(ignores, rec);
|
||||||
signal_emit("ignore destroyed", 1, 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);
|
if (rec->channels != NULL) g_strfreev(rec->channels);
|
||||||
g_free_not_null(rec->mask);
|
g_free_not_null(rec->mask);
|
||||||
g_free_not_null(rec->servertag);
|
g_free_not_null(rec->servertag);
|
||||||
|
@ -10,6 +10,9 @@ typedef struct {
|
|||||||
int level; /* ignore these levels */
|
int level; /* ignore these levels */
|
||||||
int except_level; /* don't 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 regexp:1;
|
||||||
int fullword:1;
|
int fullword:1;
|
||||||
int replies:1; /* ignore replies to nick in channel */
|
int replies:1; /* ignore replies to nick in channel */
|
||||||
|
Loading…
Reference in New Issue
Block a user