1
0
mirror of https://github.com/irssi/irssi.git synced 2024-07-21 03:14:16 -04:00

Remove /notify -idle, it can only work with not-nice automated remote whois.

(causes infrequent "server load too heavy" etc)
If people really want this, they should write a script.


git-svn-id: http://svn.irssi.org/repos/irssi/trunk@4632 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Jilles Tjoelker 2007-10-31 22:58:44 +00:00 committed by jilles
parent d9782fab84
commit 78dad04c7b
11 changed files with 19 additions and 115 deletions

View File

@ -2,8 +2,6 @@
@SYNTAX:notify@
-away: Notifies about away-status changes
-idle: Notifies if idle time is first larger than <minutes>
(default is hour) and then it drops down.
-list: Lists the notify list entries with all their settings
<mask>: Either a simple "nick" or "nick!*@*blah.org".
The nick can't contain wildcards, but the user/host can.

View File

@ -828,11 +828,9 @@
are in IRC all the time. So I made a bit more featureful notify
list:
/NOTIFY [-list] [-away] [-idle [minutes]] <mask> [network [network...]]
/NOTIFY [-list] [-away] <mask> [network [network...]]
-away: Notifies about away-status changes
-idle: Notifies if idle time is first larger than <minutes>
(default is hour) and then it drops down.
-list: Lists the notify list entries with all their settings
<mask>: Either a simple "nick" or "nick!*@*blah.org". The nick
can't contain wildcards, but the user/host can.

View File

@ -148,19 +148,14 @@ static void cmd_notify_show(void)
static void notifylist_print(NOTIFYLIST_REC *rec)
{
char idle[10+MAX_INT_STRLEN], *ircnets;
if (rec->idle_check_time <= 0)
idle[0] = '\0';
else
g_snprintf(idle, sizeof(idle), "-idle %d", rec->idle_check_time/60);
char *ircnets;
ircnets = rec->ircnets == NULL ? NULL :
g_strjoinv(",", rec->ircnets);
printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, IRCTXT_NOTIFY_LIST,
rec->mask, ircnets != NULL ? ircnets : "",
rec->away_check ? "-away" : "", idle);
rec->away_check ? "-away" : "");
g_free_not_null(ircnets);
}
@ -227,18 +222,6 @@ static void notifylist_away(IRC_SERVER_REC *server, const char *nick,
}
}
static void notifylist_unidle(IRC_SERVER_REC *server, const char *nick,
const char *username, const char *host,
const char *realname, const char *awaymsg)
{
g_return_if_fail(nick != NULL);
printformat(server, nick, MSGLEVEL_CLIENTNOTICE,
IRCTXT_NOTIFY_UNIDLE, nick, username, host, realname,
awaymsg != NULL ? awaymsg : "",
server->connrec->chatnet == NULL ? "IRC" : server->connrec->chatnet);
}
void fe_irc_notifylist_init(void)
{
theme_register(fecommon_irc_notifylist_formats);
@ -247,7 +230,6 @@ void fe_irc_notifylist_init(void)
signal_add("notifylist joined", (SIGNAL_FUNC) notifylist_joined);
signal_add("notifylist left", (SIGNAL_FUNC) notifylist_left);
signal_add("notifylist away changed", (SIGNAL_FUNC) notifylist_away);
signal_add("notifylist unidle", (SIGNAL_FUNC) notifylist_unidle);
command_set_options("notify", "list");
@ -263,5 +245,4 @@ void fe_irc_notifylist_deinit(void)
signal_remove("notifylist joined", (SIGNAL_FUNC) notifylist_joined);
signal_remove("notifylist left", (SIGNAL_FUNC) notifylist_left);
signal_remove("notifylist away changed", (SIGNAL_FUNC) notifylist_away);
signal_remove("notifylist unidle", (SIGNAL_FUNC) notifylist_unidle);
}

View File

@ -6,15 +6,12 @@
typedef struct {
char *nick;
char *user, *host, *realname, *awaymsg;
int idle_time;
unsigned int host_ok:1; /* host matches the one in notifylist = this is the right person*/
unsigned int away_ok:1; /* not away, or we don't care about it */
unsigned int idle_ok:1; /* idle time is low enough, or we don't care about it */
unsigned int away:1; /* nick is away */
unsigned int join_announced:1; /* join to IRC has been announced */
unsigned int idle_changed:1; /* idle time is lower than in last check */
time_t last_whois;
} NOTIFY_NICK_REC;

View File

