mirror of
https://github.com/weechat/weechat.git
synced 2026-06-12 14:14:48 +02:00
irc: compute hash to find nick color for nick in server message when nick is not in nicklist
This commit is contained in:
@@ -11,6 +11,8 @@ Version 0.3.8 (under dev!)
|
||||
weechat.look.paste_bracketed (task #11316)
|
||||
* core: fix display of wide chars on last column of chat area (patch #7733)
|
||||
* api: add list "gui_buffer_last_displayed" in hdata "buffer"
|
||||
* irc: compute hash to find nick color for nick in server message when nick
|
||||
is not in nicklist
|
||||
* irc: add support of "external" SASL mechanism (task #11864)
|
||||
* irc: close server buffer when server is deleted
|
||||
* irc: add search for lower case nicks in option irc.look.nick_color_force
|
||||
|
||||
@@ -778,7 +778,7 @@ 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_COLOR_NICK_IN_SERVER_MESSAGE(nick),
|
||||
irc_nick_color_for_server_message (nick, nickname),
|
||||
(nick) ? nick->name : nickname,
|
||||
IRC_COLOR_CHAT_DELIMITERS,
|
||||
IRC_COLOR_CHAT_HOST,
|
||||
|
||||
@@ -89,9 +89,6 @@
|
||||
#define IRC_COLOR_ITEM_CHANNEL_MODES weechat_color(weechat_config_string(irc_config_color_item_channel_modes))
|
||||
#define IRC_COLOR_ITEM_LAG_COUNTING weechat_color(weechat_config_string(irc_config_color_item_lag_counting))
|
||||
#define IRC_COLOR_ITEM_LAG_FINISHED weechat_color(weechat_config_string(irc_config_color_item_lag_finished))
|
||||
#define IRC_COLOR_NICK_IN_SERVER_MESSAGE(nick) \
|
||||
((nick && weechat_config_boolean(irc_config_look_color_nicks_in_server_messages)) ? \
|
||||
nick->color : IRC_COLOR_CHAT_NICK)
|
||||
|
||||
extern char *irc_color_decode (const char *string, int keep_colors);
|
||||
extern char *irc_color_decode_for_user_entry (const char *string);
|
||||
|
||||
@@ -134,6 +134,8 @@ irc_nick_strdup_for_color (const char *nickname)
|
||||
|
||||
/*
|
||||
* irc_nick_hash_color: hash a nickname to find color
|
||||
* return a number which is the index of color in the
|
||||
* nicks colors of option weechat.color.chat_nick_colors
|
||||
*/
|
||||
|
||||
int
|
||||
@@ -162,6 +164,7 @@ irc_nick_hash_color (const char *nickname)
|
||||
/*
|
||||
* irc_nick_get_forced_color: get forced color for a nick
|
||||
* (NULL if no color is forced for nick)
|
||||
* return name of color (example: "green")
|
||||
*/
|
||||
|
||||
const char *
|
||||
@@ -193,6 +196,7 @@ irc_nick_get_forced_color (const char *nickname)
|
||||
/*
|
||||
* irc_nick_find_color: find a color code for a nick
|
||||
* (according to nick letters)
|
||||
* return a WeeChat color code
|
||||
*/
|
||||
|
||||
const char *
|
||||
@@ -231,6 +235,7 @@ irc_nick_find_color (const char *nickname)
|
||||
/*
|
||||
* irc_nick_find_color_name: find a color name for a nick
|
||||
* (according to nick letters)
|
||||
* return name of color (example: "green")
|
||||
*/
|
||||
|
||||
const char *
|
||||
@@ -931,6 +936,25 @@ irc_nick_as_prefix (struct t_irc_server *server, struct t_irc_nick *nick,
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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,
|
||||
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;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_nick_color_for_pv: return string with color of nick for private
|
||||
*/
|
||||
|
||||
@@ -89,6 +89,8 @@ 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,
|
||||
const char *nickname);
|
||||
extern const char * irc_nick_color_for_pv (struct t_irc_channel *channel,
|
||||
const char *nickname);
|
||||
extern struct t_hdata *irc_nick_hdata_nick_cb (void *data,
|
||||
|
||||
@@ -586,7 +586,7 @@ IRC_PROTOCOL_CALLBACK(join)
|
||||
nick),
|
||||
_("%s%s%s%s%s%s%s%s%s%s has joined %s%s%s"),
|
||||
weechat_prefix ("join"),
|
||||
IRC_COLOR_NICK_IN_SERVER_MESSAGE(ptr_nick),
|
||||
irc_nick_color_for_server_message (ptr_nick, nick),
|
||||
nick,
|
||||
IRC_COLOR_CHAT_DELIMITERS,
|
||||
(display_host) ? " (" : "",
|
||||
@@ -643,10 +643,10 @@ IRC_PROTOCOL_CALLBACK(kick)
|
||||
irc_protocol_tags (command, NULL, NULL),
|
||||
_("%s%s%s%s has kicked %s%s%s %s(%s%s%s)"),
|
||||
weechat_prefix ("quit"),
|
||||
IRC_COLOR_NICK_IN_SERVER_MESSAGE(ptr_nick),
|
||||
irc_nick_color_for_server_message (ptr_nick, nick),
|
||||
nick,
|
||||
IRC_COLOR_MESSAGE_QUIT,
|
||||
IRC_COLOR_NICK_IN_SERVER_MESSAGE(ptr_nick_kicked),
|
||||
irc_nick_color_for_server_message (ptr_nick_kicked, argv[3]),
|
||||
argv[3],
|
||||
IRC_COLOR_MESSAGE_QUIT,
|
||||
IRC_COLOR_CHAT_DELIMITERS,
|
||||
@@ -662,10 +662,10 @@ IRC_PROTOCOL_CALLBACK(kick)
|
||||
irc_protocol_tags (command, NULL, NULL),
|
||||
_("%s%s%s%s has kicked %s%s%s"),
|
||||
weechat_prefix ("quit"),
|
||||
IRC_COLOR_NICK_IN_SERVER_MESSAGE(ptr_nick),
|
||||
irc_nick_color_for_server_message (ptr_nick, nick),
|
||||
nick,
|
||||
IRC_COLOR_MESSAGE_QUIT,
|
||||
IRC_COLOR_NICK_IN_SERVER_MESSAGE(ptr_nick_kicked),
|
||||
irc_nick_color_for_server_message (ptr_nick_kicked, argv[3]),
|
||||
argv[3],
|
||||
IRC_COLOR_MESSAGE_QUIT);
|
||||
}
|
||||
@@ -744,7 +744,7 @@ IRC_PROTOCOL_CALLBACK(kill)
|
||||
_("%s%sYou were killed by %s%s%s %s(%s%s%s)"),
|
||||
weechat_prefix ("quit"),
|
||||
IRC_COLOR_MESSAGE_QUIT,
|
||||
IRC_COLOR_NICK_IN_SERVER_MESSAGE(ptr_nick),
|
||||
irc_nick_color_for_server_message (ptr_nick, nick),
|
||||
nick,
|
||||
IRC_COLOR_MESSAGE_QUIT,
|
||||
IRC_COLOR_CHAT_DELIMITERS,
|
||||
@@ -761,7 +761,7 @@ IRC_PROTOCOL_CALLBACK(kill)
|
||||
_("%s%sYou were killed by %s%s%s"),
|
||||
weechat_prefix ("quit"),
|
||||
IRC_COLOR_MESSAGE_QUIT,
|
||||
IRC_COLOR_NICK_IN_SERVER_MESSAGE(ptr_nick),
|
||||
irc_nick_color_for_server_message (ptr_nick, nick),
|
||||
nick,
|
||||
IRC_COLOR_MESSAGE_QUIT);
|
||||
}
|
||||
@@ -862,7 +862,7 @@ IRC_PROTOCOL_CALLBACK(mode)
|
||||
pos_modes,
|
||||
IRC_COLOR_CHAT_DELIMITERS,
|
||||
IRC_COLOR_RESET,
|
||||
IRC_COLOR_NICK_IN_SERVER_MESSAGE(ptr_nick),
|
||||
irc_nick_color_for_server_message (ptr_nick, nick),
|
||||
nick);
|
||||
}
|
||||
else
|
||||
@@ -990,7 +990,7 @@ IRC_PROTOCOL_CALLBACK(nick)
|
||||
old_color : IRC_COLOR_CHAT_NICK,
|
||||
nick,
|
||||
IRC_COLOR_RESET,
|
||||
IRC_COLOR_NICK_IN_SERVER_MESSAGE(ptr_nick),
|
||||
irc_nick_color_for_server_message (ptr_nick, new_nick),
|
||||
new_nick,
|
||||
IRC_COLOR_RESET);
|
||||
}
|
||||
@@ -1094,7 +1094,7 @@ IRC_PROTOCOL_CALLBACK(notice)
|
||||
_("Notice"),
|
||||
(notice_op) ? "Op" : ((notice_voice) ? "Voice" : ""),
|
||||
IRC_COLOR_CHAT_DELIMITERS,
|
||||
IRC_COLOR_NICK_IN_SERVER_MESSAGE(ptr_nick),
|
||||
irc_nick_color_for_server_message (ptr_nick, nick),
|
||||
(nick && nick[0]) ? nick : "?",
|
||||
IRC_COLOR_CHAT_DELIMITERS,
|
||||
IRC_COLOR_RESET,
|
||||
@@ -1295,7 +1295,7 @@ IRC_PROTOCOL_CALLBACK(part)
|
||||
_("%s%s%s%s%s%s%s%s%s%s has left %s%s%s "
|
||||
"%s(%s%s%s)"),
|
||||
weechat_prefix ("quit"),
|
||||
IRC_COLOR_NICK_IN_SERVER_MESSAGE(ptr_nick),
|
||||
irc_nick_color_for_server_message (ptr_nick, nick),
|
||||
nick,
|
||||
IRC_COLOR_CHAT_DELIMITERS,
|
||||
(display_host) ? " (" : "",
|
||||
@@ -1328,7 +1328,7 @@ IRC_PROTOCOL_CALLBACK(part)
|
||||
_("%s%s%s%s%s%s%s%s%s%s has left "
|
||||
"%s%s%s"),
|
||||
weechat_prefix ("quit"),
|
||||
IRC_COLOR_NICK_IN_SERVER_MESSAGE(ptr_nick),
|
||||
irc_nick_color_for_server_message (ptr_nick, nick),
|
||||
nick,
|
||||
IRC_COLOR_CHAT_DELIMITERS,
|
||||
(display_host) ? " (" : "",
|
||||
@@ -1635,7 +1635,7 @@ IRC_PROTOCOL_CALLBACK(quit)
|
||||
"%s(%s%s%s)"),
|
||||
weechat_prefix ("quit"),
|
||||
(ptr_channel->type == IRC_CHANNEL_TYPE_PRIVATE) ?
|
||||
irc_nick_color_for_pv (ptr_channel, nick) : IRC_COLOR_NICK_IN_SERVER_MESSAGE(ptr_nick),
|
||||
irc_nick_color_for_pv (ptr_channel, nick) : irc_nick_color_for_server_message (ptr_nick, nick),
|
||||
nick,
|
||||
IRC_COLOR_CHAT_DELIMITERS,
|
||||
(display_host) ? " (" : "",
|
||||
@@ -1665,7 +1665,7 @@ IRC_PROTOCOL_CALLBACK(quit)
|
||||
_("%s%s%s%s%s%s%s%s%s%s has quit"),
|
||||
weechat_prefix ("quit"),
|
||||
(ptr_channel->type == IRC_CHANNEL_TYPE_PRIVATE) ?
|
||||
irc_nick_color_for_pv (ptr_channel, nick) : IRC_COLOR_NICK_IN_SERVER_MESSAGE(ptr_nick),
|
||||
irc_nick_color_for_pv (ptr_channel, nick) : irc_nick_color_for_server_message (ptr_nick, nick),
|
||||
nick,
|
||||
IRC_COLOR_CHAT_DELIMITERS,
|
||||
(display_host) ? " (" : "",
|
||||
@@ -1799,7 +1799,7 @@ IRC_PROTOCOL_CALLBACK(topic)
|
||||
_("%s%s%s%s has changed topic for %s%s%s "
|
||||
"from \"%s%s%s\" to \"%s%s%s\""),
|
||||
weechat_prefix ("network"),
|
||||
IRC_COLOR_NICK_IN_SERVER_MESSAGE(ptr_nick),
|
||||
irc_nick_color_for_server_message (ptr_nick, nick),
|
||||
nick,
|
||||
IRC_COLOR_RESET,
|
||||
IRC_COLOR_CHAT_CHANNEL,
|
||||
@@ -1823,7 +1823,7 @@ IRC_PROTOCOL_CALLBACK(topic)
|
||||
_("%s%s%s%s has changed topic for %s%s%s "
|
||||
"to \"%s%s%s\""),
|
||||
weechat_prefix ("network"),
|
||||
IRC_COLOR_NICK_IN_SERVER_MESSAGE(ptr_nick),
|
||||
irc_nick_color_for_server_message (ptr_nick, nick),
|
||||
nick,
|
||||
IRC_COLOR_RESET,
|
||||
IRC_COLOR_CHAT_CHANNEL,
|
||||
@@ -1850,7 +1850,7 @@ IRC_PROTOCOL_CALLBACK(topic)
|
||||
_("%s%s%s%s has unset topic for %s%s%s "
|
||||
"(old topic: \"%s%s%s\")"),
|
||||
weechat_prefix ("network"),
|
||||
IRC_COLOR_NICK_IN_SERVER_MESSAGE(ptr_nick),
|
||||
irc_nick_color_for_server_message (ptr_nick, nick),
|
||||
nick,
|
||||
IRC_COLOR_RESET,
|
||||
IRC_COLOR_CHAT_CHANNEL,
|
||||
@@ -1870,7 +1870,7 @@ IRC_PROTOCOL_CALLBACK(topic)
|
||||
irc_protocol_tags (command, NULL, NULL),
|
||||
_("%s%s%s%s has unset topic for %s%s%s"),
|
||||
weechat_prefix ("network"),
|
||||
IRC_COLOR_NICK_IN_SERVER_MESSAGE(ptr_nick),
|
||||
irc_nick_color_for_server_message (ptr_nick, nick),
|
||||
nick,
|
||||
IRC_COLOR_RESET,
|
||||
IRC_COLOR_CHAT_CHANNEL,
|
||||
@@ -3064,7 +3064,7 @@ IRC_PROTOCOL_CALLBACK(333)
|
||||
/* TRANSLATORS: "%s" after "on" is a date */
|
||||
_("%sTopic set by %s%s%s%s%s%s%s%s%s on %s"),
|
||||
weechat_prefix ("network"),
|
||||
IRC_COLOR_NICK_IN_SERVER_MESSAGE(ptr_nick),
|
||||
irc_nick_color_for_server_message (ptr_nick, topic_nick),
|
||||
topic_nick,
|
||||
IRC_COLOR_CHAT_DELIMITERS,
|
||||
(topic_address && topic_address[0]) ? " (" : "",
|
||||
@@ -3101,7 +3101,7 @@ IRC_PROTOCOL_CALLBACK(333)
|
||||
IRC_COLOR_CHAT_CHANNEL,
|
||||
argv[3],
|
||||
IRC_COLOR_RESET,
|
||||
IRC_COLOR_NICK_IN_SERVER_MESSAGE(ptr_nick),
|
||||
irc_nick_color_for_server_message (ptr_nick, topic_nick),
|
||||
topic_nick,
|
||||
IRC_COLOR_CHAT_DELIMITERS,
|
||||
(topic_address && topic_address[0]) ? " (" : "",
|
||||
|
||||
Reference in New Issue
Block a user