/** * Constructor * * Creates connection to the XMPP server, and loads all command classes. * * @return void */ public function __construct() { // Load config $conf = parse_ini_file(dirname(__FILE__) . '/../../Config/JabberBot.ini', true); $this->_config = new JabberBot_Config($conf); $server = $this->_config->getValue('server'); $this->rooms = array(); $this->db = new JabberBot_Db('bot'); $this->acl = new JabberBot_Acl(); $botConf = $this->_config->getValue('bot'); $this->defaultRoom = isset($botConf['defaultroom']) ? $botConf['defaultroom'] : null; $this->pingInverval = $botConf['pinginterval']; // Call parent constructor, and set variables parent::__construct($server['host'], $server['port'], $server['user'], $server['password'], $server['resource'], null, true, $botConf['loglevel']); $this->addEventHandler('reconnect', 'handleReconnect', $this); $this->useEncryption($server['ssl'] == 'true'); // Set up Commands $commandBase = dirname(__FILE__) . '/Command/'; foreach (scandir($commandBase) as $filename) { if (preg_match('/^(.*).class.php/', $filename)) { $this->log->log('Including ' . $commandBase . $filename, XMPPHP_Log::LEVEL_INFO); require_once $commandBase . $filename; } } $this->arrCommands = array(); foreach (get_declared_classes() as $className) { if (get_parent_class($className) == 'JabberBot_Command') { $this->arrCommands[] = new $className($this); $this->log->log('Loaded Command: ' . $className, XMPPHP_Log::LEVEL_INFO); } } // Connect to the server try { $this->connect(); $this->processUntil('session_start'); } catch (Exception $e) { die('Failed to connect: ' . $e->getMessage()); } // Connect to the default conference room, if set. if ($this->defaultRoom) { $this->enterRoom($this->defaultRoom); } // Announce our presence for private chats $this->presence(); $this->resetPing(); }
public function testConfigObjectIsCreated() { $config = new JabberBot_Config($this->_mock_config); $this->assertEquals("5222", $config->getValue("port")); }