Commits

Tony Manco committed d48b58e

Improved module auto loading

  • Participants
  • Parent commits 0136c92

Comments (0)

Files changed (1)

         $bytes = socket_write($this->socket, $cmd, strlen($cmd));
         if ($bytes){
             if (strpos($cmd, 'PASS') !== 0 && stripos($cmd, 'NickServ') === false)
-                echo ("Message sent with success $cmd\r\n");
+                echo ("Message sent with success -> $cmd\r\n");
             return true;
         }
         else{
                 $joinx += 1;
             }
             print $this->line;
+            // Auto loading of modules
             foreach ($this->modules as $module) {
                 // Windows path fix
                 if ($_SERVER['OS'] == 'Windows_NT')
-                    include "$this->modpath"."\\$module".'.php';
+                    $mod = "$this->modpath"."\\$module".'.php';
                 else
-                    include "$this->modpath"."/$module".'.php';
+                    $mod = "$this->modpath"."/$module".'.php';
+                if (file_exists($mod)) {
+                    // Load it if file exists
+                    $this->SendCommand("Module $module sucefully loaded!\r\n");
+                    include "$mod";
+                }
+                else
+                    $this->SendCommand("Failed to load module $module. Reason: Not found!\r\n");
+
             }
             if ($this->log)
                 $this->LogRaw($this->line);