14
[irbot.git] / main.php
blob3dfa26d59a1c1cde3dfcb12e01784d6d4bd59685
1 #!/usr/bin/php
2 <?php
4 // This page need to be rewrited
6 error_reporting(0);
8 date_default_timezone_set('Europe/Brussels');
10 require_once('./sources/functions.inc.php');
12 debug(true);
13 set_error_handler('myErrorHandler');
15 // Arguments passés à la ligne de commande
16 if ( isset($argv[1], $argv[2], $argv[3], $argv[4]) ) {
17 $server = $argv[1] ;
18 $port = (int) $argv[2] ;
19 $chan = '#' . $argv[3] ;
20 $name = $argv[4] ;
21 } else {
22 $server = 'irc.oh-my-songs.com';
23 $port = 6667;
24 $chan = '#oms-network';
25 $name = 'RPGBot';
28 require_once('./sources/main-class.inc.php');
29 require_once('./sources/irc-class.inc.php');
30 require_once('./sources/plugin-class.inc.php');
31 require_once('./sources/TextFormat-class.inc.php');
33 // Nouvelle instance de la classe IRCMain
34 bot::$server = $server;
35 bot::$port = $port;
36 bot::$channel = $chan;
37 bot::$myBotName = $name;
38 bot::$ip = '127.0.0.1';
39 bot::$domain = 'localhost';
40 bot::$connection_password = false;
42 while (1) {
43 $MainProc = bot::GetInstance();
45 // On charge les plugins que l'on souhaite
46 $MainProc->plugins->load_plugin('sample');
47 $MainProc->plugins->load_plugin('jet');
49 // On lance le bot
50 try {
51 $MainProc -> launch();
52 } catch (Exception $e) {
53 switch($e->getCode()) {
54 case 0:
55 echo $e->getMessage()."\n";
56 echo "Process terminating...\n";
57 die("EOL from client\n");
58 break 2;
59 case 1: // SIGHUP restart
60 echo $e->getMessage()."\n";
61 echo "Process restarting ...\n\n";
62 continue 2;
63 case 3: // SIGQUIT
64 die("EOL from user...\n");
65 break 2;
66 case 'TIMEOUT':
67 continue 2;