mirror of
https://github.com/weechat/weechat.git
synced 2026-06-26 12:56:37 +02:00
Add IRC options to customize target buffer for messages (task #7381)
This commit is contained in:
@@ -30,6 +30,7 @@ irc-ignore.c irc-ignore.h
|
||||
irc-info.c irc-info.h
|
||||
irc-input.c irc-input.h
|
||||
irc-mode.c irc-mode.h
|
||||
irc-msgbuffer.c irc-msgbuffer.h
|
||||
irc-nick.c irc-nick.h
|
||||
irc-protocol.c irc-protocol.h
|
||||
irc-raw.c irc-raw.h
|
||||
|
||||
@@ -50,6 +50,8 @@ irc_la_SOURCES = irc.c \
|
||||
irc-input.h \
|
||||
irc-mode.c \
|
||||
irc-mode.h \
|
||||
irc-msgbuffer.c \
|
||||
irc-msgbuffer.h \
|
||||
irc-nick.c \
|
||||
irc-nick.h \
|
||||
irc-protocol.c \
|
||||
|
||||
@@ -32,12 +32,14 @@
|
||||
#include "irc-ctcp.h"
|
||||
#include "irc-buffer.h"
|
||||
#include "irc-ignore.h"
|
||||
#include "irc-msgbuffer.h"
|
||||
#include "irc-nick.h"
|
||||
#include "irc-server.h"
|
||||
#include "irc-channel.h"
|
||||
|
||||
|
||||
struct t_config_file *irc_config_file = NULL;
|
||||
struct t_config_section *irc_config_section_msgbuffer = NULL;
|
||||
struct t_config_section *irc_config_section_ctcp = NULL;
|
||||
struct t_config_section *irc_config_section_server_default = NULL;
|
||||
struct t_config_section *irc_config_section_server = NULL;
|
||||
@@ -59,6 +61,7 @@ struct t_config_option *irc_config_look_display_old_topic;
|
||||
struct t_config_option *irc_config_look_hide_nickserv_pwd;
|
||||
struct t_config_option *irc_config_look_highlight_tags;
|
||||
struct t_config_option *irc_config_look_item_display_server;
|
||||
struct t_config_option *irc_config_look_msgbuffer_fallback;
|
||||
struct t_config_option *irc_config_look_notice_as_pv;
|
||||
struct t_config_option *irc_config_look_raw_messages;
|
||||
struct t_config_option *irc_config_look_show_away_once;
|
||||
@@ -554,6 +557,72 @@ irc_config_reload (void *data, struct t_config_file *config_file)
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_config_msgbuffer_create_option: set a message target buffer
|
||||
*/
|
||||
|
||||
int
|
||||
irc_config_msgbuffer_create_option (void *data,
|
||||
struct t_config_file *config_file,
|
||||
struct t_config_section *section,
|
||||
const char *option_name, const char *value)
|
||||
{
|
||||
struct t_config_option *ptr_option;
|
||||
int rc;
|
||||
const char *pos_name;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
rc = WEECHAT_CONFIG_OPTION_SET_ERROR;
|
||||
|
||||
if (option_name)
|
||||
{
|
||||
ptr_option = weechat_config_search_option (config_file, section,
|
||||
option_name);
|
||||
if (ptr_option)
|
||||
{
|
||||
if (value)
|
||||
rc = weechat_config_option_set (ptr_option, value, 1);
|
||||
else
|
||||
{
|
||||
weechat_config_option_free (ptr_option);
|
||||
rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (value)
|
||||
{
|
||||
pos_name = strchr (option_name, '.');
|
||||
pos_name = (pos_name) ? pos_name + 1 : option_name;
|
||||
|
||||
ptr_option = weechat_config_new_option (
|
||||
config_file, section,
|
||||
option_name, "integer",
|
||||
_("buffer used to display message received from IRC "
|
||||
"server"),
|
||||
"weechat|current|private", 0, 0, value, value, 0,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
rc = (ptr_option) ?
|
||||
WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE : WEECHAT_CONFIG_OPTION_SET_ERROR;
|
||||
}
|
||||
else
|
||||
rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (rc == WEECHAT_CONFIG_OPTION_SET_ERROR)
|
||||
{
|
||||
weechat_printf (NULL,
|
||||
_("%s%s: error creating \"%s\" => \"%s\""),
|
||||
weechat_prefix ("error"), IRC_PLUGIN_NAME,
|
||||
option_name, value);
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_config_ctcp_create_option: set a ctcp reply format
|
||||
*/
|
||||
@@ -1322,6 +1391,13 @@ irc_config_init ()
|
||||
N_("name of bar item where IRC server is displayed (for status bar)"),
|
||||
"buffer_plugin|buffer_name", 0, 0, "buffer_plugin", NULL, 0, NULL, NULL,
|
||||
&irc_config_change_look_item_display_server, NULL, NULL, NULL);
|
||||
irc_config_look_msgbuffer_fallback = weechat_config_new_option (
|
||||
irc_config_file, ptr_section,
|
||||
"msgbuffer_fallback", "integer",
|
||||
N_("default target buffer for msgbuffer options when target is "
|
||||
"private and that private buffer is not found"),
|
||||
"current|server", 0, 0, "current", NULL, 0, NULL, NULL,
|
||||
NULL, NULL, NULL, NULL);
|
||||
irc_config_look_raw_messages = weechat_config_new_option (
|
||||
irc_config_file, ptr_section,
|
||||
"raw_messages", "integer",
|
||||
@@ -1487,6 +1563,20 @@ irc_config_init ()
|
||||
NULL, 0, 0, "off", NULL, 0, NULL, NULL,
|
||||
&irc_config_change_network_send_unknown_commands, NULL, NULL, NULL);
|
||||
|
||||
/* msgbuffer */
|
||||
ptr_section = weechat_config_new_section (irc_config_file, "msgbuffer",
|
||||
1, 1,
|
||||
NULL, NULL, NULL, NULL,
|
||||
NULL, NULL,
|
||||
&irc_config_msgbuffer_create_option, NULL,
|
||||
NULL, NULL);
|
||||
if (!ptr_section)
|
||||
{
|
||||
weechat_config_free (irc_config_file);
|
||||
return 0;
|
||||
}
|
||||
irc_config_section_msgbuffer = ptr_section;
|
||||
|
||||
/* CTCP */
|
||||
ptr_section = weechat_config_new_section (irc_config_file, "ctcp",
|
||||
1, 1,
|
||||
@@ -1499,7 +1589,6 @@ irc_config_init ()
|
||||
weechat_config_free (irc_config_file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
irc_config_section_ctcp = ptr_section;
|
||||
|
||||
/* ignore */
|
||||
@@ -1526,7 +1615,6 @@ irc_config_init ()
|
||||
weechat_config_free (irc_config_file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
irc_config_section_server_default = ptr_section;
|
||||
|
||||
irc_config_server_create_default_options (ptr_section);
|
||||
@@ -1544,7 +1632,6 @@ irc_config_init ()
|
||||
weechat_config_free (irc_config_file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
irc_config_section_server = ptr_section;
|
||||
|
||||
hook_config_color_nicks_number = weechat_hook_config ("weechat.look.color_nicks_number",
|
||||
|
||||
@@ -35,6 +35,12 @@ enum t_irc_config_look_item_display_server
|
||||
IRC_CONFIG_LOOK_ITEM_DISPLAY_SERVER_NAME,
|
||||
};
|
||||
|
||||
enum t_irc_config_look_msgbuffer_fallback
|
||||
{
|
||||
IRC_CONFIG_LOOK_MSGBUFFER_FALLBACK_CURRENT = 0,
|
||||
IRC_CONFIG_LOOK_MSGBUFFER_FALLBACK_SERVER,
|
||||
};
|
||||
|
||||
enum t_irc_config_look_notice_as_pv
|
||||
{
|
||||
IRC_CONFIG_LOOK_NOTICE_AS_PV_AUTO = 0,
|
||||
@@ -57,6 +63,7 @@ enum t_irc_config_display_away
|
||||
};
|
||||
|
||||
extern struct t_config_file *irc_config_file;
|
||||
extern struct t_config_section *irc_config_section_msgbuffer;
|
||||
extern struct t_config_section *irc_config_section_ctcp;
|
||||
extern struct t_config_section *irc_config_section_server_default;
|
||||
extern struct t_config_section *irc_config_section_server;
|
||||
@@ -76,6 +83,7 @@ extern struct t_config_option *irc_config_look_display_old_topic;
|
||||
extern struct t_config_option *irc_config_look_hide_nickserv_pwd;
|
||||
extern struct t_config_option *irc_config_look_highlight_tags;
|
||||
extern struct t_config_option *irc_config_look_item_display_server;
|
||||
extern struct t_config_option *irc_config_look_msgbuffer_fallback;
|
||||
extern struct t_config_option *irc_config_look_notice_as_pv;
|
||||
extern struct t_config_option *irc_config_look_raw_messages;
|
||||
extern struct t_config_option *irc_config_look_show_away_once;
|
||||
|
||||
@@ -0,0 +1,142 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2009 by FlashCode <flashcode@flashtux.org>
|
||||
* See README for License detail, AUTHORS for developers list.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* irc-msgbuffer.c: target buffer for IRC messages
|
||||
(weechat, current, private) */
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
#include <sys/utsname.h>
|
||||
|
||||
#include "../weechat-plugin.h"
|
||||
#include "irc.h"
|
||||
#include "irc-msgbuffer.h"
|
||||
#include "irc-channel.h"
|
||||
#include "irc-config.h"
|
||||
#include "irc-server.h"
|
||||
|
||||
|
||||
char *irc_msgbuffer_target_string[] =
|
||||
{ "weechat", "server", "current", "private" };
|
||||
|
||||
|
||||
/*
|
||||
* irc_msgbuffer_get_string: get string value for target
|
||||
*/
|
||||
|
||||
const char *
|
||||
irc_msgbuffer_get_string (int target)
|
||||
{
|
||||
if ((target < 0) || (target >= IRC_MSGBUFFER_NUM_TARGETS))
|
||||
return NULL;
|
||||
|
||||
return irc_msgbuffer_target_string[target];
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_msgbuffer_get_option: get pointer to option with IRC message
|
||||
*/
|
||||
|
||||
struct t_config_option *
|
||||
irc_msgbuffer_get_option (struct t_irc_server *server, const char *message)
|
||||
{
|
||||
struct t_config_option *ptr_option;
|
||||
char option_name[512];
|
||||
|
||||
if (server)
|
||||
{
|
||||
snprintf (option_name, sizeof (option_name),
|
||||
"%s.%s", server->name, message);
|
||||
|
||||
/* search for msgbuffer in config file, for server */
|
||||
ptr_option = weechat_config_search_option (irc_config_file,
|
||||
irc_config_section_msgbuffer,
|
||||
option_name);
|
||||
if (ptr_option)
|
||||
return ptr_option;
|
||||
}
|
||||
|
||||
/* search for msgbuffer in config file */
|
||||
ptr_option = weechat_config_search_option (irc_config_file,
|
||||
irc_config_section_msgbuffer,
|
||||
message);
|
||||
if (ptr_option)
|
||||
return ptr_option;
|
||||
|
||||
/* no msgbuffer found in config */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* irc_msgbuffer_get_target_buffer: get target for IRC message
|
||||
* message is IRC message
|
||||
* (for example: "invite", "312")
|
||||
* alias is optional alias for message
|
||||
* (for example "whois")
|
||||
*/
|
||||
|
||||
struct t_gui_buffer *
|
||||
irc_msgbuffer_get_target_buffer (struct t_irc_server *server, const char *nick,
|
||||
const char *message, const char *alias)
|
||||
{
|
||||
struct t_config_option *ptr_option;
|
||||
int target;
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
struct t_irc_channel *ptr_channel;
|
||||
struct t_weechat_plugin *buffer_plugin;
|
||||
|
||||
ptr_option = irc_msgbuffer_get_option (server, message);
|
||||
if (!ptr_option && alias && alias[0])
|
||||
ptr_option = irc_msgbuffer_get_option (server, alias);
|
||||
|
||||
target = (ptr_option) ?
|
||||
weechat_config_integer (ptr_option) : -1;
|
||||
|
||||
switch (target)
|
||||
{
|
||||
case IRC_MSGBUFFER_TARGET_WEECHAT:
|
||||
return NULL;
|
||||
break;
|
||||
case IRC_MSGBUFFER_TARGET_CURRENT:
|
||||
break;
|
||||
case IRC_MSGBUFFER_TARGET_PRIVATE:
|
||||
ptr_channel = irc_channel_search (server, nick);
|
||||
if (ptr_channel)
|
||||
return ptr_channel->buffer;
|
||||
if (weechat_config_integer (irc_config_look_msgbuffer_fallback) ==
|
||||
IRC_CONFIG_LOOK_MSGBUFFER_FALLBACK_SERVER)
|
||||
{
|
||||
return (server) ? server->buffer : NULL;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return (server) ? server->buffer : NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
ptr_buffer = weechat_current_buffer ();
|
||||
buffer_plugin = weechat_buffer_get_pointer (ptr_buffer, "plugin");
|
||||
if (buffer_plugin == weechat_irc_plugin)
|
||||
return ptr_buffer;
|
||||
return (server) ? server->buffer : NULL;
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2009 by FlashCode <flashcode@flashtux.org>
|
||||
* See README for License detail, AUTHORS for developers list.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __WEECHAT_IRC_MSGBUFFER_H
|
||||
#define __WEECHAT_IRC_MSGBUFFER_H 1
|
||||
|
||||
enum t_irc_msgbuffer_target
|
||||
{
|
||||
IRC_MSGBUFFER_TARGET_WEECHAT = 0,
|
||||
IRC_MSGBUFFER_TARGET_CURRENT,
|
||||
IRC_MSGBUFFER_TARGET_PRIVATE,
|
||||
/* number of msgbuffer targets */
|
||||
IRC_MSGBUFFER_NUM_TARGETS,
|
||||
};
|
||||
|
||||
struct t_irc_server;
|
||||
|
||||
struct t_irc_msgbuffer
|
||||
{
|
||||
char *message; /* IRC message */
|
||||
enum t_irc_msgbuffer_target target; /* target buffer */
|
||||
};
|
||||
|
||||
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);
|
||||
|
||||
#endif /* irc-msgbuffer.h */
|
||||
+121
-41
@@ -35,15 +35,16 @@
|
||||
#include "irc.h"
|
||||
#include "irc-protocol.h"
|
||||
#include "irc-buffer.h"
|
||||
#include "irc-channel.h"
|
||||
#include "irc-color.h"
|
||||
#include "irc-command.h"
|
||||
#include "irc-config.h"
|
||||
#include "irc-ctcp.h"
|
||||
#include "irc-server.h"
|
||||
#include "irc-channel.h"
|
||||
#include "irc-nick.h"
|
||||
#include "irc-mode.h"
|
||||
#include "irc-ignore.h"
|
||||
#include "irc-mode.h"
|
||||
#include "irc-msgbuffer.h"
|
||||
#include "irc-nick.h"
|
||||
#include "irc-server.h"
|
||||
|
||||
|
||||
/*
|
||||
@@ -289,7 +290,8 @@ irc_protocol_cmd_invite (struct t_irc_server *server, const char *command,
|
||||
|
||||
if (!irc_ignore_check (server, NULL, nick, host))
|
||||
{
|
||||
weechat_printf_tags (server->buffer,
|
||||
weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, nick,
|
||||
command, NULL),
|
||||
irc_protocol_tags (command, "notify_highlight"),
|
||||
_("%sYou have been invited to %s%s%s by "
|
||||
"%s%s%s"),
|
||||
@@ -765,6 +767,7 @@ irc_protocol_cmd_notice (struct t_irc_server *server, const char *command,
|
||||
struct t_irc_channel *ptr_channel;
|
||||
struct t_irc_nick *ptr_nick;
|
||||
int notify_private;
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
|
||||
/* NOTICE message looks like:
|
||||
NOTICE AUTH :*** Looking up your hostname...
|
||||
@@ -861,9 +864,11 @@ irc_protocol_cmd_notice (struct t_irc_server *server, const char *command,
|
||||
}
|
||||
else
|
||||
{
|
||||
ptr_buffer = irc_msgbuffer_get_target_buffer (server, nick,
|
||||
command, NULL);
|
||||
if (address && address[0])
|
||||
{
|
||||
weechat_printf_tags (server->buffer,
|
||||
weechat_printf_tags (ptr_buffer,
|
||||
irc_protocol_tags (command,
|
||||
(notify_private) ? "notify_private" : NULL),
|
||||
"%s%s%s %s(%s%s%s)%s: %s",
|
||||
@@ -881,7 +886,7 @@ irc_protocol_cmd_notice (struct t_irc_server *server, const char *command,
|
||||
{
|
||||
if (nick && nick[0])
|
||||
{
|
||||
weechat_printf_tags (server->buffer,
|
||||
weechat_printf_tags (ptr_buffer,
|
||||
irc_protocol_tags (command,
|
||||
(notify_private) ? "notify_private" : NULL),
|
||||
"%s%s%s%s: %s",
|
||||
@@ -893,7 +898,7 @@ irc_protocol_cmd_notice (struct t_irc_server *server, const char *command,
|
||||
}
|
||||
else
|
||||
{
|
||||
weechat_printf_tags (server->buffer,
|
||||
weechat_printf_tags (ptr_buffer,
|
||||
irc_protocol_tags (command,
|
||||
(notify_private) ? "notify_private" : NULL),
|
||||
"%s%s",
|
||||
@@ -1393,7 +1398,8 @@ irc_protocol_cmd_numeric (struct t_irc_server *server, const char *command,
|
||||
pos_args = (argv_eol[2][0] == ':') ? argv_eol[2] + 1 : argv_eol[2];
|
||||
}
|
||||
|
||||
weechat_printf_tags (server->buffer,
|
||||
weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL,
|
||||
command, NULL),
|
||||
irc_protocol_tags (command, "irc_numeric"),
|
||||
"%s%s",
|
||||
weechat_prefix ("network"),
|
||||
@@ -1523,7 +1529,8 @@ irc_protocol_cmd_wallops (struct t_irc_server *server, const char *command,
|
||||
|
||||
if (!irc_ignore_check (server, NULL, nick, host))
|
||||
{
|
||||
weechat_printf_tags (server->buffer,
|
||||
weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, nick,
|
||||
command, NULL),
|
||||
irc_protocol_tags (command, NULL),
|
||||
_("%sWallops from %s%s %s(%s%s%s)%s: %s"),
|
||||
weechat_prefix ("network"),
|
||||
@@ -1674,7 +1681,8 @@ irc_protocol_cmd_221 (struct t_irc_server *server, const char *command,
|
||||
|
||||
IRC_PROTOCOL_MIN_ARGS(4);
|
||||
|
||||
weechat_printf_tags (server->buffer,
|
||||
weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, argv[2],
|
||||
command, NULL),
|
||||
irc_protocol_tags (command, "irc_numeric"),
|
||||
_("%sUser mode for %s%s%s is %s[%s%s%s]"),
|
||||
weechat_prefix ("network"),
|
||||
@@ -1760,7 +1768,8 @@ irc_protocol_cmd_303 (struct t_irc_server *server, const char *command,
|
||||
/* make C compiler happy */
|
||||
(void) argv;
|
||||
|
||||
weechat_printf_tags (server->buffer,
|
||||
weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL,
|
||||
command, NULL),
|
||||
irc_protocol_tags (command, "irc_numeric"),
|
||||
_("%sUsers online: %s%s"),
|
||||
weechat_prefix ("network"),
|
||||
@@ -1789,7 +1798,8 @@ irc_protocol_cmd_305 (struct t_irc_server *server, const char *command,
|
||||
|
||||
if (argc > 3)
|
||||
{
|
||||
weechat_printf_tags (server->buffer,
|
||||
weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL,
|
||||
command, "unaway"),
|
||||
irc_protocol_tags (command, "irc_numeric"),
|
||||
"%s%s",
|
||||
weechat_prefix ("network"),
|
||||
@@ -1823,7 +1833,8 @@ irc_protocol_cmd_306 (struct t_irc_server *server, const char *command,
|
||||
|
||||
if (argc > 3)
|
||||
{
|
||||
weechat_printf_tags (server->buffer,
|
||||
weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL,
|
||||
command, "away"),
|
||||
irc_protocol_tags (command, "irc_numeric"),
|
||||
"%s%s",
|
||||
weechat_prefix ("network"),
|
||||
@@ -1852,7 +1863,37 @@ irc_protocol_cmd_whois_nick_msg (struct t_irc_server *server, const char *comman
|
||||
|
||||
IRC_PROTOCOL_MIN_ARGS(5);
|
||||
|
||||
weechat_printf_tags (server->buffer,
|
||||
weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, argv[3],
|
||||
command, "whois"),
|
||||
irc_protocol_tags (command, "irc_numeric"),
|
||||
"%s%s[%s%s%s] %s%s",
|
||||
weechat_prefix ("network"),
|
||||
IRC_COLOR_CHAT_DELIMITERS,
|
||||
IRC_COLOR_CHAT_NICK,
|
||||
argv[3],
|
||||
IRC_COLOR_CHAT_DELIMITERS,
|
||||
IRC_COLOR_CHAT,
|
||||
(argv_eol[4][0] == ':') ? argv_eol[4] + 1 : argv_eol[4]);
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_protocol_cmd_whowas_nick_msg: a whowas command with nick and message
|
||||
*/
|
||||
|
||||
int
|
||||
irc_protocol_cmd_whowas_nick_msg (struct t_irc_server *server, const char *command,
|
||||
int argc, char **argv, char **argv_eol)
|
||||
{
|
||||
/* messages look like:
|
||||
:server 369 flashy FlashCode :some text here
|
||||
*/
|
||||
|
||||
IRC_PROTOCOL_MIN_ARGS(5);
|
||||
|
||||
weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, argv[3],
|
||||
command, "whowas"),
|
||||
irc_protocol_tags (command, "irc_numeric"),
|
||||
"%s%s[%s%s%s] %s%s",
|
||||
weechat_prefix ("network"),
|
||||
@@ -1880,7 +1921,8 @@ irc_protocol_cmd_311 (struct t_irc_server *server, const char *command,
|
||||
|
||||
IRC_PROTOCOL_MIN_ARGS(8);
|
||||
|
||||
weechat_printf_tags (server->buffer,
|
||||
weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, argv[3],
|
||||
command, "whois"),
|
||||
irc_protocol_tags (command, "irc_numeric"),
|
||||
"%s%s[%s%s%s] (%s%s@%s%s)%s: %s",
|
||||
weechat_prefix ("network"),
|
||||
@@ -1912,7 +1954,8 @@ irc_protocol_cmd_312 (struct t_irc_server *server, const char *command,
|
||||
|
||||
IRC_PROTOCOL_MIN_ARGS(6);
|
||||
|
||||
weechat_printf_tags (server->buffer,
|
||||
weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, argv[3],
|
||||
command, "whois"),
|
||||
irc_protocol_tags (command, "irc_numeric"),
|
||||
"%s%s[%s%s%s] %s%s %s(%s%s%s)",
|
||||
weechat_prefix ("network"),
|
||||
@@ -1944,7 +1987,8 @@ irc_protocol_cmd_314 (struct t_irc_server *server, const char *command,
|
||||
|
||||
IRC_PROTOCOL_MIN_ARGS(8);
|
||||
|
||||
weechat_printf_tags (server->buffer,
|
||||
weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, argv[3],
|
||||
command, "whowas"),
|
||||
irc_protocol_tags (command, "irc_numeric"),
|
||||
_("%s%s[%s%s%s] (%s%s@%s%s)%s was %s"),
|
||||
weechat_prefix ("network"),
|
||||
@@ -1985,7 +2029,8 @@ irc_protocol_cmd_315 (struct t_irc_server *server, const char *command,
|
||||
}
|
||||
else
|
||||
{
|
||||
weechat_printf_tags (server->buffer,
|
||||
weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL,
|
||||
command, "who"),
|
||||
irc_protocol_tags (command, "irc_numeric"),
|
||||
"%s%s[%s%s%s]%s %s",
|
||||
weechat_prefix ("network"),
|
||||
@@ -2010,6 +2055,7 @@ irc_protocol_cmd_317 (struct t_irc_server *server, const char *command,
|
||||
{
|
||||
int idle_time, day, hour, min, sec;
|
||||
time_t datetime;
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
|
||||
/* 317 message looks like:
|
||||
:server 317 mynick nick 122877 1205327880 :seconds idle, signon time
|
||||
@@ -2028,9 +2074,12 @@ 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");
|
||||
|
||||
if (day > 0)
|
||||
{
|
||||
weechat_printf_tags (server->buffer,
|
||||
weechat_printf_tags (ptr_buffer,
|
||||
irc_protocol_tags (command, "irc_numeric"),
|
||||
_("%s%s[%s%s%s]%s idle: %s%d %s%s, "
|
||||
"%s%02d %s%s %s%02d %s%s %s%02d "
|
||||
@@ -2062,7 +2111,7 @@ irc_protocol_cmd_317 (struct t_irc_server *server, const char *command,
|
||||
}
|
||||
else
|
||||
{
|
||||
weechat_printf_tags (server->buffer,
|
||||
weechat_printf_tags (ptr_buffer,
|
||||
irc_protocol_tags (command, "irc_numeric"),
|
||||
_("%s%s[%s%s%s]%s idle: %s%02d %s%s "
|
||||
"%s%02d %s%s %s%02d %s%s, "
|
||||
@@ -2111,7 +2160,8 @@ irc_protocol_cmd_321 (struct t_irc_server *server, const char *command,
|
||||
pos_args = (argc > 4) ?
|
||||
((argv_eol[4][0] == ':') ? argv_eol[4] + 1 : argv_eol[4]) : NULL;
|
||||
|
||||
weechat_printf_tags (server->buffer,
|
||||
weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL,
|
||||
command, "list"),
|
||||
irc_protocol_tags (command, "irc_numeric"),
|
||||
"%s%s%s%s",
|
||||
weechat_prefix ("network"),
|
||||
@@ -2144,7 +2194,8 @@ irc_protocol_cmd_322 (struct t_irc_server *server, const char *command,
|
||||
if (!server->cmd_list_regexp ||
|
||||
(regexec (server->cmd_list_regexp, argv[3], 0, NULL, 0) == 0))
|
||||
{
|
||||
weechat_printf_tags (server->buffer,
|
||||
weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL,
|
||||
command, "list"),
|
||||
irc_protocol_tags (command, "irc_numeric"),
|
||||
"%s%s%s%s(%s%s%s)%s%s%s",
|
||||
weechat_prefix ("network"),
|
||||
@@ -2184,7 +2235,8 @@ irc_protocol_cmd_323 (struct t_irc_server *server, const char *command,
|
||||
pos_args = (argc > 3) ?
|
||||
((argv_eol[3][0] == ':') ? argv_eol[3] + 1 : argv_eol[3]) : NULL;
|
||||
|
||||
weechat_printf_tags (server->buffer,
|
||||
weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL,
|
||||
command, "list"),
|
||||
irc_protocol_tags (command, "irc_numeric"),
|
||||
"%s%s",
|
||||
weechat_prefix ("network"),
|
||||
@@ -2242,16 +2294,20 @@ irc_protocol_cmd_327 (struct t_irc_server *server, const char *command,
|
||||
int argc, char **argv, char **argv_eol)
|
||||
{
|
||||
char *pos_realname;
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
|
||||
/* 327 message looks like:
|
||||
:server 327 mynick nick host ip :real hostname/ip
|
||||
*/
|
||||
|
||||
|
||||
IRC_PROTOCOL_MIN_ARGS(6);
|
||||
|
||||
pos_realname = (argc > 6) ?
|
||||
((argv_eol[6][0] == ':') ? argv_eol[6] + 1 : argv_eol[6]) : NULL;
|
||||
|
||||
ptr_buffer = irc_msgbuffer_get_target_buffer (server, argv[3],
|
||||
command, "whois");
|
||||
|
||||
if (pos_realname && pos_realname[0])
|
||||
{
|
||||
weechat_printf_tags (server->buffer,
|
||||
@@ -2384,7 +2440,8 @@ irc_protocol_cmd_330 (struct t_irc_server *server, const char *command,
|
||||
|
||||
IRC_PROTOCOL_MIN_ARGS(6);
|
||||
|
||||
weechat_printf_tags (server->buffer,
|
||||
weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, argv[3],
|
||||
command, "whois"),
|
||||
irc_protocol_tags (command, "irc_numeric"),
|
||||
"%s%s[%s%s%s] %s%s %s%s",
|
||||
weechat_prefix ("network"),
|
||||
@@ -2549,7 +2606,8 @@ irc_protocol_cmd_338 (struct t_irc_server *server, const char *command,
|
||||
|
||||
IRC_PROTOCOL_MIN_ARGS(6);
|
||||
|
||||
weechat_printf_tags (server->buffer,
|
||||
weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, argv[3],
|
||||
command, "whois"),
|
||||
irc_protocol_tags (command, "irc_numeric"),
|
||||
"%s%s[%s%s%s]%s %s %s%s",
|
||||
weechat_prefix ("network"),
|
||||
@@ -2582,7 +2640,8 @@ irc_protocol_cmd_341 (struct t_irc_server *server, const char *command,
|
||||
/* make C compiler happy */
|
||||
(void) argv_eol;
|
||||
|
||||
weechat_printf_tags (server->buffer,
|
||||
weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, argv[2],
|
||||
command, NULL),
|
||||
irc_protocol_tags (command, "irc_numeric"),
|
||||
_("%s%s%s%s has invited %s%s%s to %s%s%s"),
|
||||
weechat_prefix ("network"),
|
||||
@@ -2613,7 +2672,8 @@ irc_protocol_cmd_344 (struct t_irc_server *server, const char *command,
|
||||
|
||||
IRC_PROTOCOL_MIN_ARGS(5);
|
||||
|
||||
weechat_printf_tags (server->buffer,
|
||||
weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL,
|
||||
command, "reop"),
|
||||
irc_protocol_tags (command, "irc_numeric"),
|
||||
_("%sChannel reop %s%s%s: %s%s"),
|
||||
weechat_prefix ("network"),
|
||||
@@ -2640,7 +2700,8 @@ irc_protocol_cmd_345 (struct t_irc_server *server, const char *command,
|
||||
|
||||
IRC_PROTOCOL_MIN_ARGS(5);
|
||||
|
||||
weechat_printf_tags (server->buffer,
|
||||
weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL,
|
||||
command, "reop"),
|
||||
irc_protocol_tags (command, "irc_numeric"),
|
||||
"%s%s%s%s: %s",
|
||||
weechat_prefix ("network"),
|
||||
@@ -2767,15 +2828,19 @@ int
|
||||
irc_protocol_cmd_351 (struct t_irc_server *server, const char *command,
|
||||
int argc, char **argv, char **argv_eol)
|
||||
{
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
|
||||
/* 351 message looks like:
|
||||
:server 351 mynick dancer-ircd-1.0.36(2006/07/23_13:11:50). server :iMZ dncrTS/v4
|
||||
*/
|
||||
|
||||
IRC_PROTOCOL_MIN_ARGS(5);
|
||||
|
||||
ptr_buffer = irc_msgbuffer_get_target_buffer (server, NULL, command, NULL);
|
||||
|
||||
if (argc > 5)
|
||||
{
|
||||
weechat_printf_tags (server->buffer,
|
||||
weechat_printf_tags (ptr_buffer,
|
||||
irc_protocol_tags (command, "irc_numeric"),
|
||||
"%s%s %s (%s)",
|
||||
weechat_prefix ("network"),
|
||||
@@ -2785,7 +2850,7 @@ irc_protocol_cmd_351 (struct t_irc_server *server, const char *command,
|
||||
}
|
||||
else
|
||||
{
|
||||
weechat_printf_tags (server->buffer,
|
||||
weechat_printf_tags (ptr_buffer,
|
||||
irc_protocol_tags (command, "irc_numeric"),
|
||||
"%s%s %s",
|
||||
weechat_prefix ("network"),
|
||||
@@ -2848,7 +2913,8 @@ irc_protocol_cmd_352 (struct t_irc_server *server, const char *command,
|
||||
}
|
||||
else
|
||||
{
|
||||
weechat_printf_tags (server->buffer,
|
||||
weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL,
|
||||
command, "who"),
|
||||
irc_protocol_tags (command, "irc_numeric"),
|
||||
"%s%s[%s%s%s] %s%s%s(%s%s@%s%s)%s "
|
||||
"%s%s%s%s(%s)",
|
||||
@@ -3273,11 +3339,15 @@ irc_protocol_cmd_432 (struct t_irc_server *server, const char *command,
|
||||
int argc, char **argv, char **argv_eol)
|
||||
{
|
||||
int i, nick_found, nick_to_use;
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
|
||||
irc_protocol_cmd_error (server, command, argc, argv, argv_eol);
|
||||
|
||||
if (!server->is_connected)
|
||||
{
|
||||
ptr_buffer = irc_msgbuffer_get_target_buffer (server, NULL,
|
||||
command, NULL);
|
||||
|
||||
nick_found = -1;
|
||||
nick_to_use = -1;
|
||||
for (i = 0; i < server->nicks_count; i++)
|
||||
@@ -3297,7 +3367,7 @@ irc_protocol_cmd_432 (struct t_irc_server *server, const char *command,
|
||||
}
|
||||
if (nick_to_use < 0)
|
||||
{
|
||||
weechat_printf (server->buffer,
|
||||
weechat_printf (ptr_buffer,
|
||||
_("%s%s: all declared nicknames are "
|
||||
"already in use or invalid, closing "
|
||||
"connection with server"),
|
||||
@@ -3307,7 +3377,7 @@ irc_protocol_cmd_432 (struct t_irc_server *server, const char *command,
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
weechat_printf (server->buffer,
|
||||
weechat_printf (ptr_buffer,
|
||||
_("%s%s: nickname \"%s\" is invalid, "
|
||||
"trying nickname #%d (\"%s\")"),
|
||||
weechat_prefix ("error"),
|
||||
@@ -3331,9 +3401,13 @@ irc_protocol_cmd_433 (struct t_irc_server *server, const char *command,
|
||||
int argc, char **argv, char **argv_eol)
|
||||
{
|
||||
int i, nick_found, nick_to_use;
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
|
||||
if (!server->is_connected)
|
||||
{
|
||||
ptr_buffer = irc_msgbuffer_get_target_buffer (server, NULL,
|
||||
command, NULL);
|
||||
|
||||
nick_found = -1;
|
||||
nick_to_use = -1;
|
||||
for (i = 0; i < server->nicks_count; i++)
|
||||
@@ -3353,7 +3427,7 @@ irc_protocol_cmd_433 (struct t_irc_server *server, const char *command,
|
||||
}
|
||||
if (nick_to_use < 0)
|
||||
{
|
||||
weechat_printf (server->buffer,
|
||||
weechat_printf (ptr_buffer,
|
||||
_("%s%s: all declared nicknames are "
|
||||
"already in use, closing "
|
||||
"connection with server"),
|
||||
@@ -3363,7 +3437,7 @@ irc_protocol_cmd_433 (struct t_irc_server *server, const char *command,
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
weechat_printf (server->buffer,
|
||||
weechat_printf (ptr_buffer,
|
||||
_("%s: nickname \"%s\" is already in use, "
|
||||
"trying nickname #%d (\"%s\")"),
|
||||
IRC_PLUGIN_NAME, server->nick,
|
||||
@@ -3389,15 +3463,20 @@ int
|
||||
irc_protocol_cmd_438 (struct t_irc_server *server, const char *command,
|
||||
int argc, char **argv, char **argv_eol)
|
||||
{
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
|
||||
/* 438 message looks like:
|
||||
:server 438 mynick newnick :Nick change too fast. Please wait 30 seconds.
|
||||
*/
|
||||
|
||||
IRC_PROTOCOL_MIN_ARGS(4);
|
||||
|
||||
ptr_buffer = irc_msgbuffer_get_target_buffer (server, NULL,
|
||||
command, NULL);
|
||||
|
||||
if (argc >= 5)
|
||||
{
|
||||
weechat_printf_tags (server->buffer,
|
||||
weechat_printf_tags (ptr_buffer,
|
||||
irc_protocol_tags (command, "irc_numeric"),
|
||||
"%s%s (%s => %s)",
|
||||
weechat_prefix ("network"),
|
||||
@@ -3407,7 +3486,7 @@ irc_protocol_cmd_438 (struct t_irc_server *server, const char *command,
|
||||
}
|
||||
else
|
||||
{
|
||||
weechat_printf_tags (server->buffer,
|
||||
weechat_printf_tags (ptr_buffer,
|
||||
irc_protocol_tags (command, "irc_numeric"),
|
||||
"%s%s %s",
|
||||
weechat_prefix ("network"),
|
||||
@@ -3434,7 +3513,8 @@ irc_protocol_cmd_901 (struct t_irc_server *server, const char *command,
|
||||
|
||||
if (argc >= 7)
|
||||
{
|
||||
weechat_printf_tags (server->buffer,
|
||||
weechat_printf_tags (irc_msgbuffer_get_target_buffer (server, NULL,
|
||||
command, NULL),
|
||||
irc_protocol_tags (command, "irc_numeric"),
|
||||
"%s%s",
|
||||
weechat_prefix ("network"),
|
||||
@@ -3541,7 +3621,7 @@ irc_protocol_recv_command (struct t_irc_server *server, const char *entire_line,
|
||||
{ "366", /* end of /names list */ 1, &irc_protocol_cmd_366 },
|
||||
{ "367", /* banlist */ 1, &irc_protocol_cmd_367 },
|
||||
{ "368", /* end of banlist */ 1, &irc_protocol_cmd_368 },
|
||||
{ "369", /* whowas (end) */ 1, &irc_protocol_cmd_whois_nick_msg },
|
||||
{ "369", /* whowas (end) */ 1, &irc_protocol_cmd_whowas_nick_msg },
|
||||
{ "378", /* whois (connecting from) */ 1, &irc_protocol_cmd_whois_nick_msg },
|
||||
{ "379", /* whois (using modes) */ 1, &irc_protocol_cmd_whois_nick_msg },
|
||||
{ "401", /* no such nick/channel */ 1, &irc_protocol_cmd_error },
|
||||
|
||||
Reference in New Issue
Block a user