summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--handle.c27
1 files changed, 22 insertions, 5 deletions
diff --git a/handle.c b/handle.c
index da635b4..2af5837 100644
--- a/handle.c
+++ b/handle.c
@@ -193,15 +193,31 @@ static void handleJoin(struct Message *msg) {
 	);
 }
 
+static bool isAction(struct Message *msg) {
+	if (strncmp(msg->params[1], "\1ACTION ", 8)) return false;
+	msg->params[1] += 8;
+	size_t len = strlen(msg->params[1]);
+	if (msg->params[1][len - 1] == '\1') msg->params[1][len - 1] = '\0';
+	return true;
+}
+
 static void handlePrivmsg(struct Message *msg) {
 	require(msg, true, 2);
-	bool query = self.nick && !strcmp(msg->params[0], self.nick);
-	size_t id = idFor(query ? msg->nick : msg->params[0]);
-	if (query) idColors[id] = hash(msg->user);
+	bool query = msg->params[0][0] != '#'; // FIXME: CHANTYPES.
+	bool network = query && strchr(msg->nick, '.');
+	bool notice = (msg->cmd[0] == 'N');
+	bool action = isAction(msg);
+	// TODO: Send services to Network?
+	size_t id = (network ? Network : idFor(query ? msg->nick : msg->params[0]));
+	if (query && !network) idColors[id] = hash(msg->user);
 	uiFormat(
 		id, Warm, tagTime(msg),
-		"\3%d<%s>\3 %s",
-		hash(msg->user), msg->nick, msg->params[1]
+		"\3%d%s%s%s\3 %s",
+		hash(msg->user),
+		(action ? "* " : notice ? "-" : "<"),
+		msg->nick,
+		(action ? "" : notice ? "-" : ">"),
+		msg->params[1]
 	);
 }
 
@@ -226,6 +242,7 @@ static const struct Handler {
 	{ "AUTHENTICATE", handleAuthenticate },
 	{ "CAP", handleCap },
 	{ "JOIN", handleJoin },
+	{ "NOTICE", handlePrivmsg },
 	{ "PING", handlePing },
 	{ "PRIVMSG", handlePrivmsg },
 };
7c39&follow=1'>Implement sizeof in orderJune McEnroe 2019-05-15Add orderJune McEnroe 2019-05-12Add T suffix in bitJune McEnroe 2019-05-10Highlight yacc and lex files as CJune McEnroe Their %-prefixed directives should probably be highlighted Macro. 2019-05-10Use val instead of suboptargJune McEnroe suboptarg doesn't exist in GNU. Hopefully BSD getsubopt also sets val on failure? 2019-05-09Add Parable of the SowerJune McEnroe 2019-05-07Add bit without buildJune McEnroe Need to do some stuff in the Makefile for lex and yacc and generating HTML pages for it. 2019-05-04Fix MANDIR typoJune McEnroe 2019-05-04Move relay to binJune McEnroe