From 7d302429d2ee90f4c95cbc48f5b40802513150b4 Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Sun, 14 Jun 2009 18:50:43 +0200 Subject: Improve option irc.look.notice_as_pv, new values: auto/never/always This allows private chat with following nicks: nickserv/chanserv/memoserv. --- src/plugins/irc/irc-config.c | 7 ++++--- src/plugins/irc/irc-config.h | 7 +++++++ src/plugins/irc/irc-protocol.c | 13 +++++++++---- 3 files changed, 20 insertions(+), 7 deletions(-) (limited to 'src/plugins/irc') diff --git a/src/plugins/irc/irc-config.c b/src/plugins/irc/irc-config.c index 8c2b5d841..c39ef127b 100644 --- a/src/plugins/irc/irc-config.c +++ b/src/plugins/irc/irc-config.c @@ -1188,9 +1188,10 @@ irc_config_init () NULL, 1, 60*24*7, "5", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_look_notice_as_pv = weechat_config_new_option ( irc_config_file, ptr_section, - "notice_as_pv", "boolean", - N_("display notices as private messages"), - NULL, 0, 0, "off", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + "notice_as_pv", "integer", + N_("display notices as private messages (if auto, use private buffer " + "if found)"), + "auto|never|always", 0, 0, "auto", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_look_topic_strip_colors = weechat_config_new_option ( irc_config_file, ptr_section, "topic_strip_colors", "boolean", diff --git a/src/plugins/irc/irc-config.h b/src/plugins/irc/irc-config.h index da48b66d0..efd135a16 100644 --- a/src/plugins/irc/irc-config.h +++ b/src/plugins/irc/irc-config.h @@ -35,6 +35,13 @@ enum t_irc_config_look_item_display_server IRC_CONFIG_LOOK_ITEM_DISPLAY_SERVER_NAME, }; +enum t_irc_config_look_notice_as_pv +{ + IRC_CONFIG_LOOK_NOTICE_AS_PV_AUTO = 0, + IRC_CONFIG_LOOK_NOTICE_AS_PV_NEVER, + IRC_CONFIG_LOOK_NOTICE_AS_PV_ALWAYS, +}; + enum t_irc_config_nick_completion { IRC_CONFIG_NICK_COMPLETION_SMART_OFF = 0, diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c index c235223ad..b6d8e2737 100644 --- a/src/plugins/irc/irc-protocol.c +++ b/src/plugins/irc/irc-protocol.c @@ -856,10 +856,12 @@ irc_protocol_cmd_notice (struct t_irc_server *server, const char *command, notify_private = 1; } - if (nick && weechat_config_boolean (irc_config_look_notice_as_pv)) + ptr_channel = NULL; + if (nick && weechat_config_integer (irc_config_look_notice_as_pv) != IRC_CONFIG_LOOK_NOTICE_AS_PV_NEVER) { ptr_channel = irc_channel_search (server, nick); - if (!ptr_channel) + if (!ptr_channel + && weechat_config_integer (irc_config_look_notice_as_pv) == IRC_CONFIG_LOOK_NOTICE_AS_PV_ALWAYS) { ptr_channel = irc_channel_new (server, IRC_CHANNEL_TYPE_PRIVATE, @@ -871,15 +873,18 @@ irc_protocol_cmd_notice (struct t_irc_server *server, const char *command, "private buffer \"%s\""), weechat_prefix ("error"), IRC_PLUGIN_NAME, nick); - return WEECHAT_RC_ERROR; } } + } + + if (ptr_channel) + { if (!ptr_channel->topic) irc_channel_set_topic (ptr_channel, address); weechat_printf_tags (ptr_channel->buffer, irc_protocol_tags (command, - (notify_private) ? "notify_private" : NULL), + "notify_private"), "%s%s", irc_nick_as_prefix (NULL, nick, IRC_COLOR_CHAT_NICK_OTHER), -- cgit v1.2.3