@ -26,13 +26,13 @@
#include "notifylist.h"
/* SYNTAX: NOTIFY [-away] [-idle [<time>]] <mask> [<ircnets>] */
/* SYNTAX: NOTIFY [-away] <mask> [<ircnets>] */
static void cmd_notify(gchar *data)
{
GHashTable *optlist;
char *mask, *ircnets, *idletime;
char *mask, *ircnets;
void *free_arg;
int away_check, idle_check_time;
int away_check;
g_return_if_fail(data != NULL);
@ -41,19 +41,9 @@ static void cmd_notify(gchar *data)
return;
if (*mask == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
idletime = g_hash_table_lookup(optlist, "idle");
if (idletime == NULL)
idle_check_time = 0;
else if (*idletime == '\0')
idle_check_time = settings_get_time("notify_idle_time");
else {
if (!parse_time_interval(idletime, &idle_check_time))
cmd_param_error(CMDERR_INVALID_TIME);
}
away_check = g_hash_table_lookup(optlist, "away") != NULL;
notifylist_remove(mask);
notifylist_add(mask, ircnets, away_check, idle_check_time/1000);
notifylist_add(mask, ircnets, away_check);
cmd_params_free(free_arg);
}
@ -77,11 +67,10 @@ static void cmd_unnotify(const char *data)
void notifylist_commands_init(void)
{
settings_add_time("misc", "notify_idle_time", "1hour");
command_bind("notify", NULL, (SIGNAL_FUNC) cmd_notify);
command_bind("unnotify", NULL, (SIGNAL_FUNC) cmd_unnotify);
command_set_options("notify", "-idle away");
command_set_options("notify", "away");
}
void notifylist_commands_deinit(void)

View File

@ -181,7 +181,6 @@ static void whois_send(IRC_SERVER_REC *server, const char *nicks,
"event 318", "notifylist event whois end",
"event 311", "notifylist event whois",
"event 301", "notifylist event whois away",
"event 317", "notifylist event whois idle",
"", "event empty", NULL);
g_free(str);
@ -247,8 +246,7 @@ static void ison_check_joins(IRC_SERVER_REC *server)
char *nick = tmp->data;
notify = notifylist_find(nick, server->connrec->chatnet);
send_whois = notify != NULL &&
(notify->away_check || notify->idle_check_time > 0);
send_whois = notify != NULL && notify->away_check;
rec = notify_nick_find(server, nick);
if (rec != NULL) {
@ -261,7 +259,7 @@ static void ison_check_joins(IRC_SERVER_REC *server)
}
if (send_whois) {
/* we need away message or idle time -
/* we need away message -
send the WHOIS reply to the nick's server */
rec->last_whois = now;
whois_send_server(server, nick);

View File

@ -37,11 +37,6 @@ void notifylist_add_config(NOTIFYLIST_REC *rec)
else
iconfig_node_set_str(node, "away_check", NULL);
if (rec->idle_check_time > 0)
iconfig_node_set_int(node, "idle_check_time", rec->idle_check_time/60);
else
iconfig_node_set_str(node, "idle_check_time", NULL);
iconfig_node_set_str(node, "ircnets", NULL);
if (rec->ircnets != NULL && *rec->ircnets != NULL) {
node = config_node_section(node, "ircnets", NODE_TYPE_LIST);
@ -77,7 +72,6 @@ void notifylist_read_config(void)
rec->mask = g_strdup(node->key);
rec->away_check = config_node_get_bool(node, "away_check", FALSE);
rec->idle_check_time = config_node_get_int(node, "idle_check_time", 0)*60;
node = config_node_section(node, "ircnets", -1);
if (node != NULL) rec->ircnets = config_node_get_list(node);

View File

@ -63,35 +63,10 @@ static void event_whois(IRC_SERVER_REC *server, const char *data)
nickrec->away = FALSE;
nickrec->host_ok = TRUE;
nickrec->idle_ok = TRUE;
}
g_free(params);
}
static void event_whois_idle(IRC_SERVER_REC *server, const char *data)
{
NOTIFY_NICK_REC *nickrec;
NOTIFYLIST_REC *notify;
char *params, *nick, *secstr;
long secs;
g_return_if_fail(data != NULL);
params = event_get_params(data, 3, NULL, &nick, &secstr);
secs = atol(secstr);
notify = notifylist_find(nick, server->connrec->chatnet);
nickrec = notify_nick_find(server, nick);
if (notify != NULL && nickrec != NULL) {
nickrec->idle_changed = secs < nickrec->idle_time &&
nickrec->idle_time > notify->idle_check_time;
nickrec->idle_time = secs;
}
g_free(params);
}
static void event_whois_away(IRC_SERVER_REC *server, const char *data)
{
NOTIFY_NICK_REC *nickrec;
@ -135,12 +110,9 @@ static void event_whois_end(IRC_SERVER_REC *server, const char *data)
event = NULL;
if (!rec->join_announced) {
rec->join_announced = TRUE;
rec->idle_time = 0;
if (away_ok) event = "notifylist joined";
} else if (notify->away_check && rec->away_ok == rec->away)
event = "notifylist away changed";
else if (notify->idle_check_time > 0 && rec->idle_changed)
event = "notifylist unidle";
if (event != NULL) {
signal_emit(event, 6, server, rec->nick,
@ -149,9 +121,6 @@ static void event_whois_end(IRC_SERVER_REC *server, const char *data)
rec->realname != NULL ? rec->realname : "??",
rec->awaymsg);
}
rec->idle_ok = notify->idle_check_time <= 0 ||
rec->idle_time <= notify->idle_check_time;
rec->idle_changed = FALSE;
rec->away_ok = away_ok;
}
}
@ -168,7 +137,6 @@ void notifylist_whois_init(void)
signal_add("notifylist event whois", (SIGNAL_FUNC) event_whois);
signal_add("notifylist event whois away", (SIGNAL_FUNC) event_whois_away);
signal_add("notifylist event whois idle", (SIGNAL_FUNC) event_whois_idle);
signal_add("notifylist event whois end", (SIGNAL_FUNC) event_whois_end);
expando_create("D", expando_lastnotify,
"notifylist event whois", EXPANDO_ARG_SERVER, NULL);
@ -180,7 +148,6 @@ void notifylist_whois_deinit(void)
signal_remove("notifylist event whois", (SIGNAL_FUNC) event_whois);
signal_remove("notifylist event whois away", (SIGNAL_FUNC) event_whois_away);
signal_remove("notifylist event whois idle", (SIGNAL_FUNC) event_whois_idle);
signal_remove("notifylist event whois end", (SIGNAL_FUNC) event_whois_end);
expando_destroy("D", expando_lastnotify);
}

