diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2012-03-12 08:01:40 +0100 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2012-03-12 08:01:40 +0100 |
commit | d1c59c75365d370ff166eca4f00ae0e51cfb89f6 (patch) | |
tree | 52b0b14916d1de96285b6956a22585b34fd2107e /src/plugins/irc | |
parent | 595293defc3a4a9876e8bdade8a603af88457a5d (diff) | |
download | weechat-d1c59c75365d370ff166eca4f00ae0e51cfb89f6.zip |
irc: check notify immediately when adding a nick to notify list, improve first notify message for a nick (bug #35731)
Diffstat (limited to 'src/plugins/irc')
-rw-r--r-- | src/plugins/irc/irc-command.c | 1 | ||||
-rw-r--r-- | src/plugins/irc/irc-notify.c | 59 | ||||
-rw-r--r-- | src/plugins/irc/irc-notify.h | 4 |
3 files changed, 55 insertions, 9 deletions
diff --git a/src/plugins/irc/irc-command.c b/src/plugins/irc/irc-command.c index 852916059..c5d1112bc 100644 --- a/src/plugins/irc/irc-command.c +++ b/src/plugins/irc/irc-command.c @@ -2930,6 +2930,7 @@ irc_command_notify (void *data, struct t_gui_buffer *buffer, int argc, IRC_PLUGIN_NAME, IRC_COLOR_CHAT_NICK, ptr_notify->nick); + irc_notify_check_now (ptr_notify); } else { diff --git a/src/plugins/irc/irc-notify.c b/src/plugins/irc/irc-notify.c index e607266b4..e3fe8b557 100644 --- a/src/plugins/irc/irc-notify.c +++ b/src/plugins/irc/irc-notify.c @@ -193,7 +193,7 @@ irc_notify_new (struct t_irc_server *server, const char *nick, int check_away) new_notify->server = server; new_notify->nick = strdup (nick); new_notify->check_away = check_away; - new_notify->is_on_server = 0; + new_notify->is_on_server = -1; new_notify->away_message = NULL; new_notify->ison_received = 0; @@ -211,6 +211,35 @@ irc_notify_new (struct t_irc_server *server, const char *nick, int check_away) } /* + * irc_notify_check_now: check now ison/whois for a notify (called when a + * notify is added) + */ + +void +irc_notify_check_now (struct t_irc_notify *notify) +{ + if (notify->server->is_connected) + { + /* send the ISON for nick */ + irc_redirect_new (notify->server, "ison", "notify", 1, + NULL, 0, NULL); + irc_server_sendf (notify->server, + IRC_SERVER_SEND_OUTQ_PRIO_LOW, NULL, + "ISON :%s", notify->nick); + + if (notify->check_away) + { + /* send the WHOIS for nick */ + irc_redirect_new (notify->server, "whois", "notify", 1, + notify->nick, 0, "301,401"); + irc_server_sendf (notify->server, + IRC_SERVER_SEND_OUTQ_PRIO_LOW, NULL, + "WHOIS :%s", notify->nick); + } + } +} + +/* * irc_notify_new_for_server: create notify list for server with option * "irc.server.xxx.notify" */ @@ -332,7 +361,8 @@ irc_notify_free_all (struct t_irc_server *server) void irc_notify_display (struct t_gui_buffer *buffer, struct t_irc_notify *notify) { - if (!notify->is_on_server && !notify->away_message) + if ((notify->is_on_server < 0) + || (!notify->is_on_server && !notify->away_message)) { weechat_printf (buffer, " %s%s%s @ %s%s%s: %s%s", @@ -342,7 +372,10 @@ irc_notify_display (struct t_gui_buffer *buffer, struct t_irc_notify *notify) IRC_COLOR_CHAT_SERVER, notify->server->name, IRC_COLOR_RESET, - IRC_COLOR_MESSAGE_QUIT, + (notify->is_on_server < 0) ? "" : IRC_COLOR_MESSAGE_QUIT, + (notify->is_on_server < 0) ? + /* TRANSLATORS: "unknown" is the status for /notify when ison answer has not been received (check pending) */ + _("unknown") : _("offline")); } else @@ -462,20 +495,28 @@ irc_notify_set_is_on_server (struct t_irc_notify *notify, if (notify->is_on_server == is_on_server) return; - notify->is_on_server = is_on_server; - weechat_printf_tags (notify->server->buffer, irc_notify_get_tags (irc_config_look_notify_tags_ison), - (notify->is_on_server) ? - _("%snotify: %s%s%s has joined %s%s") : - _("%snotify: %s%s%s has quit %s%s"), + (notify->is_on_server < 0) ? + ((is_on_server) ? + /* TRANSLATORS: final "%s%s" is the server name */ + _("%snotify: %s%s%s is connected on %s%s") : + /* TRANSLATORS: final "%s%s" is the server name */ + _("%snotify: %s%s%s is offline on %s%s")) : + ((is_on_server) ? + /* TRANSLATORS: final "%s%s" is the server name */ + _("%snotify: %s%s%s has joined %s%s") : + /* TRANSLATORS: final "%s%s" is the server name */ + _("%snotify: %s%s%s has quit %s%s")), weechat_prefix ("network"), IRC_COLOR_CHAT_NICK, notify->nick, - (notify->is_on_server) ? + (is_on_server) ? IRC_COLOR_MESSAGE_JOIN : IRC_COLOR_MESSAGE_QUIT, IRC_COLOR_CHAT_SERVER, notify->server->name); + + notify->is_on_server = is_on_server; } /* diff --git a/src/plugins/irc/irc-notify.h b/src/plugins/irc/irc-notify.h index 7bd2319dd..d5e2acc41 100644 --- a/src/plugins/irc/irc-notify.h +++ b/src/plugins/irc/irc-notify.h @@ -29,6 +29,9 @@ struct t_irc_notify int check_away; /* check away status (with whois) */ /* current state of nick */ int is_on_server; /* 1 if nick is currently on server */ + /* 0 if nick is not on server */ + /* -1 for unknown status (check is */ + /* in progress) */ /* (using answer of ison command) */ char *away_message; /* current away message, NULL if */ /* nick is not away (using answer of */ @@ -47,6 +50,7 @@ extern void irc_notify_set_server_option (struct t_irc_server *server); extern struct t_irc_notify *irc_notify_new (struct t_irc_server *server, const char *nick, int check_away); +extern void irc_notify_check_now (struct t_irc_notify *notify); extern void irc_notify_new_for_server (struct t_irc_server *server); extern void irc_notify_new_for_all_servers (); extern void irc_notify_free (struct t_irc_server *server, |