-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.php
99 lines (89 loc) · 3.54 KB
/
run.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?php
/**
* Nuwani PHP IRC Bot Framework
* Copyright (c) 2006-2010 The Nuwani Project
*
* Nuwani is a framework for IRC Bots built using PHP. Nuwani speeds up bot
* development by handling basic tasks as connection- and bot management, timers
* and module managing. Features for your bot can easily be added by creating
* your own modules, which will receive callbacks from the framework.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @copyright Copyright (c) 2006-2010 The Nuwani Project
* @package Nuwani
* @author Peter Beverloo <peter@lvp-media.com>
* @author Dik Grapendaal <dik.grapendaal@gmail.com>
* @see http://nuwani.googlecode.com
*/
date_default_timezone_set('Europe/Amsterdam');
define('NUWANI_STARTTIME', microtime(true));
define('NUWANI_NAME', 'Nuwani');
define('NUWANI_VERSION', 'v3.0-dev');
define('NUWANI_REVISION', trim(substr('$Revision: 151 $', 10, -1)));
define('NUWANI_VERSION_STR', NUWANI_NAME . ' ' . NUWANI_VERSION . ' r' . NUWANI_REVISION);
error_reporting(E_ALL);
set_time_limit(0);
chdir(__DIR__);
if (version_compare(PHP_VERSION, '5.3.0') < 0) {
die('You need PHP 5.3 or higher to run ' . NUWANI_VERSION_STR . '.' . PHP_EOL);
}
require 'Sources/Singleton.php';
require 'Sources/ModuleBase.php';
require 'Sources/Configuration.php';
require 'Sources/BotManager.php';
require 'Sources/Exception.php';
require 'Sources/BotGroup.php';
require 'Sources/Database.php';
require 'Sources/NetworkManager.php';
require 'Sources/ModuleManager.php';
require 'Sources/SecurityManager.php';
require 'Sources/Memory.php';
require 'Sources/Socket.php';
require 'Sources/Timer.php';
require 'Sources/Bot.php';
require 'Common/Model.php';
require 'Common/stringH.php';
require 'config.php';
if ($_SERVER ['argc'] >= 1 && (isset ($_SERVER ['argv'] [1]) && $_SERVER ['argv'] [1] == 'restart')) {
/** Make sure the still running bot has time to disconnect. * */
sleep(1);
}
Nuwani \ Configuration :: getInstance()->register($aConfiguration);
Nuwani \ NetworkManager :: getInstance()->Initialize($aConfiguration ['Networks']);
Nuwani \ ModuleManager :: getInstance()->Initialize();
Nuwani \ BotManager :: getInstance()->Initialize($aConfiguration ['Bots']);
Nuwani \ Database :: getInstance();
Nuwani \ Memory :: Initialize();
Nuwani \ ErrorExceptionHandler :: getInstance()->Initialize($aConfiguration ['ErrorHandling']);
$g_bRun = true;
while ($g_bRun) {
try {
Nuwani \ BotManager :: getInstance()->process();
Nuwani \ ModuleManager :: getInstance()->onTick();
Nuwani \ Timer :: process();
Nuwani \ Memory :: process();
if (count(Nuwani \ BotManager :: getInstance()) == 0) {
$g_bRun = false;
}
usleep($aConfiguration ['SleepTimer']);
} catch (Exception $pException) {
Nuwani \ ErrorExceptionHandler :: getInstance()->processException($pException);
if (ob_get_level() >= 1) {
ob_end_flush();
}
}
}
/** Destructors will be called by PHP automatically. * */
?>