summary refs log tree commit diff
path: root/client.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-02-26 02:37:14 -0500
committerJune McEnroe <june@causal.agency>2020-02-26 02:37:14 -0500
commit8705de3da60bcffa11169218441f1782fb55fe86 (patch)
tree7e9f9da116123ba47d3c7cf9f21aebe17bb72194 /client.c
parentTweak buffer sizes (diff)
downloadpounce-8705de3da60bcffa11169218441f1782fb55fe86.tar.gz
pounce-8705de3da60bcffa11169218441f1782fb55fe86.zip
Use %n for tags when formatting intercepted PRIVMSG/NOTICE
Diffstat (limited to 'client.c')
-rw-r--r--client.c20
1 files 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;
 
publicJune McEnroe 2019-10-24Rename some thingsJune McEnroe 2019-10-23Add ISUPPORT draft to STANDARDSJune McEnroe 2019-10-23Track own originJune McEnroe 2019-10-23Track channels and sync ISUPPORTJune McEnroe 2019-10-23Track nick changesJune McEnroe 2019-10-23Rename Command to MessageJune McEnroe 2019-10-23Synchronize state after client registrationJune McEnroe 2019-10-23Send to server if client has no needsJune McEnroe 2019-10-23Implement some amount of client connectionJune McEnroe 2019-10-23Set clients non-blockingJune McEnroe 2019-10-23Clean up state.c and factor out parsingJune McEnroe 2019-10-23Respond to pingsJune McEnroe 2019-10-23Add verbose flagJune McEnroe 2019-10-23Set NOSIGPIPE on server connectionJune McEnroe 2019-10-23Set an initial loop capJune McEnroe 2019-10-23Fix rest parsingJune McEnroe 2019-10-23Add dynamic poll listJune McEnroe 2019-10-23Don't assume commands have targets and handle ERRORJune McEnroe 2019-10-23Clean up state somewhatJune McEnroe 2019-10-23Actually send the buffer...June McEnroe 2019-10-23Add stateJune McEnroe