degesch: preliminary message autosplitting

This commit is contained in:
Přemysl Eric Janouch 2015-04-22 22:41:01 +02:00
parent f2a2206e49
commit 53b46482f5

View File

@ -2722,10 +2722,28 @@ send_message_to_target (struct app_context *ctx,
return; return;
} }
// TODO: autosplit int one_message = 0;
irc_send (ctx, "PRIVMSG %s :%s", target, message); if (ctx->irc_user_host)
buffer_send (ctx, buffer, BUFFER_LINE_PRIVMSG, 0, // :<nick>!<user>@<host> PRIVMSG <target> :<message>
ctx->irc_user->nickname, NULL, "%s", message); one_message = 510 - 1 - (int) strlen (ctx->irc_user->nickname)
- 1 - (int) strlen (ctx->irc_user_host)
- 1 - 7 - 1 - strlen (target) - 1 - 1;
// FIXME: UTF-8 sequences
int left = strlen (message);
while (left)
{
int part = MIN (one_message, left);
if (!one_message)
part = left;
irc_send (ctx, "PRIVMSG %s :%.*s", target, part, message);
buffer_send (ctx, buffer, BUFFER_LINE_PRIVMSG, 0,
ctx->irc_user->nickname, NULL, "%.*s", part, message);
left -= part;
message += part;
}
} }
static void static void