<?php
/**
* $Id: initialize.php 121 2006-11-24 12:59:43Z khaless $
* $Revision: 121 $
* $Author: khaless $
* $Date: 2006-11-24 23:59:43 +1100 (Fri, 24 Nov 2006) $
*
* Kbot
* Kbot is a PHP IRC Bot that can sit in channels and offer basic services
* and serve PUG's.
* It is built ontop of Mirco Bauer's SmartIRC Class <http://sf.net/projects/phpsmartirc>.
*
* Official Projet Homepage: <http://sf.net/projects/kbot-irc>
*
* Copyright (c) 2005 Mathew Rodley <hide@address.com>
*
* Full GPL License: <http://www.gnu.org/licenses/gpl.txt>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
// VERSION CHECK
if(!version_compare(phpversion(), '5.0.0', '>=')) {
die('Kbot requires PHP >= 5.0'."\n");
}
// bot is pluaged by notices, dont worry about them
error_reporting(E_ALL ^ E_NOTICE);
include_once('./SmartIRC.php');
include_once('./includes/kbotConfig.php');
$irc = &new Net_SmartIRC();
// what OS are we running?
$os = PHP_OS;
if(stristr($os, 'WIN')) {
define('KBOT_WINDOWSOS', true);
$os = 'WIN';
}
else {
define('KBOT_WINDOWSOS', false);
}
define('KBOT_OS', $os);
// check for the debug flag here
if($argv[2] == '--debug')
{
// find level
if($argv[3]) $irc->setDebug($argv[3]);
else $irc->setDebug(SMARTIRC_DEBUG_ALL);
}
else $irc->setDebug(SMARTIRC_DEBUG_NONE);
$irc->setUseSockets(TRUE);
$irc->setAutoRetry(TRUE);
//$irc->setAutoReconnect(TRUE); Seems to cause too many problems, the bot thinks it is not connected when it actually is
$irc->setUseSockets(TRUE);
// please dont change this, i did all this nice work for you and then you want to completly
// ignore me :(, thats mean and makes me sad.
$irc->setCtcpVersion('KBot ($Revision: 121 $) by Khaless');
$irc->setMultipleHandlerMatching(TRUE);
$irc->setChannelSyncing(TRUE);
$irc->setUserSyncing(TRUE);
$irc->kbotConfig = new kbotConfig();
// does our config file exist?
if(!file_exists('./config/'.$argv[1])) die('Config file does not exist');
// set the config file..
$irc->kbotConfig->setConfigFile($argv[1]);
if(!loadConfig('./config/'.$argv[1], $irc->kbotConfig, $irc)) {
die('Confug file "'.$argv[1].'" could not be found'."\n");
}
// load the desired skin
$skin = $irc->kbotConfig->getSkin();
if(!file_exists('./skins/'.$skin.'.php')) {
die('Could not load skin "'.$skin.'"'."\n");
}
else {
// trust no parse for now... checking needs to be done however.
include('./skins/'.$skin.'.php');
}
// module time :)
$irc->setModulepath('./modules/kbot');
// core Kbot Modules
$irc->loadModule('kbot_topic');
$irc->loadModule('kbot_logging');
$irc->loadModule('kbot_help');
$irc->loadModule('kbot_rehash');
$irc->loadModule('kbot_maintinence');
$irc->loadModule('kbot_ipc');
$irc->loadModule('kbot_timeBanMaintainer');
// include those files asked for in the config here...
if(is_array($irc->kbotConfig->loadModuleList))
{
foreach($irc->kbotConfig->loadModuleList as $module)
{
$irc->setModulepath('./modules');
// find the path (described by an underscore.
$path = explode('_',$module);
// build our path... pop off the last arr element because this will be the name.
array_pop($path);
$modPath = '';
if(count($path) > 0)
{
foreach($path as $sep)
{
$modPath .= '/'.$sep;
}
$irc->setModulepath('./modules'.$modPath);
}
$irc->loadModule($module);
}
}
$irc->connect($irc->kbotConfig->getIRCServer(), $irc->kbotConfig->getIRCPort());
$irc->login($irc->kbotConfig->getNickname(), $irc->kbotConfig->getRealName(), 8, $irc->kbotConfig->getUserName(), $irc->kbotConfig->getUserPass());
$irc->listen();
$irc->disconnect();
?>