*
*/
require_once("Bot.class.php");
+require_once("saxdb.class.php");
class BotLoader {
private $uplink;
+ private $saxdb;
+ private $botdb;
+ private $loadedBots = array();
public function __construct($uplink) {
$this->uplink = $uplink;
+ $this->saxdb = new saxdb();
+ $this->saxdb->loadDB("php_p10.db");
+ $this->botdb = $this->saxdb->getSection("BotLoader");
}
public function loadBots() {
+ if(array_key_exists("bots", $this->botdb) && is_array($this->botdb["bots"])) {
+ foreach($this->botdb["bots"] as $name => $botfile) {
+ $this->loadBot($name, $botfile);
+ }
+ } else {
+ $this->botdb["bots"] = array();
+ }
+ }
+ private function loadBot($name, $botfile) {
+ if(array_key_exists($name, $this->loadedBots)) return;
+ //load bot
+ if(!array_key_exists($name, $this->botdb["bots"])) {
+ $this->botdb["bots"][$name] = $botfile;
+ }
}
}