summaryrefslogtreecommitdiff
path: root/src/plugins/irc/irc-command.c
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2012-10-20 18:03:08 +0200
committerSebastien Helleu <flashcode@flashtux.org>2012-10-20 18:03:08 +0200
commit9037c0fe4c07b76bafb9a07b1600ac600bcf4245 (patch)
tree2ed03e6cfccc89c5f354c1aedb21ee3a184f3c05 /src/plugins/irc/irc-command.c
parent7ee9e58d1b9494f2fb7befd4107d79616a084ff1 (diff)
downloadweechat-9037c0fe4c07b76bafb9a07b1600ac600bcf4245.zip
irc: add option irc.network.whois_double_nick to double nick in command /whois
Diffstat (limited to 'src/plugins/irc/irc-command.c')
-rw-r--r--src/plugins/irc/irc-command.c48
1 files changed, 29 insertions, 19 deletions
diff --git a/src/plugins/irc/irc-command.c b/src/plugins/irc/irc-command.c
index be2850b0f..9e450ef9b 100644
--- a/src/plugins/irc/irc-command.c
+++ b/src/plugins/irc/irc-command.c
@@ -4888,38 +4888,48 @@ int
irc_command_whois (void *data, struct t_gui_buffer *buffer, int argc,
char **argv, char **argv_eol)
{
+ int double_nick;
+ const char *ptr_nick;
+
IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
IRC_COMMAND_CHECK_SERVER("whois", 1);
/* make C compiler happy */
(void) data;
- (void) argv;
+
+ double_nick = weechat_config_boolean (irc_config_network_whois_double_nick);
+ ptr_nick = NULL;
if (argc > 1)
{
- irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL,
- "WHOIS %s", argv_eol[1]);
- }
- else
- {
- if (ptr_channel
- && (ptr_channel->type == IRC_CHANNEL_TYPE_PRIVATE))
+ if ((argc > 2) || strchr (argv_eol[1], ','))
{
- irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL,
- "WHOIS %s", ptr_channel->name);
+ /* do not double nick if we have more than one argument or a comma */
+ double_nick = 0;
+ ptr_nick = argv_eol[1];
}
else
- {
- if (ptr_server->nick)
- {
- irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL,
- "WHOIS %s", ptr_server->nick);
- }
- else
- IRC_COMMAND_TOO_FEW_ARGUMENTS(ptr_server->buffer, "whois");
- }
+ ptr_nick = argv[1];
+ }
+ else
+ {
+ if (ptr_channel && (ptr_channel->type == IRC_CHANNEL_TYPE_PRIVATE))
+ ptr_nick = ptr_channel->name;
+ else if (ptr_server->nick)
+ ptr_nick = ptr_server->nick;
}
+ if (!ptr_nick)
+ {
+ IRC_COMMAND_TOO_FEW_ARGUMENTS(ptr_server->buffer, "whois");
+ }
+
+ irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL,
+ "WHOIS %s%s%s",
+ ptr_nick,
+ (double_nick) ? " " : "",
+ (double_nick) ? ptr_nick : "");
+
return WEECHAT_RC_OK;
}