Ejemplo n.º 1
0
}
// Initialise the LogManager.
$log = new Library\IRC\Log($config['log']);
// Create the bot.
$bot = new Library\IRC\Bot($config, $log);
// Register the shutdown function.
register_shutdown_function(array($bot, 'onShutdown'));
// Add commands and listeners to the bot.
foreach (array_merge((array) $config['commands'], (array) $config['listeners']) as $className => $args) {
    $reflector = new ReflectionClass($className);
    if (!isset($args)) {
        $args = array();
    }
    $instance = $reflector->newInstanceArgs($args);
    if (array_key_exists($className, $config['commands'])) {
        $bot->commandManager->addCommand($instance);
    } else {
        if (array_key_exists($className, $config['listeners'])) {
            $bot->listenerManager->addListener($instance);
        } else {
            $bot->log('Command/Listener loader found invalid class ( ' . $className . ' ). Skipping.', 'STARTUP');
        }
    }
}
if (function_exists('setproctitle')) {
    $title = basename(__FILE__, '.php') . ' - ' . $config['nick'];
    setproctitle($title);
}
// And fire it up.
$bot->run();
// Nothing more possible, the bot runs until script ends.