summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2011-08-26 12:03:24 +0200
committerSebastien Helleu <flashcode@flashtux.org>2011-08-26 12:03:24 +0200
commitd040fe1b88f8d2a781b2fd051c367d5753a0d43b (patch)
tree764e47c1651ac5957a18b9e766a0e104dc965371 /src
parent4853a530b630440d34d2ce2f8f478523658dbca2 (diff)
downloadweechat-d040fe1b88f8d2a781b2fd051c367d5753a0d43b.zip
irc: fix split of notices with ctcp (like ctcp version), display split messages for notices with ctcp
Diffstat (limited to 'src')
-rw-r--r--src/plugins/irc/irc-ctcp.c64
-rw-r--r--src/plugins/irc/irc-message.c42
2 files changed, 59 insertions, 47 deletions
diff --git a/src/plugins/irc/irc-ctcp.c b/src/plugins/irc/irc-ctcp.c
index 0ef182445..0af20ddfb 100644
--- a/src/plugins/irc/irc-ctcp.c
+++ b/src/plugins/irc/irc-ctcp.c
@@ -253,29 +253,49 @@ irc_ctcp_reply_to_nick (struct t_irc_server *server,
const char *nick, const char *ctcp,
const char *arguments)
{
- irc_server_sendf (server, IRC_SERVER_SEND_OUTQ_PRIO_LOW, NULL,
- "NOTICE %s :\01%s%s%s\01",
- nick, ctcp,
- (arguments) ? " " : "",
- (arguments) ? arguments : "");
-
- if (weechat_config_boolean (irc_config_look_display_ctcp_reply))
+ struct t_hashtable *hashtable;
+ int number;
+ char hash_key[32];
+ const char *str_args;
+
+ hashtable = irc_server_sendf (server,
+ IRC_SERVER_SEND_OUTQ_PRIO_LOW | IRC_SERVER_SEND_RETURN_HASHTABLE,
+ NULL,
+ "NOTICE %s :\01%s%s%s\01",
+ nick, ctcp,
+ (arguments) ? " " : "",
+ (arguments) ? arguments : "");
+
+ if (hashtable)
{
- weechat_printf_tags ((channel) ? channel->buffer : server->buffer,
- irc_protocol_tags (command,
- "irc_ctcp,irc_ctcp_reply,"
- "notify_none,no_highlight",
- NULL),
- _("%sCTCP reply to %s%s%s: %s%s%s%s%s"),
- weechat_prefix ("network"),
- IRC_COLOR_CHAT_NICK,
- nick,
- IRC_COLOR_CHAT,
- IRC_COLOR_CHAT_CHANNEL,
- ctcp,
- (arguments) ? IRC_COLOR_CHAT : "",
- (arguments) ? " " : "",
- (arguments) ? arguments : "");
+ if (weechat_config_boolean (irc_config_look_display_ctcp_reply))
+ {
+ number = 1;
+ while (1)
+ {
+ snprintf (hash_key, sizeof (hash_key), "args%d", number);
+ str_args = weechat_hashtable_get (hashtable, hash_key);
+ if (!str_args)
+ break;
+ weechat_printf_tags ((channel) ? channel->buffer : server->buffer,
+ irc_protocol_tags (command,
+ "irc_ctcp,irc_ctcp_reply,"
+ "notify_none,no_highlight",
+ NULL),
+ _("%sCTCP reply to %s%s%s: %s%s%s%s%s"),
+ weechat_prefix ("network"),
+ IRC_COLOR_CHAT_NICK,
+ nick,
+ IRC_COLOR_CHAT,
+ IRC_COLOR_CHAT_CHANNEL,
+ ctcp,
+ (str_args[0]) ? IRC_COLOR_CHAT : "",
+ (str_args[0]) ? " " : "",
+ str_args);
+ number++;
+ }
+ }
+ weechat_hashtable_free (hashtable);
}
}
diff --git a/src/plugins/irc/irc-message.c b/src/plugins/irc/irc-message.c
index 28c965642..cc6586ba0 100644
--- a/src/plugins/irc/irc-message.c
+++ b/src/plugins/irc/irc-message.c
@@ -605,15 +605,16 @@ irc_message_split_join (struct t_hashtable *hashtable,
}
/*
- * irc_message_split_privmsg: split a PRIVMSG message, taking care of keeping
- * the '\01' char used in CTCP messages
- * return 1 if split ok, 0 if error
+ * irc_message_split_privmsg_notice: split a PRIVMSG or NOTICE message, taking
+ * care of keeping the '\01' char used in
+ * CTCP messages
+ * return 1 if split ok, 0 if error
*/
int
-irc_message_split_privmsg (struct t_hashtable *hashtable,
- char *host, char *command, char *target,
- char *arguments, int max_length_host)
+irc_message_split_privmsg_notice (struct t_hashtable *hashtable,
+ char *host, char *command, char *target,
+ char *arguments, int max_length_host)
{
char prefix[512], suffix[2], *pos, saved_char;
int length, rc;
@@ -626,7 +627,7 @@ irc_message_split_privmsg (struct t_hashtable *hashtable,
* :nick!user@host.com PRIVMSG #channel :hello world!
*/
- /* for CTCP, target2 will be '\01xxxx' and suffix '\01' */
+ /* for CTCP, prefix will be ":\01xxxx " and suffix "\01" */
prefix[0] = '\0';
suffix[0] = '\0';
length = strlen (arguments);
@@ -777,27 +778,18 @@ irc_message_split (struct t_irc_server *server, const char *message)
if (strlen (message) > 510)
split_ok = irc_message_split_join (hashtable, host, arguments);
}
- else if (weechat_strcasecmp (command, "notice") == 0)
+ else if ((weechat_strcasecmp (command, "privmsg") == 0)
+ || (weechat_strcasecmp (command, "notice") == 0))
{
+ /* split privmsg/notice */
if (index_args + 1 <= argc - 1)
{
- split_ok = irc_message_split_string (hashtable, host, command,
- argv[index_args], ":",
- (argv_eol[index_args + 1][0] == ':') ?
- argv_eol[index_args + 1] + 1 : argv_eol[index_args + 1],
- NULL, ' ', max_length_host);
- }
- }
- else if (weechat_strcasecmp (command, "privmsg") == 0)
- {
- /* split privmsg */
- if (index_args + 1 <= argc - 1)
- {
- split_ok = irc_message_split_privmsg (hashtable, host, command,
- argv[index_args],
- (argv_eol[index_args + 1][0] == ':') ?
- argv_eol[index_args + 1] + 1 : argv_eol[index_args + 1],
- max_length_host);
+ split_ok = irc_message_split_privmsg_notice (hashtable, host,
+ command,
+ argv[index_args],
+ (argv_eol[index_args + 1][0] == ':') ?
+ argv_eol[index_args + 1] + 1 : argv_eol[index_args + 1],
+ max_length_host);
}
}
else if (weechat_strcasecmp (command, "005") == 0)