diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2010-02-11 17:07:56 +0100 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2010-02-11 17:07:56 +0100 |
commit | f19000ac4f52ea90a47312e113b3d9337376aa8c (patch) | |
tree | d2978ac673086ace679da31eacb33fd3a1f98e54 | |
parent | be8831499d856fe5e9aa601ec8050c91971daf83 (diff) | |
download | weechat-f19000ac4f52ea90a47312e113b3d9337376aa8c.zip |
Allow IRC message 301 to be redirected with irc.msgbuffer feature
-rw-r--r-- | src/plugins/irc/irc-msgbuffer.c | 9 | ||||
-rw-r--r-- | src/plugins/irc/irc-msgbuffer.h | 3 | ||||
-rw-r--r-- | src/plugins/irc/irc-protocol.c | 85 |
3 files changed, 64 insertions, 33 deletions
diff --git a/src/plugins/irc/irc-msgbuffer.c b/src/plugins/irc/irc-msgbuffer.c index 0a17e1a89..20a2bc146 100644 --- a/src/plugins/irc/irc-msgbuffer.c +++ b/src/plugins/irc/irc-msgbuffer.c @@ -93,11 +93,15 @@ irc_msgbuffer_get_option (struct t_irc_server *server, const char *message) * (for example: "invite", "312") * alias is optional alias for message * (for example "whois") + * default_buffer is used if no target is + * defined (optional, by default server + * buffer is used) */ struct t_gui_buffer * irc_msgbuffer_get_target_buffer (struct t_irc_server *server, const char *nick, - const char *message, const char *alias) + const char *message, const char *alias, + struct t_gui_buffer *default_buffer) { struct t_config_option *ptr_option; int target; @@ -109,6 +113,9 @@ irc_msgbuffer_get_target_buffer (struct t_irc_server *server, const char *nick, if (!ptr_option && alias && alias[0]) ptr_option = irc_msgbuffer_get_option (server, alias); + if (!ptr_option && default_buffer) + return default_buffer; + target = (ptr_option) ? weechat_config_integer (ptr_option) : -1; diff --git a/src/plugins/irc/irc-msgbuffer.h b/src/plugins/irc/irc-msgbuffer.h index 6774e4443..d5e50a791 100644 --- a/src/plugins/irc/irc-msgbuffer.h +++ b/src/plugins/irc/irc-msgbuffer.h @@ -41,6 +41,7 @@ extern const char *irc_msgbuffer_get_string (int target); extern struct t_gui_buffer *irc_msgbuffer_get_target_buffer (struct t_irc_server *server, const char *nick, const char *message, - const char *alias); + const char *alias, + struct t_gui_buffer *default_buffer); #endif /* irc-msgbuffer.h */ diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c index 1d50076cf..83c09109d 100644 --- a/src/plugins/irc/irc-protocol.c +++ b/src/plugins/irc/irc-protocol.c @@ -291,7 +291,8 @@ irc_protocol_cmd_invite (struct t_irc_server *server, const char *command, if (!irc_ignore_check (server, NULL, nick, host)) { weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, nick, - command, NULL), + command, NULL, + NULL), irc_protocol_tags (command, "notify_highlight"), _("%sYou have been invited to %s%s%s by " "%s%s%s"), @@ -870,7 +871,8 @@ irc_protocol_cmd_notice (struct t_irc_server *server, const char *command, else { ptr_buffer = irc_msgbuffer_get_target_buffer (server, nick, - command, NULL); + command, NULL, + NULL); if (address && address[0]) { weechat_printf_tags (ptr_buffer, @@ -1426,7 +1428,7 @@ irc_protocol_cmd_numeric (struct t_irc_server *server, const char *command, } weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL, - command, NULL), + command, NULL, NULL), irc_protocol_tags (command, "irc_numeric"), "%s%s", weechat_prefix ("network"), @@ -1557,7 +1559,8 @@ irc_protocol_cmd_wallops (struct t_irc_server *server, const char *command, if (!irc_ignore_check (server, NULL, nick, host)) { weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, nick, - command, NULL), + command, NULL, + NULL), irc_protocol_tags (command, NULL), _("%sWallops from %s%s %s(%s%s%s)%s: %s"), weechat_prefix ("network"), @@ -1709,7 +1712,7 @@ irc_protocol_cmd_221 (struct t_irc_server *server, const char *command, IRC_PROTOCOL_MIN_ARGS(4); weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, argv[2], - command, NULL), + command, NULL, NULL), irc_protocol_tags (command, "irc_numeric"), _("%sUser mode for %s%s%s is %s[%s%s%s]"), weechat_prefix ("network"), @@ -1756,7 +1759,9 @@ irc_protocol_cmd_301 (struct t_irc_server *server, const char *command, || (strcmp (ptr_channel->away_message, pos_away_msg) != 0)) { ptr_buffer = (ptr_channel) ? ptr_channel->buffer : server->buffer; - weechat_printf_tags (ptr_buffer, + weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, argv[3], + command, "whois", + ptr_buffer), irc_protocol_tags (command, "irc_numeric"), _("%s%s[%s%s%s]%s is away: %s"), weechat_prefix ("network"), @@ -1796,7 +1801,7 @@ irc_protocol_cmd_303 (struct t_irc_server *server, const char *command, (void) argv; weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL, - command, NULL), + command, NULL, NULL), irc_protocol_tags (command, "irc_numeric"), _("%sUsers online: %s%s"), weechat_prefix ("network"), @@ -1826,7 +1831,8 @@ irc_protocol_cmd_305 (struct t_irc_server *server, const char *command, if (argc > 3) { weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL, - command, "unaway"), + command, "unaway", + NULL), irc_protocol_tags (command, "irc_numeric"), "%s%s", weechat_prefix ("network"), @@ -1861,7 +1867,8 @@ irc_protocol_cmd_306 (struct t_irc_server *server, const char *command, if (argc > 3) { weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL, - command, "away"), + command, "away", + NULL), irc_protocol_tags (command, "irc_numeric"), "%s%s", weechat_prefix ("network"), @@ -1891,7 +1898,8 @@ irc_protocol_cmd_whois_nick_msg (struct t_irc_server *server, const char *comman IRC_PROTOCOL_MIN_ARGS(5); weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, argv[3], - command, "whois"), + command, "whois", + NULL), irc_protocol_tags (command, "irc_numeric"), "%s%s[%s%s%s] %s%s", weechat_prefix ("network"), @@ -1920,7 +1928,8 @@ irc_protocol_cmd_whowas_nick_msg (struct t_irc_server *server, const char *comma IRC_PROTOCOL_MIN_ARGS(5); weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, argv[3], - command, "whowas"), + command, "whowas", + NULL), irc_protocol_tags (command, "irc_numeric"), "%s%s[%s%s%s] %s%s", weechat_prefix ("network"), @@ -1949,7 +1958,8 @@ irc_protocol_cmd_311 (struct t_irc_server *server, const char *command, IRC_PROTOCOL_MIN_ARGS(8); weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, argv[3], - command, "whois"), + command, "whois", + NULL), irc_protocol_tags (command, "irc_numeric"), "%s%s[%s%s%s] (%s%s@%s%s)%s: %s", weechat_prefix ("network"), @@ -1982,7 +1992,8 @@ irc_protocol_cmd_312 (struct t_irc_server *server, const char *command, IRC_PROTOCOL_MIN_ARGS(6); weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, argv[3], - command, "whois"), + command, "whois", + NULL), irc_protocol_tags (command, "irc_numeric"), "%s%s[%s%s%s] %s%s %s(%s%s%s)", weechat_prefix ("network"), @@ -2015,7 +2026,8 @@ irc_protocol_cmd_314 (struct t_irc_server *server, const char *command, IRC_PROTOCOL_MIN_ARGS(8); weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, argv[3], - command, "whowas"), + command, "whowas", + NULL), irc_protocol_tags (command, "irc_numeric"), _("%s%s[%s%s%s] (%s%s@%s%s)%s was %s"), weechat_prefix ("network"), @@ -2057,7 +2069,8 @@ irc_protocol_cmd_315 (struct t_irc_server *server, const char *command, else { weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL, - command, "who"), + command, "who", + NULL), irc_protocol_tags (command, "irc_numeric"), "%s%s[%s%s%s]%s %s", weechat_prefix ("network"), @@ -2102,7 +2115,7 @@ irc_protocol_cmd_317 (struct t_irc_server *server, const char *command, datetime = (time_t)(atol (argv[5])); ptr_buffer = irc_msgbuffer_get_target_buffer (server, argv[3], - command, "whois"); + command, "whois", NULL); if (day > 0) { @@ -2188,7 +2201,8 @@ irc_protocol_cmd_321 (struct t_irc_server *server, const char *command, ((argv_eol[4][0] == ':') ? argv_eol[4] + 1 : argv_eol[4]) : NULL; weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL, - command, "list"), + command, "list", + NULL), irc_protocol_tags (command, "irc_numeric"), "%s%s%s%s", weechat_prefix ("network"), @@ -2222,7 +2236,8 @@ irc_protocol_cmd_322 (struct t_irc_server *server, const char *command, (regexec (server->cmd_list_regexp, argv[3], 0, NULL, 0) == 0)) { weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL, - command, "list"), + command, "list", + NULL), irc_protocol_tags (command, "irc_numeric"), "%s%s%s%s(%s%s%s)%s%s%s", weechat_prefix ("network"), @@ -2263,7 +2278,8 @@ irc_protocol_cmd_323 (struct t_irc_server *server, const char *command, ((argv_eol[3][0] == ':') ? argv_eol[3] + 1 : argv_eol[3]) : NULL; weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL, - command, "list"), + command, "list", + NULL), irc_protocol_tags (command, "irc_numeric"), "%s%s", weechat_prefix ("network"), @@ -2333,7 +2349,7 @@ irc_protocol_cmd_327 (struct t_irc_server *server, const char *command, ((argv_eol[6][0] == ':') ? argv_eol[6] + 1 : argv_eol[6]) : NULL; ptr_buffer = irc_msgbuffer_get_target_buffer (server, argv[3], - command, "whois"); + command, "whois", NULL); if (pos_realname && pos_realname[0]) { @@ -2471,7 +2487,8 @@ irc_protocol_cmd_330_343 (struct t_irc_server *server, const char *command, IRC_PROTOCOL_MIN_ARGS(6); weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, argv[3], - command, "whois"), + command, "whois", + NULL), irc_protocol_tags (command, "irc_numeric"), "%s%s[%s%s%s] %s%s %s%s", weechat_prefix ("network"), @@ -2637,7 +2654,8 @@ irc_protocol_cmd_338 (struct t_irc_server *server, const char *command, IRC_PROTOCOL_MIN_ARGS(6); weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, argv[3], - command, "whois"), + command, "whois", + NULL), irc_protocol_tags (command, "irc_numeric"), "%s%s[%s%s%s]%s %s %s%s", weechat_prefix ("network"), @@ -2671,7 +2689,7 @@ irc_protocol_cmd_341 (struct t_irc_server *server, const char *command, (void) argv_eol; weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, argv[2], - command, NULL), + command, NULL, NULL), irc_protocol_tags (command, "irc_numeric"), _("%s%s%s%s has invited %s%s%s to %s%s%s"), weechat_prefix ("network"), @@ -2703,7 +2721,8 @@ irc_protocol_cmd_344 (struct t_irc_server *server, const char *command, IRC_PROTOCOL_MIN_ARGS(5); weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL, - command, "reop"), + command, "reop", + NULL), irc_protocol_tags (command, "irc_numeric"), _("%sChannel reop %s%s%s: %s%s"), weechat_prefix ("network"), @@ -2731,7 +2750,8 @@ irc_protocol_cmd_345 (struct t_irc_server *server, const char *command, IRC_PROTOCOL_MIN_ARGS(5); weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL, - command, "reop"), + command, "reop", + NULL), irc_protocol_tags (command, "irc_numeric"), "%s%s%s%s: %s", weechat_prefix ("network"), @@ -2866,7 +2886,8 @@ irc_protocol_cmd_351 (struct t_irc_server *server, const char *command, IRC_PROTOCOL_MIN_ARGS(5); - ptr_buffer = irc_msgbuffer_get_target_buffer (server, NULL, command, NULL); + ptr_buffer = irc_msgbuffer_get_target_buffer (server, NULL, command, NULL, + NULL); if (argc > 5) { @@ -2944,7 +2965,8 @@ irc_protocol_cmd_352 (struct t_irc_server *server, const char *command, else { weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL, - command, "who"), + command, "who", + NULL), irc_protocol_tags (command, "irc_numeric"), "%s%s[%s%s%s] %s%s%s(%s%s@%s%s)%s " "%s%s%s%s(%s)", @@ -3380,7 +3402,7 @@ irc_protocol_cmd_432 (struct t_irc_server *server, const char *command, if (!server->is_connected) { ptr_buffer = irc_msgbuffer_get_target_buffer (server, NULL, - command, NULL); + command, NULL, NULL); nick_found = -1; nick_to_use = -1; @@ -3444,7 +3466,7 @@ irc_protocol_cmd_433 (struct t_irc_server *server, const char *command, if (!server->is_connected) { ptr_buffer = irc_msgbuffer_get_target_buffer (server, NULL, - command, NULL); + command, NULL, NULL); nick_found = -1; nick_to_use = -1; @@ -3510,7 +3532,7 @@ irc_protocol_cmd_438 (struct t_irc_server *server, const char *command, IRC_PROTOCOL_MIN_ARGS(4); ptr_buffer = irc_msgbuffer_get_target_buffer (server, NULL, - command, NULL); + command, NULL, NULL); if (argc >= 5) { @@ -3552,7 +3574,8 @@ irc_protocol_cmd_901 (struct t_irc_server *server, const char *command, if (argc >= 7) { weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL, - command, NULL), + command, NULL, + NULL), irc_protocol_tags (command, "irc_numeric"), "%s%s", weechat_prefix ("network"), |