From d9b9f715abf63f5dff3bab8764b95cec3cb38258 Mon Sep 17 00:00:00 2001 From: xrogaan Date: Sun, 30 Dec 2007 12:43:56 +0000 Subject: [PATCH] 24 "adding some tools for releases. more extended recognition of options passed by the command line (help need to be write). adding a config file." --- config.php | 2 +- main.php | 99 ++++++++++++++++++++++++++++++++++++------------------ release-cleanup.sh | 1 - 3 files changed, 67 insertions(+), 35 deletions(-) diff --git a/config.php b/config.php index 567fba2..50ef5bc 100644 --- a/config.php +++ b/config.php @@ -26,7 +26,7 @@ date_default_timezone_set('Europe/Brussels'); define('IRC_SERVER','irc.oh-my-songs.com'); define('IRC_PORT',6667); -define('IRC_CHANNEL','#oms-network'); +define('IRC_CHANNEL','#irbot'); define('IRC_PSEUDO','irbot'); define('IRC_IP',''); define('IRC_DOMAIN',''); diff --git a/main.php b/main.php index 061e8fd..ffce771 100755 --- a/main.php +++ b/main.php @@ -16,58 +16,91 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see . + * + * $Id: main.php 24 2007-12-30 12:43:56Z xrogaan $ */ - -// This page need to be rewrited - -error_reporting(E_ALL); - -date_default_timezone_set('Europe/Brussels'); - +require_once('./config.php'); require_once('./sources/functions.inc.php'); debug(true); //set_error_handler('myErrorHandler'); -// Arguments passés à la ligne de commande -if ( isset($argv[1], $argv[2], $argv[3], $argv[4]) ) { - $server = $argv[1] ; - $port = (int) $argv[2] ; - $chan = '#' . $argv[3] ; - $name = $argv[4] ; -} else { - $server = 'irc.tty2.org'; - $port = 6667; - $chan = '#sharesource'; - $name = 'IrBot'; -} - require_once('./sources/main-class.inc.php'); require_once('./sources/irc-class.inc.php'); require_once('./sources/plugin-class.inc.php'); require_once('./sources/tick-class.inc.php'); require_once('./sources/TextFormat-class.inc.php'); -// Nouvelle instance de la classe IRCMain -bot::$server = $server; -bot::$port = $port; -bot::$channel = $chan; -bot::$myBotName = $name; -bot::$ip = ''; -bot::$domain = ''; -bot::$connection_password = false; - echo <<. + IrBot Copyright (C) 2007 Bellière Ludovic + This program comes with ABSOLUTELY NO WARRANTY; + This is free software, and you are welcome to redistribute it + under certain conditions; for details see . EOF; +// searching for command line option +if (isset($argv[1])) { + $i=1; + while (isset($argv[$i])) { + $val = false; + $option = $argv[$i]; + if (substr_count($option,'=') === 1) { + list($option,$val) = explode('=',$option); + } + + if (!$val) { + $i++; + $val = $argv[$i]; + } + + switch ($option) { + case '-h':case '--help': + echo "help content need to be write\n"; + break 2; + case '-s':case '--server': + bot::$server = $val; + break; + case '-p':case '--port': + bot::$port = (int) $val; + break; + case '-c':case '--channel': + bot::$channel = $val; + break; + case '-n':case '--pseudo': + bot::$myBotName = $val; + break; + case '-i':case '--ip': + if (ereg("[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}",$val)) { + bot::$ip = $val; + } else { + echo "The ip adress entered is wrong.\nUsing default ip instead : ".IRC_IP."\n"; + } + break; + case '-d':case '--domain': + bot::$domain = $val; + break; + case '-a':case '--password': + bot::$connection_password = $val; + break; + default: + break; + } + $i++; + } +} + +if (!isset(bot::$server)) bot::$server = IRC_SERVER; +if (!isset(bot::$port)) bot::$port = (int) IRC_PORT; +if (!isset(bot::$channel)) bot::$channel = IRC_CHANNEL; +if (!isset(bot::$myBotName)) bot::$myBotName = IRC_PSEUDO; +if (!isset(bot::$ip)) bot::$ip = IRC_IP; +if (!isset(bot::$domain)) bot::$domain = IRC_DOMAIN; +if (!isset(bot::$connection_password)) bot::$connection_password = IRC_PASSWORD; + $MainProc = bot::GetInstance(); while (1) { diff --git a/release-cleanup.sh b/release-cleanup.sh index 00c65df..1268bc9 100755 --- a/release-cleanup.sh +++ b/release-cleanup.sh @@ -6,7 +6,6 @@ echo ------------------------------------ find . -depth -type d -name .svn -exec rm -fr {} \; find . -type d -exec chmod 775 {} \; -find . -type f -name "*.*~" -exec rm -fr {} \; find . -type f -name "*.php" -exec chmod -x {} \; find . -type f -name "main.php" -exec chmod +x {} \; -- 2.11.4.GIT