Rehash: added support for channel changing
authorDan
Sat, 10 Jan 2009 14:08:11 -0500
changeset 49 4c4d69b2cd4d
parent 48 d793361a27ec
child 50 45164bc2567a
Rehash: added support for channel changing
enanobot.php
--- a/enanobot.php	Sat Jan 10 14:07:54 2009 -0500
+++ b/enanobot.php	Sat Jan 10 14:08:11 2009 -0500
@@ -189,7 +189,30 @@
     require('config.php');
     $GLOBALS['privileged_list'] = $privileged_list;
     $GLOBALS['alert_list'] = $alert_list;
-    $irc->privmsg($message['nick'], "Reloaded privileged_list and alert_list. privileged = " . str_replace("\n", '', print_r($privileged_list, true)) . "; alert = " . str_replace("\n", '', print_r($alert_list, true)));
+    $GLOBALS['channels'] = $channels;
+    print_r($channels);
+    $in = array();
+    foreach ( $irc->channels as $channel )
+    {
+      $channame = $channel->get_channel_name();
+      if ( !in_array($channame, $channels) )
+      {
+        $channel->part("Leaving");
+      }
+      else
+      {
+        $in[] = $channame;
+      }
+    }
+    unset($channel);
+    foreach ( $channels as $channel )
+    {
+      if ( !in_array($channel, $in) )
+      {
+        $GLOBALS[ preg_replace('/^(#|&)/', '', $channel) ] = $irc->join($channel, 'enanobot_channel_event');
+      }
+    }
+    $irc->privmsg($message['nick'], "Config has been reloaded.");
   }
   else if ( substr($message['message'], 0, 1) == "\x01" && substr($message['message'], -1) == "\x01" )
   {