Fix bug with IRC notices for channel: display them in channel instead of server buffer (bug #18730)

This commit is contained in:
Sebastien Helleu 2008-10-03 18:09:23 +02:00
parent dfaa43ff17
commit b18a61984f
2 changed files with 72 additions and 49 deletions

View File

@ -2255,12 +2255,10 @@ irc_command_notice (void *data, struct t_gui_buffer *buffer, int argc,
string = irc_color_decode (argv_eol[2],
weechat_config_boolean (irc_config_network_colors_receive));
weechat_printf (ptr_server->buffer,
"%snotice%s(%s%s%s)%s: %s",
"%sNotice -> %s%s%s: %s",
irc_buffer_get_server_prefix (ptr_server, NULL),
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_NICK,
argv[1],
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT,
(string) ? string : argv_eol[2]);
if (string)

View File

@ -659,7 +659,7 @@ int
irc_protocol_cmd_notice (struct t_irc_server *server, const char *command,
int argc, char **argv, char **argv_eol)
{
char *pos_args, *pos_end, *pos_usec, tags[128];
char *pos_target, *pos_args, *pos_end, *pos_usec, tags[128];
struct timeval tv;
long sec1, usec1, sec2, usec2, difftime;
struct t_irc_channel *ptr_channel;
@ -667,15 +667,22 @@ irc_protocol_cmd_notice (struct t_irc_server *server, const char *command,
/* NOTICE message looks like:
NOTICE AUTH :*** Looking up your hostname...
:nick!user@host NOTICE mynick :notice text
:nick!user@host NOTICE #channel :notice text
*/
IRC_PROTOCOL_GET_HOST;
IRC_PROTOCOL_MIN_ARGS(3);
if (argv[0][0] == ':')
{
pos_target = argv[2];
pos_args = (argv_eol[3][0] == ':') ? argv_eol[3] + 1 : argv_eol[3];
}
else
{
pos_target = NULL;
pos_args = (argv_eol[2][0] == ':') ? argv_eol[2] + 1 : argv_eol[2];
}
if (nick && irc_ignore_check (server, NULL, nick, host))
return WEECHAT_RC_OK;
@ -699,9 +706,7 @@ irc_protocol_cmd_notice (struct t_irc_server *server, const char *command,
if (pos_end)
pos_end[0] = '\01';
}
else
{
if (nick && strncmp (pos_args, "\01PING", 5) == 0)
else if (nick && strncmp (pos_args, "\01PING", 5) == 0)
{
pos_args += 5;
while (pos_args[0] == ' ')
@ -749,6 +754,25 @@ irc_protocol_cmd_notice (struct t_irc_server *server, const char *command,
}
else
{
if (pos_target && irc_channel_is_channel (pos_target))
{
/* notice for channel */
ptr_channel = irc_channel_search (server, pos_target);
weechat_printf_tags ((ptr_channel) ? ptr_channel->buffer : server->buffer,
"irc_notice",
"%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,
(nick && nick[0]) ? nick : "?",
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT,
pos_args);
}
else
{
/* notice for user */
if (nick
&& (weechat_strcasecmp (nick, "nickserv") != 0)
&& (weechat_strcasecmp (nick, "chanserv") != 0)
@ -762,6 +786,7 @@ irc_protocol_cmd_notice (struct t_irc_server *server, const char *command,
snprintf (tags, sizeof (tags),
"%s", "irc_notice");
}
if (nick && weechat_config_boolean (irc_config_look_notice_as_pv))
{
ptr_channel = irc_channel_search (server, nick);