diff options
author | Přemysl Eric Janouch <p@janouch.name> | 2022-09-10 18:48:15 +0200 |
---|---|---|
committer | Přemysl Eric Janouch <p@janouch.name> | 2022-09-10 18:51:27 +0200 |
commit | 7d5e63be1fd6602ab8e62316202924b316c7436f (patch) | |
tree | 035bed03f6b4e8041c106d023bf6310f5c588f78 /xC.c | |
parent | e7d0f2380eb00610d335d87dd0656e50840aa8c0 (diff) | |
download | xK-7d5e63be1fd6602ab8e62316202924b316c7436f.tar.gz xK-7d5e63be1fd6602ab8e62316202924b316c7436f.tar.xz xK-7d5e63be1fd6602ab8e62316202924b316c7436f.zip |
xC: deal with so far unexpected multiline messages
And get rid of an outdated unmarked TODO comment.
Diffstat (limited to 'xC.c')
-rw-r--r-- | xC.c | 26 |
1 files changed, 17 insertions, 9 deletions
@@ -9075,12 +9075,21 @@ irc_autosplit_message (struct server *s, const char *message, - 1 - (int) strlen (s->irc_user_host) - 1 - fixed_part; - // However we don't always have the full info for message splitting - if (!space_in_one_message) - strv_append (output, message); - else if (!wrap_message (message, space_in_one_message, output, e)) - return false; - return true; + // Multiline messages can be triggered through hooks and plugins. + struct strv lines = strv_make (); + cstr_split (message, "\r\n", false, &lines); + bool success = true; + for (size_t i = 0; i < lines.len; i++) + { + // We don't always have the full info for message splitting. + if (!space_in_one_message) + strv_append (output, lines.vector[i]); + else if (!(success = + wrap_message (lines.vector[i], space_in_one_message, output, e))) + break; + } + strv_free (&lines); + return success; } static void @@ -9089,12 +9098,11 @@ send_autosplit_message (struct server *s, const char *prefix, const char *suffix) { struct buffer *buffer = str_map_find (&s->irc_buffer_map, target); + + // "COMMAND target * :prefix*suffix" int fixed_part = strlen (command) + 1 + strlen (target) + 1 + 1 + strlen (prefix) + strlen (suffix); - // We might also want to preserve attributes across splits but - // that would make this code a lot more complicated - struct strv lines = strv_make (); struct error *e = NULL; if (!irc_autosplit_message (s, message, fixed_part, &lines, &e)) |