mirror of
https://github.com/weechat/weechat.git
synced 2026-07-08 09:05:43 +02:00
irc: use computed nick color in many messages instead of option weechat.color.chat_nick
This commit is contained in:
@@ -778,7 +778,9 @@ irc_channel_display_nick_back_in_pv (struct t_irc_server *server,
|
||||
weechat_printf (ptr_channel->buffer,
|
||||
_("%s%s%s %s(%s%s%s)%s is back on server"),
|
||||
weechat_prefix ("join"),
|
||||
irc_nick_color_for_server_message (nick, nickname),
|
||||
irc_nick_color_for_server_message (server,
|
||||
nick,
|
||||
nickname),
|
||||
(nick) ? nick->name : nickname,
|
||||
IRC_COLOR_CHAT_DELIMITERS,
|
||||
IRC_COLOR_CHAT_HOST,
|
||||
|
||||
@@ -948,7 +948,8 @@ irc_command_ctcp (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
NULL),
|
||||
_("%sCTCP query to %s%s%s: %s%s%s%s%s"),
|
||||
weechat_prefix ("network"),
|
||||
IRC_COLOR_CHAT_NICK,
|
||||
irc_nick_color_for_message (ptr_server,
|
||||
NULL, argv[1]),
|
||||
argv[1],
|
||||
IRC_COLOR_RESET,
|
||||
IRC_COLOR_CHAT_CHANNEL,
|
||||
@@ -971,7 +972,8 @@ irc_command_ctcp (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
NULL),
|
||||
_("%sCTCP query to %s%s%s: %s%s%s%s%s"),
|
||||
weechat_prefix ("network"),
|
||||
IRC_COLOR_CHAT_NICK,
|
||||
irc_nick_color_for_message (ptr_server, NULL,
|
||||
argv[1]),
|
||||
argv[1],
|
||||
IRC_COLOR_RESET,
|
||||
IRC_COLOR_CHAT_CHANNEL,
|
||||
@@ -2593,7 +2595,9 @@ irc_command_msg (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
"%sMSG%s(%s%s%s)%s: %s",
|
||||
weechat_prefix ("network"),
|
||||
IRC_COLOR_CHAT_DELIMITERS,
|
||||
IRC_COLOR_CHAT_NICK,
|
||||
irc_nick_color_for_message (ptr_server,
|
||||
NULL,
|
||||
targets[i]),
|
||||
targets[i],
|
||||
IRC_COLOR_CHAT_DELIMITERS,
|
||||
IRC_COLOR_RESET,
|
||||
@@ -2625,7 +2629,9 @@ irc_command_msg (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
"%sMSG%s(%s%s%s)%s: %s",
|
||||
weechat_prefix ("network"),
|
||||
IRC_COLOR_CHAT_DELIMITERS,
|
||||
IRC_COLOR_CHAT_NICK,
|
||||
irc_nick_color_for_message (ptr_server,
|
||||
NULL,
|
||||
targets[i]),
|
||||
targets[i],
|
||||
IRC_COLOR_CHAT_DELIMITERS,
|
||||
IRC_COLOR_RESET,
|
||||
@@ -2821,7 +2827,7 @@ irc_command_notice (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
/* TRANSLATORS: "Notice" is command name in IRC protocol (translation is frequently the same word) */
|
||||
_("Notice"),
|
||||
IRC_COLOR_RESET,
|
||||
(is_channel) ? IRC_COLOR_CHAT_CHANNEL : IRC_COLOR_CHAT_NICK,
|
||||
(is_channel) ? IRC_COLOR_CHAT_CHANNEL : irc_nick_color_for_message (ptr_server, NULL, argv[arg_target]),
|
||||
argv[arg_target],
|
||||
IRC_COLOR_RESET,
|
||||
(string) ? string : str_args);
|
||||
@@ -2928,7 +2934,9 @@ irc_command_notify (void *data, struct t_gui_buffer *buffer, int argc,
|
||||
weechat_printf (ptr_server->buffer,
|
||||
_("%s: notification added for %s%s"),
|
||||
IRC_PLUGIN_NAME,
|
||||
IRC_COLOR_CHAT_NICK,
|
||||
irc_nick_color_for_server_message (ptr_server,
|
||||
NULL,
|
||||
ptr_notify->nick),
|
||||
ptr_notify->nick);
|
||||
irc_notify_check_now (ptr_notify);
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ irc_ctcp_display_request (struct t_irc_server *server,
|
||||
irc_protocol_tags (command, "irc_ctcp", NULL),
|
||||
_("%sCTCP requested by %s%s%s: %s%s%s%s%s%s"),
|
||||
weechat_prefix ("network"),
|
||||
IRC_COLOR_CHAT_NICK,
|
||||
irc_nick_color_for_message (server, NULL, nick),
|
||||
nick,
|
||||
IRC_COLOR_RESET,
|
||||
IRC_COLOR_CHAT_CHANNEL,
|
||||
@@ -192,7 +192,9 @@ irc_ctcp_display_reply_from_nick (struct t_irc_server *server,
|
||||
_("%sCTCP reply from %s%s%s: %s%s%s "
|
||||
"%ld.%ld %s"),
|
||||
weechat_prefix ("network"),
|
||||
IRC_COLOR_CHAT_NICK,
|
||||
irc_nick_color_for_message (server,
|
||||
NULL,
|
||||
nick),
|
||||
nick,
|
||||
IRC_COLOR_RESET,
|
||||
IRC_COLOR_CHAT_CHANNEL,
|
||||
@@ -218,7 +220,8 @@ irc_ctcp_display_reply_from_nick (struct t_irc_server *server,
|
||||
NULL),
|
||||
_("%sCTCP reply from %s%s%s: %s%s%s%s%s"),
|
||||
weechat_prefix ("network"),
|
||||
IRC_COLOR_CHAT_NICK,
|
||||
irc_nick_color_for_message (server, NULL,
|
||||
nick),
|
||||
nick,
|
||||
IRC_COLOR_RESET,
|
||||
IRC_COLOR_CHAT_CHANNEL,
|
||||
@@ -237,7 +240,8 @@ irc_ctcp_display_reply_from_nick (struct t_irc_server *server,
|
||||
irc_protocol_tags (command, NULL, NULL),
|
||||
_("%sCTCP reply from %s%s%s: %s%s%s%s%s"),
|
||||
weechat_prefix ("network"),
|
||||
IRC_COLOR_CHAT_NICK,
|
||||
irc_nick_color_for_message (server, NULL,
|
||||
nick),
|
||||
nick,
|
||||
IRC_COLOR_RESET,
|
||||
IRC_COLOR_CHAT_CHANNEL,
|
||||
@@ -300,7 +304,8 @@ irc_ctcp_reply_to_nick (struct t_irc_server *server,
|
||||
NULL),
|
||||
_("%sCTCP reply to %s%s%s: %s%s%s%s%s"),
|
||||
weechat_prefix ("network"),
|
||||
IRC_COLOR_CHAT_NICK,
|
||||
irc_nick_color_for_message (server, NULL,
|
||||
nick),
|
||||
nick,
|
||||
IRC_COLOR_RESET,
|
||||
IRC_COLOR_CHAT_CHANNEL,
|
||||
@@ -837,7 +842,7 @@ irc_ctcp_recv_dcc (struct t_irc_server *server, const char *nick,
|
||||
"received from %s%s%s: \"%s\""),
|
||||
weechat_prefix ("error"),
|
||||
IRC_PLUGIN_NAME,
|
||||
IRC_COLOR_CHAT_NICK,
|
||||
irc_nick_color_for_message (server, NULL, nick),
|
||||
nick,
|
||||
IRC_COLOR_RESET,
|
||||
pos_file);
|
||||
@@ -1037,7 +1042,9 @@ irc_ctcp_recv (struct t_irc_server *server, const char *command,
|
||||
_("%sUnknown CTCP requested by %s%s%s: "
|
||||
"%s%s%s%s%s"),
|
||||
weechat_prefix ("network"),
|
||||
IRC_COLOR_CHAT_NICK,
|
||||
irc_nick_color_for_message (server,
|
||||
NULL,
|
||||
nick),
|
||||
nick,
|
||||
IRC_COLOR_RESET,
|
||||
IRC_COLOR_CHAT_CHANNEL,
|
||||
|
||||
@@ -142,7 +142,7 @@ irc_display_away (struct t_irc_server *server, const char *string1,
|
||||
"away_info",
|
||||
"%s[%s%s%s %s: %s%s]",
|
||||
IRC_COLOR_CHAT_DELIMITERS,
|
||||
IRC_COLOR_CHAT_NICK,
|
||||
IRC_COLOR_CHAT_NICK_SELF,
|
||||
server->nick,
|
||||
IRC_COLOR_RESET,
|
||||
string1,
|
||||
|
||||
@@ -936,23 +936,45 @@ irc_nick_as_prefix (struct t_irc_server *server, struct t_irc_nick *nick,
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_nick_color_for_message: return WeeChat color code for a nick
|
||||
*/
|
||||
|
||||
const char *
|
||||
irc_nick_color_for_message (struct t_irc_server *server,
|
||||
struct t_irc_nick *nick,
|
||||
const char *nickname)
|
||||
{
|
||||
if (nick)
|
||||
return nick->color;
|
||||
|
||||
if (nickname)
|
||||
{
|
||||
if (server
|
||||
&& (irc_server_strcasecmp (server, nickname, server->nick) == 0))
|
||||
{
|
||||
return IRC_COLOR_CHAT_NICK_SELF;
|
||||
}
|
||||
return irc_nick_find_color (nickname);
|
||||
}
|
||||
|
||||
return IRC_COLOR_CHAT_NICK;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_nick_color_for_server_message: return WeeChat color code for a nick
|
||||
* (used in a server message)
|
||||
*/
|
||||
|
||||
const char *
|
||||
irc_nick_color_for_server_message (struct t_irc_nick *nick,
|
||||
irc_nick_color_for_server_message (struct t_irc_server *server,
|
||||
struct t_irc_nick *nick,
|
||||
const char *nickname)
|
||||
{
|
||||
if (weechat_config_boolean(irc_config_look_color_nicks_in_server_messages))
|
||||
{
|
||||
if (nick)
|
||||
return nick->color;
|
||||
if (nickname)
|
||||
return irc_nick_find_color (nickname);
|
||||
}
|
||||
return IRC_COLOR_CHAT_NICK;
|
||||
if (!weechat_config_boolean(irc_config_look_color_nicks_in_server_messages))
|
||||
return IRC_COLOR_CHAT_NICK;
|
||||
|
||||
return irc_nick_color_for_message (server, nick, nickname);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -89,7 +89,11 @@ extern char *irc_nick_as_prefix (struct t_irc_server *server,
|
||||
struct t_irc_nick *nick,
|
||||
const char *nickname,
|
||||
const char *force_color);
|
||||
extern const char *irc_nick_color_for_server_message (struct t_irc_nick *nick,
|
||||
extern const char *irc_nick_color_for_message (struct t_irc_server *server,
|
||||
struct t_irc_nick *nick,
|
||||
const char *nickname);
|
||||
extern const char *irc_nick_color_for_server_message (struct t_irc_server *server,
|
||||
struct t_irc_nick *nick,
|
||||
const char *nickname);
|
||||
extern const char * irc_nick_color_for_pv (struct t_irc_channel *channel,
|
||||
const char *nickname);
|
||||
|
||||
@@ -360,14 +360,16 @@ irc_notify_free_all (struct t_irc_server *server)
|
||||
*/
|
||||
|
||||
void
|
||||
irc_notify_display (struct t_gui_buffer *buffer, struct t_irc_notify *notify)
|
||||
irc_notify_display (struct t_irc_server *server, struct t_gui_buffer *buffer,
|
||||
struct t_irc_notify *notify)
|
||||
{
|
||||
if ((notify->is_on_server < 0)
|
||||
|| (!notify->is_on_server && !notify->away_message))
|
||||
{
|
||||
weechat_printf (buffer,
|
||||
" %s%s%s @ %s%s%s: %s%s",
|
||||
irc_nick_color_for_server_message (NULL, notify->nick),
|
||||
irc_nick_color_for_server_message (server, NULL,
|
||||
notify->nick),
|
||||
notify->nick,
|
||||
IRC_COLOR_RESET,
|
||||
IRC_COLOR_CHAT_SERVER,
|
||||
@@ -383,7 +385,8 @@ irc_notify_display (struct t_gui_buffer *buffer, struct t_irc_notify *notify)
|
||||
{
|
||||
weechat_printf (buffer,
|
||||
" %s%s%s @ %s%s%s: %s%s %s%s%s%s%s%s",
|
||||
irc_nick_color_for_server_message (NULL, notify->nick),
|
||||
irc_nick_color_for_server_message (server, NULL,
|
||||
notify->nick),
|
||||
notify->nick,
|
||||
IRC_COLOR_RESET,
|
||||
IRC_COLOR_CHAT_SERVER,
|
||||
@@ -425,7 +428,7 @@ irc_notify_display_list (struct t_irc_server *server)
|
||||
for (ptr_notify = server->notify_list; ptr_notify;
|
||||
ptr_notify = ptr_notify->next_notify)
|
||||
{
|
||||
irc_notify_display (server->buffer, ptr_notify);
|
||||
irc_notify_display (server, server->buffer, ptr_notify);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -448,7 +451,7 @@ irc_notify_display_list (struct t_irc_server *server)
|
||||
weechat_printf (NULL, "");
|
||||
weechat_printf (NULL, _("Notify list for all servers:"));
|
||||
}
|
||||
irc_notify_display (NULL, ptr_notify);
|
||||
irc_notify_display (ptr_server, NULL, ptr_notify);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
@@ -543,7 +546,9 @@ irc_notify_set_is_on_server (struct t_irc_notify *notify,
|
||||
_("%snotify: %s%s%s has joined") :
|
||||
_("%snotify: %s%s%s has quit")),
|
||||
weechat_prefix ("network"),
|
||||
irc_nick_color_for_server_message (NULL, notify->nick),
|
||||
irc_nick_color_for_server_message (notify->server,
|
||||
NULL,
|
||||
notify->nick),
|
||||
notify->nick,
|
||||
(is_on_server) ?
|
||||
IRC_COLOR_MESSAGE_JOIN : IRC_COLOR_MESSAGE_QUIT);
|
||||
@@ -578,7 +583,9 @@ irc_notify_set_away_message (struct t_irc_notify *notify,
|
||||
notify->nick),
|
||||
_("%snotify: %s%s%s is now away: \"%s\""),
|
||||
weechat_prefix ("network"),
|
||||
irc_nick_color_for_server_message (NULL, notify->nick),
|
||||
irc_nick_color_for_server_message (notify->server,
|
||||
NULL,
|
||||
notify->nick),
|
||||
notify->nick,
|
||||
IRC_COLOR_RESET,
|
||||
away_message);
|
||||
@@ -592,7 +599,9 @@ irc_notify_set_away_message (struct t_irc_notify *notify,
|
||||
notify->nick),
|
||||
_("%snotify: %s%s%s is back"),
|
||||
weechat_prefix ("network"),
|
||||
irc_nick_color_for_server_message (NULL, notify->nick),
|
||||
irc_nick_color_for_server_message (notify->server,
|
||||
NULL,
|
||||
notify->nick),
|
||||
notify->nick,
|
||||
IRC_COLOR_RESET);
|
||||
irc_notify_send_signal (notify, "back", NULL);
|
||||
@@ -605,7 +614,9 @@ irc_notify_set_away_message (struct t_irc_notify *notify,
|
||||
notify->nick),
|
||||
_("%snotify: %s%s%s is still away: \"%s\""),
|
||||
weechat_prefix ("network"),
|
||||
irc_nick_color_for_server_message (NULL, notify->nick),
|
||||
irc_nick_color_for_server_message (notify->server,
|
||||
NULL,
|
||||
notify->nick),
|
||||
notify->nick,
|
||||
IRC_COLOR_RESET,
|
||||
away_message);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user