wm: ircd

Download patch

ref: cbf3068e0f404a6370d3b7d4da3161d056a071cc
parent: d08105b69107543a67d13df9664f4a4faaa8f2df
author: saeed <saeed@cloud9p.org>
date: Fri Jul 4 13:48:01 IDT 2025

fix PART with no reason disconnecting people and remove extranous \n in 003 message

with some other minor fixes, test in irssi

--- a/ircd.c
+++ b/ircd.c
@@ -92,8 +92,6 @@
 	char *topic;
 	char *topicwho;
 	List members;
-	List banned;
-	List silenced;
 };
 
 /* message that is sent to clients */
@@ -833,7 +831,7 @@
 		r.code = PART;
 		r.argv[0] = c->prefix;
 		r.argv[1] = chan;
-		r.argv[2] = reason;
+		r.argv[2] = reason == nil ? "" : reason;
 		replychan(ch, &r, nil);
 		del(&c->channels, ch);
 		del(&ch->members, c);
@@ -1188,14 +1186,14 @@
 		return 1;
 	}
 	if(strcmp(cmd, "PART") == 0){
-		tmp = strtok(0, " :"); /* channel */
-		if(tmp == nil)
-			return 0;
-		tmp2 = strtok(0, "\r"); /* reason */
-		if(tmp2 == nil)
-			return 0;
-		if(*tmp2 == ':')
-			tmp2++;
+		if(strchr(msg, ':') != nil)
+			tmp = strtok(0, " :"); /* channel, if there is a reason */
+		else
+			tmp = strtok(0, "\r"); /* channel, with no reason */
+
+ 		tmp2 = strtok(0, "\r"); /* reason */
+		if(tmp2 && *tmp2 == ':')
+ 			tmp2++;
 		return part(c, tmp, tmp2);
 	}
 	if(strcmp(cmd, "TOPIC") == 0){
@@ -1220,14 +1218,6 @@
 		tmp = strtok(0, " :\r"); /* channels */
 		return list(c, tmp);
 	}
-	/*
-	 * TODO: WHO doesn't really mean WHOIS, 
-	 * but this is enough for some clients to be happy
-	 */
-	if(strcmp(cmd, "WHO") == 0){
-		tmp = strtok(0, " :\r"); /* nicks */
-		return whois(c, tmp);
-	}
 	if(strcmp(cmd, "WHOIS") == 0){
 		tmp = strtok(0, " :\r"); /* nicks */
 		return whois(c, tmp);
@@ -1264,7 +1254,7 @@
 		c->msgtimer = now+1;
 		return 0;
 	}
-	if(c->msgtimer < now+10){
+	if(c->msgtimer < now+20){
 		c->msgtimer += 1;
 		return 0;
 	}
@@ -1328,6 +1318,9 @@
 		servername = getenv("sysname");
 
 	date = ctime(time(nil));
+	if(date && strchr(date, '\n')){
+		*strchr(date, '\n') = '\0';
+	}
 
 	afd = announce(argv[0], adir);
 	if(afd < 0)
--