LOGIN without Password added
authorMarkus Bröker <mbroeker@largo.dyndns.tv>
Sat, 13 Dec 2008 15:41:35 +0100
changeset 18 4435146391ae
parent 17 9a32b5242320
child 19 66114d944208
LOGIN without Password added * the bot can access an irc server without a password * the help system won't start a botwar anymore committer: Markus Bröker <mbroeker@largo.homelinux.org>
TODO
config/.mcbotrc
debian/changelog
src/config.c
src/irc.c
src/main.c
src/parse.c
--- a/TODO
+++ b/TODO
@@ -10,10 +10,12 @@
 Todo:
 	* UTF-8 aware Character-Encoding
 	* Dynamic Loading of plugins with dlopen
-	* implementation of some fun stuff  
+	* implementation of some fun stuff
+	* AUTO-RECONNECT must be implemented
 
 Author:
 	* Markus Broeker mbroeker@largo.homelinux.org
 	
 Comments:
 	* scanner/parser rewritten
+	* a flex / bison parser will be better and safer than pointer arithmetics
--- a/config/.mcbotrc
+++ b/config/.mcbotrc
@@ -2,8 +2,8 @@
 # This is a simple ~/.mcbotrc
 # NO SPACING, PLEASE !!
 #
-NICK:test
-PASSWORD:test
+NICK:mcbot278
+PASSWORD:
 SERVER:irc.freenode.net
 PORT:6667
 CHANNEL:#test
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,4 +1,4 @@
-mcbot (0.95-0) unstable; urgency=low
+mcbot (0.95-1) unstable; urgency=low
 
   * Initial Release
   * the location of mcbot.cgi is stored in the db
@@ -14,5 +14,7 @@
   * compat.c added for XOPEN_SOURCE features - not finished yet
   * SOURCE_URL points to the proper git-location.
   * many small improvements, reduced codebase
+  * IRC access without password added
+  * Help System was able to start a botwar. Fixed
 
- -- Markus Broeker <mbroeker@largo.homelinux.org>  Mon, 11 Aug 2008 00:00:54 +0200
+ -- Markus Broeker <mbroeker@largo.homelinux.org>  Mon, 11 Aug 2008 20:45:54 +0200
--- a/src/config.c
+++ b/src/config.c
@@ -103,7 +103,7 @@
     if (line != NULL)
         free (line);
 
-    if (!(uc->nick && uc->pass && uc->server && uc->channel))
+    if (!(uc->nick && uc->server && uc->channel))
         return -2;
 
     return 0;
--- a/src/irc.c
+++ b/src/irc.c
@@ -105,9 +105,6 @@
     if ((pwd = getpwnam (user)) == NULL)
         return IRC_GENERAL_ERROR;
 
-    if (password == NULL)
-        return IRC_LOGIN_ERROR;
-
     if (stream == NULL)
         return IRC_GENERAL_ERROR;
     else
@@ -115,7 +112,9 @@
 
     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);
+
+    if (password != NULL)
+        fprintf (stream, "PRIVMSG NICKSERV :IDENTIFY %s\r\n", password);
 
     for (;;) {
         *msg = '\0';
@@ -148,6 +147,12 @@
         if (strstr (msg, "is not registered") != NULL) {
             return IRC_LOGIN_ERROR;
         }
+        if (strstr (msg, ":Nickname is already in use") != NULL) {
+            return IRC_LOGIN_ERROR;
+        }
+
+        if (password == NULL)
+            break;
     }
 
     sleep (2);
@@ -329,6 +334,9 @@
                 message->line = strtok (NULL, "\r\n");
                 fprintf (message->stream, "PRIVMSG %s :%s\r\n", message->current_channel, message->line);
                 return command;
+            case 433:          /* NICK ALREADY IN USE */
+            case 451:          /* REGISTER FIRST */
+                return command;
             case 474:
             case 475:
             case 476:
--- a/src/main.c
+++ b/src/main.c
@@ -53,9 +53,7 @@
             printf ("You need to create a config file %s\n", CONFIG_FILE);
             break;
         case -2:
-            printf
-                ("You need at least entries for user, password, server and channel in your config file %s\n",
-                 CONFIG_FILE);
+            printf ("You need at least entries for user, server and channel in your config file %s\n", CONFIG_FILE);
             break;
         }
         return len;
--- a/src/parse.c
+++ b/src/parse.c
@@ -46,21 +46,21 @@
 
 const
 char *COMMAND_LIST[] = {
-    "!help      Known Commands: join(1), leave(2), add(3), replace(4), delete(5), list(6), search(7), info(8)\r\n",
-    "!join:     Joins a new channel\r\n",
-    "!leave:    Parts from the current channel\r\n",
-    "!add:      adds an entry\r\n",
-    "!replace:  replaces an entry\r\n",
-    "!delete:   deletes an entry\r\n",
-    "!list:     lists the number of stored values\r\n",
-    "!search:   searches an entry up\r\n",
-    "!info:     Prints the current Bot-Version\r\n",
-    "!ping:     pings an host\r\n",
-    "!on:       enables autolearning mode\r\n",
-    "!off:      disables autolearning\r\n",
-    "!debug:    prints some debug infos\r\n",
-    "!vaccuum:  reorganizes the database\r\n",
-    "!logout:   Protected logout function\r\n",
+    "help      Known Commands: join(1), leave(2), add(3), replace(4), delete(5), list(6), search(7), info(8)\r\n",
+    "join:     Joins a new channel\r\n",
+    "leave:    Parts from the current channel\r\n",
+    "add:      adds an entry\r\n",
+    "replace:  replaces an entry\r\n",
+    "delete:   deletes an entry\r\n",
+    "list:     lists the number of stored values\r\n",
+    "search:   searches an entry up\r\n",
+    "info:     Prints the current Bot-Version\r\n",
+    "ping:     pings an host\r\n",
+    "on:       enables autolearning mode\r\n",
+    "off:      disables autolearning\r\n",
+    "debug:    prints some debug infos\r\n",
+    "vaccuum:  reorganizes the database\r\n",
+    "logout:   Protected logout function\r\n",
     NULL,
 };