diff options
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/irc/irc-config.c | 23 | ||||
-rw-r--r-- | src/plugins/irc/irc-config.h | 3 | ||||
-rw-r--r-- | src/plugins/irc/irc-nick.c | 2 | ||||
-rw-r--r-- | src/plugins/irc/irc-protocol.c | 143 | ||||
-rw-r--r-- | src/plugins/irc/irc.h | 5 |
5 files changed, 108 insertions, 68 deletions
diff --git a/src/plugins/irc/irc-config.c b/src/plugins/irc/irc-config.c index 54b029c7c..e00a2fe0a 100644 --- a/src/plugins/irc/irc-config.c +++ b/src/plugins/irc/irc-config.c @@ -52,6 +52,7 @@ struct t_config_section *irc_config_section_server = NULL; /* IRC config, look section */ +struct t_config_option *irc_config_look_color_nicks_in_server_messages; struct t_config_option *irc_config_look_one_server_buffer; struct t_config_option *irc_config_look_open_near_server; struct t_config_option *irc_config_look_nick_prefix; @@ -68,6 +69,8 @@ struct t_config_option *irc_config_look_notice_as_pv; /* IRC config, color section */ +struct t_config_option *irc_config_color_message_join; +struct t_config_option *irc_config_color_message_quit; struct t_config_option *irc_config_color_input_nick; /* IRC config, network section */ @@ -1106,7 +1109,13 @@ irc_config_init () weechat_config_free (irc_config_file); return 0; } - + + irc_config_look_color_nicks_in_server_messages = weechat_config_new_option ( + irc_config_file, ptr_section, + "color_nicks_in_server_messages", "boolean", + N_("use nick color in messages from server"), + NULL, 0, 0, "on", NULL, NULL, NULL, + NULL, NULL, NULL, NULL); irc_config_look_one_server_buffer = weechat_config_new_option ( irc_config_file, ptr_section, "one_server_buffer", "boolean", @@ -1192,6 +1201,18 @@ irc_config_init () return 0; } + irc_config_color_message_join = weechat_config_new_option ( + irc_config_file, ptr_section, + "message_join", "color", + N_("color for text in join messages"), + NULL, -1, 0, "green", NULL, NULL, NULL, + NULL, NULL, NULL, NULL); + irc_config_color_message_quit = weechat_config_new_option ( + irc_config_file, ptr_section, + "message_quit", "color", + N_("color for text in part/quit messages"), + NULL, -1, 0, "red", NULL, NULL, NULL, + NULL, NULL, NULL, NULL); irc_config_color_input_nick = weechat_config_new_option ( irc_config_file, ptr_section, "input_nick", "color", diff --git a/src/plugins/irc/irc-config.h b/src/plugins/irc/irc-config.h index 229ab16a1..71374071a 100644 --- a/src/plugins/irc/irc-config.h +++ b/src/plugins/irc/irc-config.h @@ -63,6 +63,7 @@ extern struct t_config_file *irc_config_file; extern struct t_config_section *irc_config_section_server_default; extern struct t_config_section *irc_config_section_server; +extern struct t_config_option *irc_config_look_color_nicks_in_server_messages; extern struct t_config_option *irc_config_look_one_server_buffer; extern struct t_config_option *irc_config_look_open_near_server; extern struct t_config_option *irc_config_look_nick_prefix; @@ -77,6 +78,8 @@ extern struct t_config_option *irc_config_look_smart_filter; extern struct t_config_option *irc_config_look_smart_filter_delay; extern struct t_config_option *irc_config_look_notice_as_pv; +extern struct t_config_option *irc_config_color_message_join; +extern struct t_config_option *irc_config_color_message_quit; extern struct t_config_option *irc_config_color_input_nick; extern struct t_config_option *irc_config_network_default_msg_part; diff --git a/src/plugins/irc/irc-nick.c b/src/plugins/irc/irc-nick.c index 90cdcdfa2..d2c49475f 100644 --- a/src/plugins/irc/irc-nick.c +++ b/src/plugins/irc/irc-nick.c @@ -434,7 +434,7 @@ irc_nick_search (struct t_irc_channel *channel, const char *nickname) { struct t_irc_nick *ptr_nick; - if (!nickname) + if (!channel || !nickname) return NULL; for (ptr_nick = channel->nicks; ptr_nick; diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c index bea5d7e33..54eb56ca9 100644 --- a/src/plugins/irc/irc-protocol.c +++ b/src/plugins/irc/irc-protocol.c @@ -341,6 +341,20 @@ irc_protocol_cmd_join (struct t_irc_server *server, const char *command, } } + /* remove topic and display channel creation date if joining new channel */ + if (!ptr_channel->nicks) + { + if (ptr_channel->topic) + irc_channel_set_topic (ptr_channel, NULL); + + ptr_channel->display_creation_date = 1; + } + + /* add nick in channel */ + ptr_nick = irc_nick_new (server, ptr_channel, nick, 0, 0, 0, 0, 0, 0, 0, 0); + if (ptr_nick) + ptr_nick->host = strdup (address); + if (!irc_ignore_check (server, ptr_channel, nick, host)) { local_join = (strcmp (nick, server->nick) == 0); @@ -354,31 +368,17 @@ irc_protocol_cmd_join (struct t_irc_server *server, const char *command, NULL : "irc_smart_filter"), _("%s%s%s %s(%s%s%s)%s has joined %s%s"), weechat_prefix ("join"), - IRC_COLOR_CHAT_NICK, + IRC_COLOR_NICK_IN_SERVER_MESSAGE(ptr_nick), nick, IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_CHAT_HOST, address, IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT, + IRC_COLOR_MESSAGE_JOIN, IRC_COLOR_CHAT_CHANNEL, pos_channel); } - /* remove topic and display channel creation date if joining new channel */ - if (!ptr_channel->nicks) - { - if (ptr_channel->topic) - irc_channel_set_topic (ptr_channel, NULL); - - ptr_channel->display_creation_date = 1; - } - - /* add nick in channel */ - ptr_nick = irc_nick_new (server, ptr_channel, nick, 0, 0, 0, 0, 0, 0, 0, 0); - if (ptr_nick) - ptr_nick->host = strdup (address); - return WEECHAT_RC_OK; } @@ -392,7 +392,7 @@ irc_protocol_cmd_kick (struct t_irc_server *server, const char *command, { char *pos_comment; struct t_irc_channel *ptr_channel; - struct t_irc_nick *ptr_nick; + struct t_irc_nick *ptr_nick, *ptr_nick_kicked; /* KICK message looks like: :nick1!user@host KICK #channel nick2 :kick reason @@ -416,23 +416,22 @@ irc_protocol_cmd_kick (struct t_irc_server *server, const char *command, return WEECHAT_RC_ERROR; } + ptr_nick = irc_nick_search (ptr_channel, nick); + ptr_nick_kicked = irc_nick_search (ptr_channel, argv[3]); + if (!irc_ignore_check (server, ptr_channel, nick, host)) { if (pos_comment) { weechat_printf_tags (ptr_channel->buffer, irc_protocol_tags (command, NULL), - _("%s%s%s%s has kicked %s%s%s from %s%s " - "%s(%s%s%s)"), + _("%s%s%s%s has kicked %s%s %s(%s%s%s)"), weechat_prefix ("quit"), - IRC_COLOR_CHAT_NICK, + IRC_COLOR_NICK_IN_SERVER_MESSAGE(ptr_nick), nick, - IRC_COLOR_CHAT, - IRC_COLOR_CHAT_NICK, + IRC_COLOR_MESSAGE_QUIT, + IRC_COLOR_NICK_IN_SERVER_MESSAGE(ptr_nick_kicked), argv[3], - IRC_COLOR_CHAT, - IRC_COLOR_CHAT_CHANNEL, - argv[2], IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_CHAT, pos_comment, @@ -442,16 +441,13 @@ irc_protocol_cmd_kick (struct t_irc_server *server, const char *command, { weechat_printf_tags (ptr_channel->buffer, irc_protocol_tags (command, NULL), - _("%s%s%s%s has kicked %s%s%s from %s%s"), + _("%s%s%s%s has kicked %s%s"), weechat_prefix ("quit"), - IRC_COLOR_CHAT_NICK, + IRC_COLOR_NICK_IN_SERVER_MESSAGE(ptr_nick), nick, - IRC_COLOR_CHAT, - IRC_COLOR_CHAT_NICK, - argv[3], - IRC_COLOR_CHAT, - IRC_COLOR_CHAT_CHANNEL, - argv[2]); + IRC_COLOR_MESSAGE_QUIT, + IRC_COLOR_NICK_IN_SERVER_MESSAGE(ptr_nick_kicked), + argv[3]); } } @@ -467,9 +463,8 @@ irc_protocol_cmd_kick (struct t_irc_server *server, const char *command, { /* someone was kicked from channel (but not me) => remove only this nick */ - ptr_nick = irc_nick_search (ptr_channel, argv[3]); - if (ptr_nick) - irc_nick_free (ptr_channel, ptr_nick); + if (ptr_nick_kicked) + irc_nick_free (ptr_channel, ptr_nick_kicked); } return WEECHAT_RC_OK; @@ -485,7 +480,7 @@ irc_protocol_cmd_kill (struct t_irc_server *server, const char *command, { char *pos_comment; struct t_irc_channel *ptr_channel; - struct t_irc_nick *ptr_nick; + struct t_irc_nick *ptr_nick, *ptr_nick_killed; /* KILL message looks like: :nick1!user@host KILL mynick :kill reason @@ -501,15 +496,19 @@ irc_protocol_cmd_kill (struct t_irc_server *server, const char *command, for (ptr_channel = server->channels; ptr_channel; ptr_channel = ptr_channel->next_channel) { + ptr_nick = irc_nick_search (ptr_channel, nick); + ptr_nick_killed = irc_nick_search (ptr_channel, argv[2]); + if (!irc_ignore_check (server, ptr_channel, nick, host)) { if (pos_comment) { weechat_printf_tags (ptr_channel->buffer, irc_protocol_tags (command, NULL), - _("%sYou were killed by %s%s %s(%s%s%s)"), + _("%s%sYou were killed by %s%s %s(%s%s%s)"), weechat_prefix ("quit"), - IRC_COLOR_CHAT_NICK, + IRC_COLOR_MESSAGE_QUIT, + IRC_COLOR_NICK_IN_SERVER_MESSAGE(ptr_nick), nick, IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_CHAT, @@ -520,9 +519,10 @@ irc_protocol_cmd_kill (struct t_irc_server *server, const char *command, { weechat_printf_tags (ptr_channel->buffer, irc_protocol_tags (command, NULL), - _("%sYou were killed by %s%s"), + _("%s%sYou were killed by %s%s"), weechat_prefix ("quit"), - IRC_COLOR_CHAT_NICK, + IRC_COLOR_MESSAGE_QUIT, + IRC_COLOR_NICK_IN_SERVER_MESSAGE(ptr_nick), nick); } } @@ -537,9 +537,8 @@ irc_protocol_cmd_kill (struct t_irc_server *server, const char *command, { /* someone was killed on channel (but not me) => remove only this nick */ - ptr_nick = irc_nick_search (ptr_channel, argv[2]); - if (ptr_nick) - irc_nick_free (ptr_channel, ptr_nick); + if (ptr_nick_killed) + irc_nick_free (ptr_channel, ptr_nick_killed); } } @@ -556,6 +555,7 @@ irc_protocol_cmd_mode (struct t_irc_server *server, const char *command, { char *pos_modes; struct t_irc_channel *ptr_channel; + struct t_irc_nick *ptr_nick; /* MODE message looks like: :nick!user@host MODE #test +o nick @@ -575,6 +575,7 @@ irc_protocol_cmd_mode (struct t_irc_server *server, const char *command, irc_mode_channel_set (server, ptr_channel, pos_modes); irc_server_sendf (server, "MODE %s", ptr_channel->name); } + ptr_nick = irc_nick_search (ptr_channel, nick); if (!irc_ignore_check (server, ptr_channel, nick, host)) { weechat_printf_tags ((ptr_channel) ? @@ -589,7 +590,7 @@ irc_protocol_cmd_mode (struct t_irc_server *server, const char *command, pos_modes, IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_CHAT, - IRC_COLOR_CHAT_NICK, + IRC_COLOR_NICK_IN_SERVER_MESSAGE(ptr_nick), nick); } } @@ -625,7 +626,7 @@ irc_protocol_cmd_nick (struct t_irc_server *server, const char *command, { struct t_irc_channel *ptr_channel; struct t_irc_nick *ptr_nick; - char *new_nick; + char *new_nick, *old_color; int local_nick; /* NICK message looks like: @@ -668,6 +669,7 @@ irc_protocol_cmd_nick (struct t_irc_server *server, const char *command, weechat_buffer_set (NULL, "hotlist", "-"); /* change nick and display message on all channels */ + old_color = strdup (ptr_nick->color); irc_nick_change (server, ptr_channel, ptr_nick, new_nick); if (local_nick) { @@ -676,7 +678,7 @@ irc_protocol_cmd_nick (struct t_irc_server *server, const char *command, _("%sYou are now known as " "%s%s"), weechat_prefix ("network"), - IRC_COLOR_CHAT_NICK, + IRC_COLOR_NICK_IN_SERVER_MESSAGE(ptr_nick), new_nick); } else @@ -688,10 +690,11 @@ irc_protocol_cmd_nick (struct t_irc_server *server, const char *command, _("%s%s%s%s is now known as " "%s%s"), weechat_prefix ("network"), - IRC_COLOR_CHAT_NICK, + weechat_config_boolean(irc_config_look_color_nicks_in_server_messages) ? + old_color : IRC_COLOR_CHAT_NICK, nick, IRC_COLOR_CHAT, - IRC_COLOR_CHAT_NICK, + IRC_COLOR_NICK_IN_SERVER_MESSAGE(ptr_nick), new_nick); } irc_channel_nick_speaking_rename (ptr_channel, @@ -700,6 +703,9 @@ irc_protocol_cmd_nick (struct t_irc_server *server, const char *command, nick, new_nick); } + if (old_color) + free (old_color); + /* enable hotlist */ weechat_buffer_set (NULL, "hotlist", "+"); } @@ -725,6 +731,7 @@ irc_protocol_cmd_notice (struct t_irc_server *server, const char *command, struct timeval tv; long sec1, usec1, sec2, usec2, difftime; struct t_irc_channel *ptr_channel; + struct t_irc_nick *ptr_nick; int notify_private; /* NOTICE message looks like: @@ -821,13 +828,14 @@ irc_protocol_cmd_notice (struct t_irc_server *server, const char *command, { /* notice for channel */ ptr_channel = irc_channel_search (server, pos_target); + ptr_nick = irc_nick_search (ptr_channel, nick); weechat_printf_tags ((ptr_channel) ? ptr_channel->buffer : server->buffer, irc_protocol_tags (command, NULL), "%sNotice%s(%s%s%s)%s: %s", (ptr_channel) ? weechat_prefix ("network") : irc_buffer_get_server_prefix (server, "network"), IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_NICK, + IRC_COLOR_NICK_IN_SERVER_MESSAGE(ptr_nick), (nick && nick[0]) ? nick : "?", IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_CHAT, @@ -976,13 +984,13 @@ irc_protocol_cmd_part (struct t_irc_server *server, const char *command, _("%s%s%s %s(%s%s%s)%s has left %s%s " "%s(%s%s%s)"), weechat_prefix ("quit"), - IRC_COLOR_CHAT_NICK, + IRC_COLOR_NICK_IN_SERVER_MESSAGE(ptr_nick), nick, IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_CHAT_HOST, address, IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT, + IRC_COLOR_MESSAGE_QUIT, IRC_COLOR_CHAT_CHANNEL, ptr_channel->name, IRC_COLOR_CHAT_DELIMITERS, @@ -1001,13 +1009,13 @@ irc_protocol_cmd_part (struct t_irc_server *server, const char *command, _("%s%s%s %s(%s%s%s)%s has left " "%s%s"), weechat_prefix ("quit"), - IRC_COLOR_CHAT_NICK, + IRC_COLOR_NICK_IN_SERVER_MESSAGE(ptr_nick), nick, IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_CHAT_HOST, address, IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT, + IRC_COLOR_MESSAGE_QUIT, IRC_COLOR_CHAT_CHANNEL, ptr_channel->name); } @@ -2125,9 +2133,6 @@ irc_protocol_cmd_quit (struct t_irc_server *server, const char *command, if (ptr_nick || (strcmp (ptr_channel->name, nick) == 0)) { - if (ptr_nick) - irc_nick_free (ptr_channel, ptr_nick); - /* display quit message */ if (!irc_ignore_check (server, ptr_channel, nick, host)) { @@ -2145,13 +2150,13 @@ irc_protocol_cmd_quit (struct t_irc_server *server, const char *command, _("%s%s%s %s(%s%s%s)%s has quit " "%s(%s%s%s)"), weechat_prefix ("quit"), - IRC_COLOR_CHAT_NICK, + IRC_COLOR_NICK_IN_SERVER_MESSAGE(ptr_nick), nick, IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_CHAT_HOST, address, IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT, + IRC_COLOR_MESSAGE_QUIT, IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_CHAT, pos_comment, @@ -2167,15 +2172,17 @@ irc_protocol_cmd_quit (struct t_irc_server *server, const char *command, NULL : "irc_smart_filter"), _("%s%s%s %s(%s%s%s)%s has quit"), weechat_prefix ("quit"), - IRC_COLOR_CHAT_NICK, + IRC_COLOR_NICK_IN_SERVER_MESSAGE(ptr_nick), nick, IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_CHAT_HOST, address, IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT); + IRC_COLOR_MESSAGE_QUIT); } } + if (ptr_nick) + irc_nick_free (ptr_channel, ptr_nick); } } @@ -2261,6 +2268,7 @@ irc_protocol_cmd_topic (struct t_irc_server *server, const char *command, { char *pos_topic, *topic_color; struct t_irc_channel *ptr_channel; + struct t_irc_nick *ptr_nick; struct t_gui_buffer *ptr_buffer; /* TOPIC message looks like: @@ -2283,8 +2291,9 @@ irc_protocol_cmd_topic (struct t_irc_server *server, const char *command, ((argv_eol[3][0] == ':') ? argv_eol[3] + 1 : argv_eol[3]) : NULL; ptr_channel = irc_channel_search (server, argv[2]); + ptr_nick = irc_nick_search (ptr_channel, nick); ptr_buffer = (ptr_channel) ? ptr_channel->buffer : server->buffer; - + if (!irc_ignore_check (server, ptr_channel, nick, host)) { if (pos_topic && pos_topic[0]) @@ -2297,7 +2306,7 @@ irc_protocol_cmd_topic (struct t_irc_server *server, const char *command, "\"%s%s\""), (ptr_buffer == server->buffer) ? irc_buffer_get_server_prefix (server, "network") : weechat_prefix ("network"), - IRC_COLOR_CHAT_NICK, + IRC_COLOR_NICK_IN_SERVER_MESSAGE(ptr_nick), nick, IRC_COLOR_CHAT, IRC_COLOR_CHAT_CHANNEL, @@ -2315,7 +2324,7 @@ irc_protocol_cmd_topic (struct t_irc_server *server, const char *command, _("%s%s%s%s has unset topic for %s%s"), (ptr_buffer == server->buffer) ? irc_buffer_get_server_prefix (server, "network") : weechat_prefix ("network"), - IRC_COLOR_CHAT_NICK, + IRC_COLOR_NICK_IN_SERVER_MESSAGE(ptr_nick), nick, IRC_COLOR_CHAT, IRC_COLOR_CHAT_CHANNEL, @@ -3277,6 +3286,7 @@ irc_protocol_cmd_333 (struct t_irc_server *server, const char *command, int argc, char **argv, char **argv_eol) { struct t_irc_channel *ptr_channel; + struct t_irc_nick *ptr_nick; time_t datetime; /* 333 message looks like: @@ -3286,6 +3296,7 @@ irc_protocol_cmd_333 (struct t_irc_server *server, const char *command, IRC_PROTOCOL_MIN_ARGS(6); ptr_channel = irc_channel_search (server, argv[3]); + ptr_nick = irc_nick_search (ptr_channel, argv[4]); datetime = (time_t)(atol ((argv_eol[5][0] == ':') ? argv_eol[5] + 1 : argv_eol[5])); if (ptr_channel && ptr_channel->nicks) @@ -3294,7 +3305,7 @@ irc_protocol_cmd_333 (struct t_irc_server *server, const char *command, irc_protocol_tags (command, "irc_numeric"), _("%sTopic set by %s%s%s on %s"), weechat_prefix ("network"), - IRC_COLOR_CHAT_NICK, + IRC_COLOR_NICK_IN_SERVER_MESSAGE(ptr_nick), argv[4], IRC_COLOR_CHAT, ctime (&datetime)); @@ -3308,7 +3319,7 @@ irc_protocol_cmd_333 (struct t_irc_server *server, const char *command, IRC_COLOR_CHAT_CHANNEL, argv[3], IRC_COLOR_CHAT, - IRC_COLOR_CHAT_NICK, + IRC_COLOR_NICK_IN_SERVER_MESSAGE(ptr_nick), argv[4], IRC_COLOR_CHAT, ctime (&datetime)); diff --git a/src/plugins/irc/irc.h b/src/plugins/irc/irc.h index d8ad68975..14aa43c2e 100644 --- a/src/plugins/irc/irc.h +++ b/src/plugins/irc/irc.h @@ -63,7 +63,12 @@ #define IRC_COLOR_BAR_DELIM weechat_color("bar_delim") #define IRC_COLOR_STATUS_NUMBER weechat_color(weechat_config_string(weechat_config_get("weechat.color.status_number"))) #define IRC_COLOR_STATUS_NAME weechat_color(weechat_config_string(weechat_config_get("weechat.color.status_name"))) +#define IRC_COLOR_MESSAGE_JOIN weechat_color(weechat_config_string(irc_config_color_message_join)) +#define IRC_COLOR_MESSAGE_QUIT weechat_color(weechat_config_string(irc_config_color_message_quit)) #define IRC_COLOR_INPUT_NICK weechat_color(weechat_config_string(irc_config_color_input_nick)) +#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 struct t_weechat_plugin *weechat_irc_plugin; extern struct t_hook *irc_hook_timer_check_away; |