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

move away message to fe-common/core

This commit is contained in:
ailin-nemui 2019-08-14 22:52:38 +02:00
parent 61d215acdd
commit 5f13614d47
7 changed files with 27 additions and 41 deletions

View File

@ -587,6 +587,25 @@ static void sig_message_topic(SERVER_REC *server, const char *channel,
nick, channel, topic, address);
}
static void sig_message_away_notify(SERVER_REC *server, const char *nick,
const char *addr, const char *awaymsg)
{
int txt = *awaymsg == '\0' ? TXT_NOTIFY_UNAWAY_CHANNEL :
TXT_NOTIFY_AWAY_CHANNEL;
if (!settings_get_bool("away_notify_public"))
return;
spread_server_message_to_windows(server, FALSE,
FALSE,
MSGLEVEL_CRAP,
txt, txt,
nick, addr,
awaymsg,
awaymsg
);
}
static int printnick_exists(NICK_REC *first, NICK_REC *ignore,
const char *nick)
{
@ -730,6 +749,7 @@ void fe_messages_init(void)
settings_add_bool("lookandfeel", "print_active_channel", FALSE);
settings_add_bool("lookandfeel", "show_quit_once", FALSE);
settings_add_bool("lookandfeel", "show_own_nickchange_once", FALSE);
settings_add_bool("lookandfeel", "away_notify_public", FALSE);
signal_add_last("message public", (SIGNAL_FUNC) sig_message_public);
signal_add_last("message private", (SIGNAL_FUNC) sig_message_private);
@ -744,6 +764,7 @@ void fe_messages_init(void)
signal_add_last("message invite", (SIGNAL_FUNC) sig_message_invite);
signal_add_last("message invite_other", (SIGNAL_FUNC) sig_message_invite_other);
signal_add_last("message topic", (SIGNAL_FUNC) sig_message_topic);
signal_add_last("message away_notify", (SIGNAL_FUNC) sig_message_away_notify);
signal_add("nicklist new", (SIGNAL_FUNC) sig_nicklist_new);
signal_add("nicklist remove", (SIGNAL_FUNC) sig_nicklist_remove);
@ -770,6 +791,7 @@ void fe_messages_deinit(void)
signal_remove("message invite_other", (SIGNAL_FUNC) sig_message_invite_other);
signal_remove("message invite", (SIGNAL_FUNC) sig_message_invite);
signal_remove("message topic", (SIGNAL_FUNC) sig_message_topic);
signal_remove("message away_notify", (SIGNAL_FUNC) sig_message_away_notify);
signal_remove("nicklist new", (SIGNAL_FUNC) sig_nicklist_new);
signal_remove("nicklist remove", (SIGNAL_FUNC) sig_nicklist_remove);

View File

@ -106,6 +106,8 @@ FORMAT_REC fecommon_core_formats[] = {
{ "topic_unset", "Topic unset by {nick $0} on {channel $1}", 4, { 0, 0, 0, 0 } },
{ "your_nick_changed", "You're now known as {nick $1}", 4, { 0, 0, 0, 0 } },
{ "nick_changed", "{channick $0} is now known as {channick_hilight $1}", 4, { 0, 0, 0, 0 } },
{ "notify_away_channel", "{channick $0} {chanhost $1} is now away: {reason $2}", 4, { 0, 0, 0, 0 } },
{ "notify_unaway_channel", "{channick_hilight $0} {chanhost $1} is no longer away", 4, { 0, 0, 0, 0 } },
{ "talking_in", "You are now talking in {channel $0}", 1, { 0 } },
{ "not_in_channels", "You are not on any channels", 0 },
{ "current_channel", "Current channel {channel $0}", 1, { 0 } },

View File

@ -82,6 +82,8 @@ enum {
TXT_TOPIC_UNSET,
TXT_YOUR_NICK_CHANGED,
TXT_NICK_CHANGED,
TXT_NOTIFY_AWAY_CHANNEL,
TXT_NOTIFY_UNAWAY_CHANNEL,
TXT_TALKING_IN,
TXT_NOT_IN_CHANNELS,
TXT_CURRENT_CHANNEL,

View File

@ -247,7 +247,7 @@ static void event_away_notify(IRC_SERVER_REC *server, const char *data,
params = event_get_params(data, 1 | PARAM_FLAG_GETREST,
&awaymsg);
signal_emit("message irc away", 4,
signal_emit("message away_notify", 4,
server, nick, addr, awaymsg);
g_free(params);
}

View File

@ -295,43 +295,9 @@ 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);
@ -342,7 +308,6 @@ 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)
@ -356,5 +321,4 @@ 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);
}

View File

@ -95,8 +95,6 @@ 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 } },

View File

@ -71,8 +71,6 @@ 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,