4 * This file is part of IrBot, irc robot.
5 * Copyright (C) 2007 Bellière Ludovic
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 * $Id: main.php 28 2008-01-19 17:17:01Z xrogaan $
23 define('BASE_DIR',dirname(__FILE__
).'/');
25 require_once('./config.php');
26 require_once('./sources/functions.inc.php');
29 //set_error_handler('myErrorHandler');
31 require_once('source/Registry.php');
32 Zend_Registry
::registerAutoload();
34 require_once('./sources/main-class.inc.php');
35 require_once('./sources/irc-class.inc.php');
36 require_once('./sources/Plugins.php');
37 require_once('./sources/tick-class.inc.php');
38 require_once('./sources/TextFormat-class.inc.php');
42 IrBot Copyright (C) 2007 Bellière Ludovic
43 This program comes with ABSOLUTELY NO WARRANTY;
44 This is free software, and you are welcome to redistribute it
45 under certain conditions; for details see <http://www.gnu.org/licenses/>.
50 // searching for command line option
51 if (isset($argv[1])) {
53 while (isset($argv[$i])) {
56 if (substr_count($option,'=') === 1) {
57 list($option,$val) = explode('=',$option);
60 if (!$val && ($option != '-h' && $option != '--help')) {
66 case '-h':case '--help':
71 -s Equivalent to --server=name
72 -p Equivalent to --port=number
73 -c Equivalent to --channel=#name
74 -n Equivalent to --nick=name
75 -i Equivalent to --ip=number
76 -d Equivalent to --domain=HOST
77 -a Equivalent to --password=pwd
79 IRC server to connect (default: ".IRC_SERVER
.")
81 Port to use (default: ".IRC_PORT
.")
83 Channel to join (default: ".IRC_CHANNEL
.")
85 Nick of the bot (default: ".IRC_PSEUDO
.")
87 Local ip (default: ".IRC_IP
.")
89 Local domain (default: ".IRC_DOMAIN
.")
91 Server password (default: ".IRC_PASSWORD
.")
95 case '-s':case '--server':
98 case '-p':case '--port':
99 bot
::$port = (int) $val;
101 case '-c':case '--channel':
102 bot
::$channel = $val;
104 case '-n':case '--nick':
105 bot
::$myBotName = $val;
107 case '-i':case '--ip':
108 if (ereg("[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}",$val)) {
111 echo "The ip adress entered is wrong.\nUsing default ip instead : ".IRC_IP
."\n";
114 case '-d':case '--domain':
117 case '-a':case '--password':
118 bot
::$connection_password = $val;
130 if (!isset(bot
::$server)) bot
::$server = IRC_SERVER
;
131 if (!isset(bot
::$port)) bot
::$port = (int) IRC_PORT
;
132 if (!isset(bot
::$channel)) bot
::$channel = IRC_CHANNEL
;
133 if (!isset(bot
::$myBotName)) bot
::$myBotName = IRC_PSEUDO
;
134 if (!isset(bot
::$ip)) bot
::$ip = IRC_IP
;
135 if (!isset(bot
::$domain)) bot
::$domain = IRC_DOMAIN
;
136 if (!isset(bot
::$connection_password)) bot
::$connection_password = IRC_PASSWORD
;
138 $MainProc = bot
::GetInstance();
141 // On charge les plugins que l'on souhaite
142 $MainProc->plugins
->load_plugin('sample');
143 $MainProc->plugins
->load_plugin('jet');
147 $MainProc -> launch();
148 } catch (Exception
$e) {
149 switch($e->getCode()) {
151 echo $e->getMessage()."\n";
152 echo "Process terminating...\n";
153 die("EOL from client\n");
155 case 1: // SIGHUP restart
156 echo $e->getMessage()."\n";
157 echo "Process restarting ...\n\n";
160 die("EOL from user...\n");