From 8705de3da60bcffa11169218441f1782fb55fe86 Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Wed, 26 Feb 2020 02:37:14 -0500 Subject: Use %n for tags when formatting intercepted PRIVMSG/NOTICE --- client.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/client.c b/client.c index 2405004..088691a 100644 --- a/client.c +++ b/client.c @@ -227,20 +227,16 @@ static void handleQuit(struct Client *client, struct Message *msg) { static void handlePrivmsg(struct Client *client, struct Message *msg) { if (!msg->params[0] || !msg->params[1]) return; + + int origin; char line[MessageCap]; - if (msg->tags) { - snprintf( - line, sizeof(line), "@%s :%s %s %s :%s", - msg->tags, stateEcho(), msg->cmd, msg->params[0], msg->params[1] - ); - } else { - snprintf( - line, sizeof(line), ":%s %s %s :%s", - stateEcho(), msg->cmd, msg->params[0], msg->params[1] - ); - } + snprintf( + line, sizeof(line), "@%s %n:%s %s %s :%s", + (msg->tags ? msg->tags : ""), &origin, + stateEcho(), msg->cmd, msg->params[0], msg->params[1] + ); size_t diff = ringDiff(client->consumer); - ringProduce(line); + ringProduce((msg->tags ? line : &line[origin])); if (!diff) ringConsume(NULL, client->consumer); if (!strcmp(msg->params[0], stateNick())) return; -- cgit 1.4.1