From 1d9d044c6a442ba0a94d34ebd51a3be2ba42b383 Mon Sep 17 00:00:00 2001
From: Alcor <alcor@tilde.club>
Date: Mon, 11 May 2026 16:55:04 +0200
Subject: [PATCH 13/19] Implement IRCv3 echo-message.

Also disable local echoing if the capability is supported by the server.
---
 chat.h    | 1 +
 command.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/chat.h b/chat.h
index 092f503..83cc138 100644
--- a/chat.h
+++ b/chat.h
@@ -184,6 +184,7 @@ static inline char bitPrefix(uint p) {
 #define ENUM_CAP \
 	X("causal.agency/consumer", CapConsumer) \
 	X("chghost", CapChghost) \
+	X("echo-message", CapEchoMessage) \
 	X("extended-join", CapExtendedJoin) \
 	X("invite-notify", CapInviteNotify) \
 	X("message-tags", CapMessageTags) \
diff --git a/command.c b/command.c
index 95c61c7..04523e6 100644
--- a/command.c
+++ b/command.c
@@ -60,6 +60,7 @@ static void echoMessage(char *cmd, uint id, char *params) {
 	} else {
 		ircFormat("%s %s :%s\r\n", cmd, idNames[id], params);
 	}
+	if (self.caps & CapEchoMessage) return; /* server-side echo */
 	struct Message msg = {
 		.nick = self.nick,
 		.user = self.user,
-- 
2.47.3

