Source

pcw / ii-1.4-joinuser.diff

diff -r d93eaacde742 ii.c
--- a/ii.c	Fri Jun 25 10:55:05 2010 +0200
+++ b/ii.c	Thu Jul 08 00:55:27 2010 -0700
@@ -105,6 +105,7 @@
 	return open(infile, O_RDONLY | O_NONBLOCK, 0);
 }
 
+static void print_out(char *channel, char *buf); // needs to be declared
 static void add_channel(char *name) {
 	Channel *c;
 	int fd;
@@ -130,6 +131,12 @@
 	}
 	c->fd = fd;
 	c->name = strdup(name);
+
+	if(name[0] && !((name[0]=='#')||(name[0]=='&')||(name[0]=='+')||(name[0]=='!'))) {
+		char msg[128];
+		snprintf(msg, sizeof(msg), "-!- %s has joined %s", nick, name);
+		print_out(name, msg);
+	}
 }
 
 static void rm_channel(Channel *c) {
@@ -211,6 +218,7 @@
 	if(strstr(buf, server)) channel="";
 	create_filepath(outfile, sizeof(outfile), channel, "out");
 	if(!(out = fopen(outfile, "a"))) return;
+	if(channel && channel[0]) add_channel(channel);
 
 	strftime(buft, sizeof(buft), "%F %R", localtime(&t));
 	fprintf(out, "%s %s\n", buft, buf);
@@ -237,17 +245,14 @@
 		case 'j':
 			p = strchr(&buf[3], ' ');
 			if(p) *p = 0;
+			add_channel(&buf[3]);
 			if((buf[3]=='#')||(buf[3]=='&')||(buf[3]=='+')||(buf[3]=='!')){
 				if(p) snprintf(message, PIPE_BUF, "JOIN %s %s\r\n", &buf[3], p + 1); /* password protected channel */
 				else snprintf(message, PIPE_BUF, "JOIN %s\r\n", &buf[3]);
-				add_channel(&buf[3]);
 			}
-			else {
-				if(p){
-					add_channel(&buf[3]);
-					proc_channels_privmsg(&buf[3], p + 1);
-					return;
-				}
+			else if(p) {
+				proc_channels_privmsg(&buf[3], p + 1);
+				return;
 			}
 			break;
 		case 't':
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.