summary refs log tree commit diff
path: root/client.c
diff options
context:
space:
mode:
Diffstat (limited to 'client.c')
-rw-r--r--client.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/client.c b/client.c
index 3ea00c8..22106e3 100644
--- a/client.c
+++ b/client.c
@@ -277,30 +277,31 @@ size_t clientDiff(const struct Client *client) {
 
 typedef const char *Filter(const char *line);
 
-static const char *cmd(const char *line) {
-	static char buf[512];
-	if (*line == ':') {
+static const char *word(size_t i, const char *line) {
+	if (*line != ':') i--;
+	for (; i; --i) {
 		line += strcspn(line, " ");
 		if (*line) line++;
 	}
+	static char buf[512];
 	snprintf(buf, sizeof(buf), "%.*s", (int)strcspn(line, " "), line);
 	return buf;
 }
 
 static const char *filterAccountNotify(const char *line) {
-	return (strcmp(cmd(line), "ACCOUNT") ? line : NULL);
+	return (strcmp(word(1, line), "ACCOUNT") ? line : NULL);
 }
 
 static const char *filterAwayNotify(const char *line) {
-	return (strcmp(cmd(line), "AWAY") ? line : NULL);
+	return (strcmp(word(1, line), "AWAY") ? line : NULL);
 }
 
 static const char *filterChghost(const char *line) {
-	return (strcmp(cmd(line), "CHGHOST") ? line : NULL);
+	return (strcmp(word(1, line), "CHGHOST") ? line : NULL);
 }
 
 static const char *filterExtendedJoin(const char *line) {
-	if (strcmp(cmd(line), "JOIN")) return line;
+	if (strcmp(word(1, line), "JOIN")) return line;
 	size_t len = 0;
 	for (int i = 0; i < 3; ++i) {
 		len += strcspn(&line[len], " ");
@@ -311,11 +312,17 @@ static const char *filterExtendedJoin(const char *line) {
 	return buf;
 }
 
+static const char *filterInviteNotify(const char *line) {
+	if (strcmp(word(1, line), "INVITE")) return line;
+	return (strcmp(word(2, line), stateNick()) ? NULL : line);
+}
+
 static Filter *Filters[] = {
 	[CapAccountNotifyBit] = filterAccountNotify,
 	[CapAwayNotifyBit] = filterAwayNotify,
 	[CapChghostBit] = filterChghost,
 	[CapExtendedJoinBit] = filterExtendedJoin,
+	[CapInviteNotifyBit] = filterInviteNotify,
 };
 
 void clientConsume(struct Client *client) {