View File

@ -35,7 +35,7 @@
GSList *notifies;
NOTIFYLIST_REC *notifylist_add(const char *mask, const char *ircnets,
int away_check, int idle_check_time)
int away_check)
{
NOTIFYLIST_REC *rec;
@ -46,7 +46,6 @@ NOTIFYLIST_REC *notifylist_add(const char *mask, const char *ircnets,
rec->ircnets = ircnets == NULL || *ircnets == '\0' ? NULL :
g_strsplit(ircnets, " ", -1);
rec->away_check = away_check;
rec->idle_check_time = idle_check_time;
notifylist_add_config(rec);
@ -138,7 +137,7 @@ int notifylist_ison_server(IRC_SERVER_REC *server, const char *nick)
g_return_val_if_fail(IS_IRC_SERVER(server), FALSE);
rec = notify_nick_find(server, nick);
return rec != NULL && rec->host_ok && rec->away_ok && rec->idle_ok;
return rec != NULL && rec->host_ok && rec->away_ok;
}
static IRC_SERVER_REC *notifylist_ison_serverlist(const char *nick, const char *taglist)
@ -237,24 +236,6 @@ void notifylist_left(IRC_SERVER_REC *server, NOTIFY_NICK_REC *rec)
notify_nick_destroy(rec);
}
static void notifylist_idle_reset(IRC_SERVER_REC *server, const char *nick)
{
NOTIFY_NICK_REC *rec;
NOTIFYLIST_REC *notify;
notify = notifylist_find(nick, server->connrec->chatnet);
rec = notify_nick_find(server, nick);
if (notify != NULL && rec != NULL && notify->idle_check_time > 0 &&
rec->idle_time > notify->idle_check_time) {
rec->idle_time = 0;
signal_emit("notifylist unidle", 6,
server, rec->nick,
rec->user, rec->host,
rec->realname, rec->awaymsg);
}
}
static void event_quit(IRC_SERVER_REC *server, const char *data,
const char *nick)
{
@ -308,7 +289,6 @@ static void notifylist_check_join(IRC_SERVER_REC *server, const char *nick,
if (away != -1) rec->away = away;
rec->host_ok = TRUE;
rec->join_announced = TRUE;
rec->idle_time = 0;
signal_emit("notifylist joined", 6,
server, rec->nick, rec->user, rec->host, realname, NULL);
@ -320,7 +300,6 @@ static void event_privmsg(IRC_SERVER_REC *server, const char *data,
{
if (nick != NULL) {
notifylist_check_join(server, nick, address, "", -1);
notifylist_idle_reset(server, nick);
}
}

View File

@ -7,9 +7,6 @@ typedef struct {
/* notify when AWAY status changes (uses /USERHOST) */
unsigned int away_check:1;
/* notify when idle time is reset and it was bigger than this
(uses /WHOIS and PRIVMSG events) */
int idle_check_time;
} NOTIFYLIST_REC;
extern GSList *notifies;
@ -18,7 +15,7 @@ void notifylist_init(void);
void notifylist_deinit(void);
NOTIFYLIST_REC *notifylist_add(const char *mask, const char *ircnets,
int away_check, int idle_check_time);
int away_check);
void notifylist_remove(const char *mask);
IRC_SERVER_REC *notifylist_ison(const char *nick, const char *serverlist);

View File

@ -18,6 +18,12 @@ notifylist_add(mask, ircnets, away_check, idle_check_time)
char *ircnets
int away_check
int idle_check_time
CODE:
if (idle_check_time != 0)
croak("Notify -idle has been removed");
RETVAL = notifylist_add(mask, ircnets, away_check);
OUTPUT:
RETVAL
void
notifylist_remove(mask)