4 * This file is part of IrBot, irc robot.
5 * Copyright (C) 2007-2008 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/>.
22 define('BASE_DIR',dirname(__FILE__
).'/');
24 require_once('./config.php');
25 require_once('./sources/functions.inc.php');
28 //set_error_handler('myErrorHandler');
30 require_once('sources/Registry.php');
31 Zend_Registry
::registerAutoload();
33 require_once('./sources/IRCMain.php');
34 //require_once('./sources/Plugins.php');
35 require_once('./sources/tick-class.inc.php');
39 IrBot Copyright (C) 2007-2008 Bellière Ludovic
40 This program comes with ABSOLUTELY NO WARRANTY;
41 This is free software, and you are welcome to redistribute it
42 under certain conditions; for details see <http://www.gnu.org/licenses/>.
47 // searching for command line option
48 if (isset($argv[1])) {
50 while (isset($argv[$i])) {
53 if (substr_count($option,'=') === 1) {
54 list($option,$val) = explode('=',$option);
58 if (!$val && ($option != '-h' && $option != '--help')) {
64 case '-h':case '--help':
69 -s Equivalent to --server=name
70 -p Equivalent to --port=number
71 -c Equivalent to --channel=#name
72 -n Equivalent to --nick=name
73 -i Equivalent to --ip=number
74 -d Equivalent to --domain=HOST
75 -a Equivalent to --password=pwd
77 IRC server to connect (default: ".IRC_SERVER
.")
79 Port to use (default: ".IRC_PORT
.")
81 Channel to join (default: ".IRC_CHANNEL
.")
83 Nick of the bot (default: ".IRC_PSEUDO
.")
85 Local ip (default: ".IRC_IP
.")
87 Local domain (default: ".IRC_DOMAIN
.")
89 Server password (default: ".IRC_PASSWORD
.")
93 case '-s':case '--server':
96 case '-p':case '--port':
97 $setPort = (int) $val;
99 case '-c':case '--channel':
102 case '-n':case '--nick':
103 // TODO check for alphanumeric nick name. No utf8 allowed.
106 case '-i':case '--ip':
107 if (ereg("[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}",$val)) {
110 echo "The ip adress entered is wrong.\nUsing default ip instead : ".IRC_IP
."\n";
113 case '-d':case '--domain':
116 case '-a':case '--password':
130 'server' => (isset($setServer)) ?
$setServer : IRC_SERVER
,
131 'port' => (isset($setPort)) ?
$setPort : IRC_PORT
,
132 'channel' => (isset($setChannel)) ?
$setChannel : IRC_CHANNEL
,
133 'nick' => (isset($setNick)) ?
$setNick : IRC_PSEUDO
,
134 'ip' => (isset($setIp)) ?
$setIp : IRC_IP
,
135 'domain' => (isset($setDomain)) ?
$setDomain : IRC_DOMAIN
,
136 'password' => (isset($setDomain)) ?
$setDomain : IRC_PASSWORD
,
139 $ircMain = new IRCMain($options);
143 // On charge les plugins que l'on souhaite
144 // $ircMain->plugins()->load_plugin('sample');
145 // $ircMain->plugins()->load_plugin('jet');
149 $ircMain -> launch();
150 } catch (Exception
$e) {
151 switch($e->getCode()) {
153 echo $e->getMessage()."\n";
154 echo "Process terminating...\n";
155 die("EOL from client\n");
157 case 1: // SIGHUP restart
158 echo $e->getMessage()."\n";
159 echo "Process restarting ...\n\n";
162 die("EOL from user...\n");