mirror of
https://github.com/irssi/irssi.git
synced 2024-09-01 04:14:16 -04:00
support cap away-notify
This commit is contained in:
parent
d418989f0c
commit
61d215acdd
@ -237,6 +237,21 @@ static void event_mode(IRC_SERVER_REC *server, const char *data,
|
||||
g_free(params);
|
||||
}
|
||||
|
||||
static void event_away_notify(IRC_SERVER_REC *server, const char *data,
|
||||
const char *nick, const char *addr)
|
||||
{
|
||||
char *params, *awaymsg;
|
||||
|
||||
g_return_if_fail(data != NULL);
|
||||
|
||||
params = event_get_params(data, 1 | PARAM_FLAG_GETREST,
|
||||
&awaymsg);
|
||||
|
||||
signal_emit("message irc away", 4,
|
||||
server, nick, addr, awaymsg);
|
||||
g_free(params);
|
||||
}
|
||||
|
||||
static void event_pong(IRC_SERVER_REC *server, const char *data, const char *nick)
|
||||
{
|
||||
char *params, *host, *reply;
|
||||
@ -458,6 +473,7 @@ void fe_events_init(void)
|
||||
signal_add("event error", (SIGNAL_FUNC) event_error);
|
||||
signal_add("event wallops", (SIGNAL_FUNC) event_wallops);
|
||||
signal_add("event silence", (SIGNAL_FUNC) event_silence);
|
||||
signal_add("event away", (SIGNAL_FUNC) event_away_notify);
|
||||
|
||||
signal_add("default event", (SIGNAL_FUNC) event_received);
|
||||
|
||||
@ -487,6 +503,7 @@ void fe_events_deinit(void)
|
||||
signal_remove("event error", (SIGNAL_FUNC) event_error);
|
||||
signal_remove("event wallops", (SIGNAL_FUNC) event_wallops);
|
||||
signal_remove("event silence", (SIGNAL_FUNC) event_silence);
|
||||
signal_remove("event away", (SIGNAL_FUNC) event_away_notify);
|
||||
|
||||
signal_remove("default event", (SIGNAL_FUNC) event_received);
|
||||
|
||||
|
@ -295,9 +295,43 @@ static void sig_message_irc_ctcp(IRC_SERVER_REC *server, const char *cmd,
|
||||
IRCTXT_CTCP_REQUESTED, nick, addr, cmd, data, oldtarget);
|
||||
}
|
||||
|
||||
static void sig_message_irc_away(IRC_SERVER_REC *server, const char *nick,
|
||||
const char *addr, const char *awaymsg)
|
||||
{
|
||||
GSList *tmp, *windows;
|
||||
|
||||
if (!settings_get_bool("away_notify_public"))
|
||||
return;
|
||||
|
||||
windows = NULL;
|
||||
for (tmp = server->channels; tmp != NULL; tmp = tmp->next) {
|
||||
int level = MSGLEVEL_CRAP;
|
||||
CHANNEL_REC *channel = tmp->data;
|
||||
WINDOW_REC *window =
|
||||
window_item_window((WI_ITEM_REC *) channel);
|
||||
|
||||
if (nicklist_find(channel, nick) == NULL ||
|
||||
g_slist_find(windows, window) != NULL)
|
||||
continue;
|
||||
|
||||
if (ignore_check_plus(SERVER(server), nick, addr,
|
||||
channel->visible_name, awaymsg, &level, TRUE))
|
||||
continue;
|
||||
|
||||
windows = g_slist_prepend(windows, window);
|
||||
|
||||
printformat(server, channel->visible_name, level,
|
||||
*awaymsg == '\0' ? IRCTXT_NOTIFY_UNAWAY_CHANNEL :
|
||||
IRCTXT_NOTIFY_AWAY_CHANNEL,
|
||||
nick, addr, channel->visible_name, awaymsg);
|
||||
}
|
||||
g_slist_free(windows);
|
||||
}
|
||||
|
||||
void fe_irc_messages_init(void)
|
||||
{
|
||||
settings_add_bool("misc", "notice_channel_context", TRUE);
|
||||
settings_add_bool("lookandfeel", "away_notify_public", FALSE);
|
||||
|
||||
signal_add_last("message own_public", (SIGNAL_FUNC) sig_message_own_public);
|
||||
signal_add_last("message irc op_public", (SIGNAL_FUNC) sig_message_irc_op_public);
|
||||
@ -308,6 +342,7 @@ void fe_irc_messages_init(void)
|
||||
signal_add_last("message irc notice", (SIGNAL_FUNC) sig_message_irc_notice);
|
||||
signal_add_last("message irc own_ctcp", (SIGNAL_FUNC) sig_message_own_ctcp);
|
||||
signal_add_last("message irc ctcp", (SIGNAL_FUNC) sig_message_irc_ctcp);
|
||||
signal_add_last("message irc away", (SIGNAL_FUNC) sig_message_irc_away);
|
||||
}
|
||||
|
||||
void fe_irc_messages_deinit(void)
|
||||
@ -321,4 +356,5 @@ void fe_irc_messages_deinit(void)
|
||||
signal_remove("message irc notice", (SIGNAL_FUNC) sig_message_irc_notice);
|
||||
signal_remove("message irc own_ctcp", (SIGNAL_FUNC) sig_message_own_ctcp);
|
||||
signal_remove("message irc ctcp", (SIGNAL_FUNC) sig_message_irc_ctcp);
|
||||
signal_remove("message irc away", (SIGNAL_FUNC) sig_message_irc_away);
|
||||
}
|
||||
|
@ -95,6 +95,8 @@ FORMAT_REC fecommon_irc_formats[] = {
|
||||
{ "away", "You have been marked as being away", 0 },
|
||||
{ "unaway", "You are no longer marked as being away", 0 },
|
||||
{ "nick_away", "{nick $0} is away: $1", 2, { 0, 0 } },
|
||||
{ "notify_away_channel", "{channick $0} {chanhost $1} is now away: {reason $3}", 4, { 0, 0, 0, 0 } },
|
||||
{ "notify_unaway_channel", "{channick_hilight $0} {chanhost $1} is no longer away", 3, { 0, 0, 0 } },
|
||||
{ "no_such_nick", "{nick $0}: No such nick/channel", 1, { 0 } },
|
||||
{ "nick_in_use", "Nick {nick $0} is already in use", 1, { 0 } },
|
||||
{ "nick_unavailable", "Nick {nick $0} is temporarily unavailable", 1, { 0 } },
|
||||
|
@ -71,6 +71,8 @@ enum {
|
||||
IRCTXT_AWAY,
|
||||
IRCTXT_UNAWAY,
|
||||
IRCTXT_NICK_AWAY,
|
||||
IRCTXT_NOTIFY_AWAY_CHANNEL,
|
||||
IRCTXT_NOTIFY_UNAWAY_CHANNEL,
|
||||
IRCTXT_NO_SUCH_NICK,
|
||||
IRCTXT_NICK_IN_USE,
|
||||
IRCTXT_NICK_UNAVAILABLE,
|
||||
|
@ -467,6 +467,20 @@ static void event_setname(SERVER_REC *server, const char *data, const char *nick
|
||||
g_slist_free(nicks);
|
||||
}
|
||||
|
||||
static void event_away_notify(IRC_SERVER_REC *server, const char *data, const char *nick, const char *add)
|
||||
{
|
||||
char *params, *awaymsg;
|
||||
|
||||
if (!IS_IRC_SERVER(server))
|
||||
return;
|
||||
|
||||
g_return_if_fail(data != NULL);
|
||||
|
||||
params = event_get_params(data, 1 | PARAM_FLAG_GETREST, &awaymsg);
|
||||
nicklist_update_flags(SERVER(server), nick, *awaymsg != '\0', -1);
|
||||
g_free(params);
|
||||
}
|
||||
|
||||
static void sig_usermode(SERVER_REC *server)
|
||||
{
|
||||
g_return_if_fail(IS_SERVER(server));
|
||||
@ -507,6 +521,7 @@ void irc_nicklist_init(void)
|
||||
signal_add_first("event 433", (SIGNAL_FUNC) event_nick_in_use);
|
||||
signal_add_first("event 437", (SIGNAL_FUNC) event_target_unavailable);
|
||||
signal_add_first("event 302", (SIGNAL_FUNC) event_userhost);
|
||||
signal_add_first("event away", (SIGNAL_FUNC) event_away_notify);
|
||||
signal_add("userhost event", (SIGNAL_FUNC) event_userhost);
|
||||
signal_add("event setname", (SIGNAL_FUNC) event_setname);
|
||||
signal_add("user mode changed", (SIGNAL_FUNC) sig_usermode);
|
||||
@ -530,6 +545,7 @@ void irc_nicklist_deinit(void)
|
||||
signal_remove("event 433", (SIGNAL_FUNC) event_nick_in_use);
|
||||
signal_remove("event 437", (SIGNAL_FUNC) event_target_unavailable);
|
||||
signal_remove("event 302", (SIGNAL_FUNC) event_userhost);
|
||||
signal_remove("event away", (SIGNAL_FUNC) event_away_notify);
|
||||
signal_remove("userhost event", (SIGNAL_FUNC) event_userhost);
|
||||
signal_remove("event setname", (SIGNAL_FUNC) event_setname);
|
||||
signal_remove("user mode changed", (SIGNAL_FUNC) sig_usermode);
|
||||
|
@ -237,6 +237,7 @@ static void server_init(IRC_SERVER_REC *server)
|
||||
irc_cap_toggle(server, CAP_EXTENDED_JOIN, TRUE);
|
||||
irc_cap_toggle(server, CAP_SETNAME, TRUE);
|
||||
irc_cap_toggle(server, CAP_INVITE_NOTIFY, TRUE);
|
||||
irc_cap_toggle(server, CAP_AWAY_NOTIFY, TRUE);
|
||||
|
||||
irc_send_cmd_now(server, "CAP LS " CAP_LS_VERSION);
|
||||
|
||||
|
@ -20,6 +20,7 @@
|
||||
#define CAP_EXTENDED_JOIN "extended-join"
|
||||
#define CAP_SETNAME "draft/setname"
|
||||
#define CAP_INVITE_NOTIFY "invite-notify"
|
||||
#define CAP_AWAY_NOTIFY "away-notify"
|
||||
|
||||
/* returns IRC_SERVER_REC if it's IRC server, NULL if it isn't */
|
||||
#define IRC_SERVER(server) \
|
||||
|
Loading…
Reference in New Issue
Block a user