forked from gluxon/phpwolf
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphpbot.php
More file actions
executable file
·75 lines (56 loc) · 1.68 KB
/
phpbot.php
File metadata and controls
executable file
·75 lines (56 loc) · 1.68 KB
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
<?php
// Stop PHP from killing itself
set_time_limit(0);
// Log error messages
ini_set('display_errors', 'On');
ini_set('log_errors', 'true');
ini_set('error_log', 'error_log');
// Where is everything?
define('INCLUDES_PATH', 'includes');
define('SETTINGS_PATH', 'settings');
define('MODULES_PATH', 'modules');
define('LOCALES_PATH', 'locales');
require("irc.inc"); // IRC Class
require(INCLUDES_PATH . "/functions.inc"); // Custom functions
require(INCLUDES_PATH . "/TokenBucket.inc"); // Token Bucket Algorithm
require(INCLUDES_PATH . "/random.inc"); // Random Functions
require(INCLUDES_PATH . "/locale.inc"); // Language class
require(MODULES_PATH . "/wolf.inc"); // Werewolf Game
require(SETTINGS_PATH . "/bot.inc"); // Settings
// Start IRC class
$irc = new irc();
$irc->connect($server["address"], $server["port"]);
// Send the password and user ident info
$irc->sendPassword($user["password"]);
$irc->sendIdent($user["nick"], $user["mode"], $user["unused"], $user["realname"]);
// Join the default channel
$irc->joinChannel($channel["name"]);
// Start wolf module
$wolf = new wolf(array(
'bot' => $user,
'irc' => $irc,
'channel' => $channel,
'admins' => $admins,
'lang' => $lang,
'settings_path' => SETTINGS_PATH,
'locale_path' => LOCALES_PATH,
));
// Continously read new lines
while (true) {
// Read new line
$data=$irc->getData(512);
if (!empty($data)) {
echo $data;
// Trim off line carriage and newline
$data = str_replace("\r\n", '', $data);
// Split the data into words
$data = $irc->explodeData($data);
// Play some Ping Pong!
$irc->PingPong($data);
// Run wolfbot module
$wolf->run($irc->getSocket(), $data);
} else {
$wolf->runMaintenance();
}
}
?>