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.
Diffstat (limited to '')
-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",
rate LINKS from BINS for html to workJune McEnroe 2020-02-11Add margin to Bl-bullet itemsJune McEnroe 2020-02-10Match URLs inside parens or with paired parens insideJune McEnroe 2020-02-10Duplicate effective URL before passing it back to curlJune McEnroe Apparently sometimes it didn't like receiving its own internal storage to parse again. Understandable. 2020-02-09Add To Be Taught, If FortunateJune McEnroe 2020-02-04Add The Future of Another TimelineJune McEnroe Wow. One of the best I've read. 2020-01-31Reorganize the Makefile for the umpteenth timeJune McEnroe Broke out LDLIBS for each bin, and made everything more uniform. 2020-01-28Change scout sensitivity to 1.4June McEnroe idk it seems to work. 2020-01-28Import shows.txtJune McEnroe