mirror of
https://github.com/weechat/weechat.git
synced 2026-06-27 13:26:38 +02:00
irc: fix split of notices with ctcp (like ctcp version), display split messages for notices with ctcp
This commit is contained in:
+42
-22
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user