about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2018-12-03 10:33:04 -0500
committerJune McEnroe <june@causal.agency>2018-12-03 10:33:04 -0500
commit7dab1c01f69fdf0bf9bd2918d9e955a1e7257d63 (patch)
tree9a969484c6fa541597f46003c0c477597c1cad73
parentIgnore ~ username prefixes (diff)
downloadcatgirl-7dab1c01f69fdf0bf9bd2918d9e955a1e7257d63.tar.gz
catgirl-7dab1c01f69fdf0bf9bd2918d9e955a1e7257d63.zip
Check nick to determine if is self
I forgot that usernames aren't unique for a minute there.
-rw-r--r--handle.c31
1 files changed, 13 insertions, 18 deletions
diff --git a/handle.c b/handle.c
index 759d494..973845f 100644
--- a/handle.c
+++ b/handle.c
@@ -66,11 +66,6 @@ static void parse(
 	va_end(ap);
 }
 
-static bool isSelf(const char *user) {
-	if (!user) return false;
-	return !strcmp(user, self.user);
-}
-
 static bool isPing(const char *mesg) {
 	size_t len = strlen(self.nick);
 	const char *match = mesg;
@@ -193,7 +188,7 @@ static void handleJoin(char *prefix, char *params) {
 	parse(prefix, &nick, &user, NULL, params, 1, 0, &chan);
 	struct Tag tag = tagFor(chan);
 
-	if (isSelf(user)) {
+	if (!strcmp(nick, self.nick)) {
 		tabTouch(TagNone, chan);
 		uiViewTag(tag);
 		logReplay(tag);
@@ -213,7 +208,7 @@ static void handlePart(char *prefix, char *params) {
 	parse(prefix, &nick, &user, NULL, params, 1, 1, &chan, &mesg);
 	struct Tag tag = tagFor(chan);
 
-	if (isSelf(user)) {
+	if (!strcmp(nick, self.nick)) {
 		tabClear(tag);
 	} else {
 		tabRemove(tag, nick);
@@ -317,7 +312,7 @@ static void handleTopic(char *prefix, char *params) {
 	parse(prefix, &nick, &user, NULL, params, 2, 0, &chan, &topic);
 	struct Tag tag = tagFor(chan);
 
-	if (!isSelf(user)) tabTouch(tag, nick);
+	if (strcmp(nick, self.nick)) tabTouch(tag, nick);
 
 	urlScan(tag, topic);
 	uiFmt(
@@ -376,7 +371,7 @@ static void handleNick(char *prefix, char *params) {
 	char *prev, *user, *next;
 	parse(prefix, &prev, &user, NULL, params, 1, 0, &next);
 
-	if (isSelf(user)) {
+	if (!strcmp(prev, self.nick)) {
 		free(self.nick);
 		self.nick = strdup(next);
 		if (!self.nick) err(EX_OSERR, "strdup");
@@ -402,10 +397,10 @@ static void handleCTCP(struct Tag tag, char *nick, char *user, char *mesg) {
 	char *params = strsep(&mesg, "\1");
 	if (strcmp(ctcp, "ACTION")) return;
 
-	if (!isSelf(user)) tabTouch(tag, nick);
+	if (strcmp(nick, self.nick)) tabTouch(tag, nick);
 
 	urlScan(tag, params);
-	bool ping = !isSelf(user) && isPing(params);
+	bool ping = strcmp(nick, self.nick) && isPing(params);
 	uiFmt(
 		tag, (ping ? UIHot : UIWarm),
 		"%c\3%d* %s\17 %s",
@@ -424,16 +419,16 @@ static void handlePrivmsg(char *prefix, char *params) {
 		return;
 	}
 
-	bool self = isSelf(user);
-	if (!self) tabTouch(tag, nick);
+	bool me = !strcmp(nick, self.nick);
+	if (!me) tabTouch(tag, nick);
 
 	urlScan(tag, mesg);
-	bool hot = !self && (direct || isPing(mesg));
-	bool ping = !self && isPing(mesg);
+	bool hot = !me && (direct || isPing(mesg));
+	bool ping = !me && isPing(mesg);
 	uiFmt(
 		tag, (hot ? UIHot : UIWarm),
 		"%c\3%d%c%s%c\17 %s",
-		ping["\17\26"], formatColor(user), self["<("], nick, self[">)"], mesg
+		ping["\17\26"], formatColor(user), me["<("], nick, me[">)"], mesg
 	);
 	logFmt(tag, NULL, "<%s> %s", nick, mesg);
 }
@@ -444,10 +439,10 @@ static void handleNotice(char *prefix, char *params) {
 	struct Tag tag = TagStatus;
 	if (user) tag = (strcmp(chan, self.nick) ? tagFor(chan) : tagFor(nick));
 
-	if (!isSelf(user)) tabTouch(tag, nick);
+	if (strcmp(nick, self.nick)) tabTouch(tag, nick);
 
 	urlScan(tag, mesg);
-	bool ping = !isSelf(user) && isPing(mesg);
+	bool ping = strcmp(nick, self.nick) && isPing(mesg);
 	uiFmt(
 		tag, (ping ? UIHot : UIWarm),
 		"%c\3%d-%s-\17 %s",
highlight'> 2019-10-26Do not require RPL_ISUPPORT for stateReadyJune McEnroe 2019-10-26Implement graceful shutdownJune McEnroe 2019-10-26Require PASS before USERJune McEnroe Prevent creating a ring consumer without authentication. 2019-10-26Track channel topicsJune McEnroe 2019-10-26Set AWAY when no clients are connectedJune McEnroe 2019-10-26Add flags to request TOPIC and NAMES on client connectJune McEnroe 2019-10-26OopsJune McEnroe 2019-10-26Disconnect client on unknown commandJune McEnroe During registration, no other commands should be sent. Afterwards, only intercepted commands will get parsed. 2019-10-26Allow reading sensitive information from filesJune McEnroe 2019-10-26Add rc scriptJune McEnroe 2019-10-25Add install and uninstall targetsJune McEnroe 2019-10-25Expand documentationJune McEnroe 2019-10-25Add AGPLv3 notice on client registrationJune McEnroe OwO 2019-10-25Rename project pounceJune McEnroe