* @author Matej Velikonja <*****@*****.**> */ define('ROOT_DIR', __DIR__); // Configure PHP //ini_set( 'display_errors', 'on' ); // Make autoload working require 'Classes/Autoloader.php'; if (file_exists(ROOT_DIR . '/config.local.php')) { $config = (include_once ROOT_DIR . '/config.local.php'); } else { $config = (include_once ROOT_DIR . '/config.php'); } require $config['mangaApi']; spl_autoload_register('Autoloader::load'); // Create the bot. $bot = new Library\IRC\Bot(); // Configure the bot. $bot->setServer($config['server']); $bot->setPort($config['port']); $bot->setChannel($config['channels']); $bot->setName($config['name']); $bot->setNick($config['nick']); $bot->setMaxReconnects($config['max_reconnects']); $bot->setLogFile($config['log_file']); $bot->setNickPassword($config['nickPassword']); // Add commands to the bot. foreach ($config['commands'] as $commandName => $args) { $reflector = new ReflectionClass($commandName); $command = $reflector->newInstanceArgs($args); $bot->addCommand($command); }
try { $config = Nette\Neon\Neon::decode($config); } catch (Nette\Neon\Exception $e) { die('Configuration syntax error: ' . $e->getMessage() . PHP_EOL); } $timezone = ini_get('date.timezone'); if (empty($timezone)) { if (empty($config['timezone'])) { $config['timezone'] = 'UTC'; } date_default_timezone_set($config['timezone']); } // 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 {