summaryrefslogtreecommitdiff
path: root/src/plugins/irc/irc-input.c
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2011-08-26 10:31:37 +0200
committerSebastien Helleu <flashcode@flashtux.org>2011-08-26 10:31:37 +0200
commit4853a530b630440d34d2ce2f8f478523658dbca2 (patch)
tree57baab29d9e31de18e22c7b34811ceecd65ed00b /src/plugins/irc/irc-input.c
parentebf72c7eda87e70aed16e890581307f527567bed (diff)
downloadweechat-4853a530b630440d34d2ce2f8f478523658dbca2.zip
irc: improve split of privmsg, add split of some other messages (bug #29879), add new info_hashtable "irc_message_split", split irc messages in relay plugin
List of new features/bugs fixed: - improve split of privmsg: keep CTCP in split - add split of messages: ison, join, notice, wallops, 005, 353 - add new info_hashtable "irc_message_split" (for plugins/scripts) - in relay plugin: split irc messages sent to clients of irc proxy
Diffstat (limited to 'src/plugins/irc/irc-input.c')
-rw-r--r--src/plugins/irc/irc-input.c57
1 files changed, 19 insertions, 38 deletions
diff --git a/src/plugins/irc/irc-input.c b/src/plugins/irc/irc-input.c
index cce50d1f7..0a1b7b5ec 100644
--- a/src/plugins/irc/irc-input.c
+++ b/src/plugins/irc/irc-input.c
@@ -22,6 +22,7 @@
*/
#include <stdlib.h>
+#include <stdio.h>
#include <string.h>
#include "../weechat-plugin.h"
@@ -85,8 +86,9 @@ void
irc_input_send_user_message (struct t_gui_buffer *buffer, int flags,
const char *tags, char *message)
{
- int max_length;
- char *pos, *pos_max, *last_space, *pos_next, *next, saved_char;
+ int number;
+ char hash_key[32], *str_args;
+ struct t_hashtable *hashtable;
IRC_BUFFER_GET_SERVER_CHANNEL(buffer);
@@ -100,45 +102,24 @@ irc_input_send_user_message (struct t_gui_buffer *buffer, int flags,
weechat_prefix ("error"), IRC_PLUGIN_NAME);
return;
}
-
- next = NULL;
- last_space = NULL;
- saved_char = '\0';
-
- max_length = 512 - 16 - 65 - 10 - strlen (ptr_server->nick) -
- strlen (ptr_channel->name);
-
- if (max_length > 0)
+ hashtable = irc_server_sendf (ptr_server,
+ flags | IRC_SERVER_SEND_RETURN_HASHTABLE,
+ tags,
+ "PRIVMSG %s :%s",
+ ptr_channel->name, message);
+ if (hashtable)
{
- if ((int)strlen (message) > max_length)
+ number = 1;
+ while (1)
{
- pos = message;
- pos_max = message + max_length;
- while (pos[0])
- {
- if (pos[0] == ' ')
- last_space = pos;
- pos_next = weechat_utf8_next_char (pos);
- if (pos_next > pos_max)
- break;
- pos = pos_next;
- }
- if (last_space && (last_space < pos))
- pos = last_space + 1;
- saved_char = pos[0];
- pos[0] = '\0';
- next = pos;
+ snprintf (hash_key, sizeof (hash_key), "args%d", number);
+ str_args = weechat_hashtable_get (hashtable, hash_key);
+ if (!str_args)
+ break;
+ irc_input_user_message_display (buffer, str_args);
+ number++;
}
- }
-
- irc_server_sendf (ptr_server, flags, tags,
- "PRIVMSG %s :%s", ptr_channel->name, message);
- irc_input_user_message_display (buffer, message);
-
- if (next)
- {
- next[0] = saved_char;
- irc_input_send_user_message (buffer, flags, tags, next);
+ weechat_hashtable_free (hashtable);
}
}