diff --git a/src/irc.c b/src/irc.c --- a/src/irc.c +++ b/src/irc.c @@ -96,9 +96,7 @@ return IRC_GENERAL_ERROR; fprintf (stream, "NICK %s\r\n", nick); - fprintf (stream, "USER %s 0 %s %s\r\n", user, server, pwd->pw_gecos); - fprintf (stream, "PRIVMSG NICKSERV :IDENTIFY %s\r\n", password); for (;;) { @@ -169,11 +167,10 @@ return message->command; } -/* +/** * Main prints ("%10s %s %s\n", MSG->command MSG->channel MSG->line). * This functions makes sure, that there will be someting to print... */ - char *irc_parsemessage (const char *line, MSG * message) { int i; @@ -186,7 +183,6 @@ while (IRC_Commands[i] != NULL) { if (strcmp (IRC_Commands[i], command) == 0) { switch (i) { - case 0: /* NOTICE */ if (message->line == NULL) { message->channel = "*"; @@ -214,6 +210,9 @@ return command; case 5: /* PING */ #ifdef DEBUG + /* + * DONT NERVE WITH PING PONG MESSAGES + */ printf ("%10s %s localhost\n", "PING", message->line); #endif fprintf (message->stream, "PONG :%s\r\n", message->line); @@ -225,8 +224,7 @@ #endif case 6: /* ENOMEM */ case 7: /* ERROR */ - exit (-1); - break; + return command; case 8: /* VERSION */ if ((ptr = strchr (message->user, ' '))) *ptr = 0; @@ -238,6 +236,7 @@ *ptr = 0; message->channel = strtok (message->line, " "); + message->current_channel = message->channel; message->line = strtok (NULL, "\r\n"); message->line++; printf ("%10s %s %s :%s\n", "READ", message->command, message->channel, message->line); @@ -271,7 +270,6 @@ * prints as is in irc_login */ return command; - break; case 311: case 312: case 315: /* END OF WHO */ @@ -282,7 +280,7 @@ case 319: message->channel = strtok (message->line, " "); message->line = strtok (NULL, "\r\n"); - fprintf (message->stream, "PRIVMSG %s :%s\r\n", "#mcbot", message->line); + fprintf (message->stream, "PRIVMSG %s :%s\r\n", message->current_channel, message->line); return command; case 320: case 332: /* TOPIC OF CHANNEL */ @@ -301,14 +299,12 @@ * MORE THAN 3 LINES AND YOU WILL be KICKED */ return command; - break; case 353: case 365: case 366: /* END OF NAMES */ message->channel = strtok (message->line, " "); message->line = strtok (NULL, "\r\n"); return command; - break; case 372: /* MOTD MESSAGES */ case 375: case 376: /* END OF MOTD */ @@ -316,30 +312,29 @@ break; case 401: /* NO SUCH NICK/CHANNEL */ case 403: /* That CHANNEL doesnt exist */ + case 441: /* They aren't on this channel */ return command; - break; case 474: case 475: case 476: case 477: + case 482: message->channel = strtok (message->line, " "); message->line = strtok (NULL, "\r\n"); return command; - break; case 901: /* notify or some crap */ message->channel = strtok (message->line, " "); message->line = strtok (NULL, "\r\n"); return command; - break; default: printf ("DEBUG %s", line); - printf ("Unknown Value: %d\n", value); + printf ("Unknown Command Value: %d\n", value); } } printf ("DEBUG %s", line); printf ("Unknown Command: %s\n", command); return command; } - printf ("DEBUG %s", line); + printf ("NOT PARSEABLE %s", line); return NULL; }