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 27 2008-01-19 14:04:53Z xrogaan $
23 require_once('./config.php');
24 require_once('./sources/functions.inc.php');
27 //set_error_handler('myErrorHandler');
29 require_once('./sources/main-class.inc.php');
30 require_once('./sources/irc-class.inc.php');
31 require_once('./sources/plugin-class.inc.php');
32 require_once('./sources/tick-class.inc.php');
33 require_once('./sources/TextFormat-class.inc.php');
37 IrBot Copyright (C) 2007 Bellière Ludovic
38 This program comes with ABSOLUTELY NO WARRANTY;
39 This is free software, and you are welcome to redistribute it
40 under certain conditions; for details see <http://www.gnu.org/licenses/>.
45 // searching for command line option
46 if (isset($argv[1])) {
48 while (isset($argv[$i])) {
51 if (substr_count($option,'=') === 1) {
52 list($option,$val) = explode('=',$option);
55 if (!$val && ($option != '-h' && $option != '--help')) {
61 case '-h':case '--help':
66 -s Equivalent to --server=name
67 -p Equivalent to --port=number
68 -c Equivalent to --channel=#name
69 -n Equivalent to --nick=name
70 -i Equivalent to --ip=number
71 -d Equivalent to --domain=HOST
72 -a Equivalent to --password=pwd
74 IRC server to connect (default: ".IRC_SERVER
.")
76 Port to use (default: ".IRC_PORT
.")
78 Channel to join (default: ".IRC_CHANNEL
.")
80 Nick of the bot (default: ".IRC_PSEUDO
.")
82 Local ip (default: ".IRC_IP
.")
84 Local domain (default: ".IRC_DOMAIN
.")
86 Server password (default: ".IRC_PASSWORD
.")
90 case '-s':case '--server':
93 case '-p':case '--port':
94 bot
::$port = (int) $val;
96 case '-c':case '--channel':
99 case '-n':case '--nick':
100 bot
::$myBotName = $val;
102 case '-i':case '--ip':
103 if (ereg("[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}",$val)) {
106 echo "The ip adress entered is wrong.\nUsing default ip instead : ".IRC_IP
."\n";
109 case '-d':case '--domain':
112 case '-a':case '--password':
113 bot
::$connection_password = $val;
125 if (!isset(bot
::$server)) bot
::$server = IRC_SERVER
;
126 if (!isset(bot
::$port)) bot
::$port = (int) IRC_PORT
;
127 if (!isset(bot
::$channel)) bot
::$channel = IRC_CHANNEL
;
128 if (!isset(bot
::$myBotName)) bot
::$myBotName = IRC_PSEUDO
;
129 if (!isset(bot
::$ip)) bot
::$ip = IRC_IP
;
130 if (!isset(bot
::$domain)) bot
::$domain = IRC_DOMAIN
;
131 if (!isset(bot
::$connection_password)) bot
::$connection_password = IRC_PASSWORD
;
133 $MainProc = bot
::GetInstance();
136 // On charge les plugins que l'on souhaite
137 $MainProc->plugins
->load_plugin('sample');
138 $MainProc->plugins
->load_plugin('jet');
142 $MainProc -> launch();
143 } catch (Exception
$e) {
144 switch($e->getCode()) {
146 echo $e->getMessage()."\n";
147 echo "Process terminating...\n";
148 die("EOL from client\n");
150 case 1: // SIGHUP restart
151 echo $e->getMessage()."\n";
152 echo "Process restarting ...\n\n";
155 die("EOL from user...\n");