summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-02-02 17:26:20 -0500
committerJune McEnroe <june@causal.agency>2020-02-02 17:26:20 -0500
commitb535f0abdde6fb79f9f972d0b39c8b0a7a837339 (patch)
tree66d6dde524f93bb8b8a45d22e7af78bb89913abc
parentAdd option to show style codes (diff)
downloadcatgirl-b535f0abdde6fb79f9f972d0b39c8b0a7a837339.tar.gz
catgirl-b535f0abdde6fb79f9f972d0b39c8b0a7a837339.zip
Handle notices and actions
Diffstat (limited to '')
-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 },
 };
/a>Christian Hesse 2014-12-13ui-diff: add "stat only" diff typeJohn Keeping 2014-12-13Change "ss" diff flag to an enumJohn Keeping 2014-12-13ui-shared: remove toggle_ssdiff arg to cgit_diff_link()John Keeping 2014-12-13ui-shared: remove toggle_ssdiff arg to cgit_commit_link()John Keeping 2014-08-07git: update to v2.0.4John Keeping 2014-08-07Always check if README exists in choose_readme()Lukas Fleischer 2014-08-01cgitrc.5: we mean a cgi response, not requestJason A. Donenfeld 2014-07-28ui-stats.c: set parent pointer to NULL after freeing itJohn Keeping 2014-07-28git: update to v2.0.3John Keeping 2014-07-28parsing.c: make commit buffer constJohn Keeping 2014-06-30Bump version.Jason A. Donenfeld 2014-06-29remove debug fprinf() calls that sneaked in with commit 79c985Christian Hesse 2014-06-28git: update to 2.0.1Christian Hesse 2014-06-28ui-patch: Flush stdout after outputting dataJohn Keeping 2014-06-28ui-log: ignore unhandled argumentsJohn Keeping 2014-06-28git: update for git 2.0Christian Hesse 2014-04-17remove trailing whitespaces from source filesChristian Hesse 2014-04-12git: update to 1.9.2Christian Hesse 2014-04-05Fix cgit_parse_url when a repo url is contained in another repo urlJulian Maurice 2014-03-20Makefile: use more reliable git tarball mirrorJason A. Donenfeld 2014-03-20git: update to 1.9.1Christian Hesse