-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathumarmen.php
107 lines (100 loc) · 3.28 KB
/
umarmen.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
100
101
102
103
104
105
106
107
<?php
include('common.php');
include('config.php');
require('library/MultiBot.php');
require('library/DataStore.php');
require('library/Logger.php');
require('library/Hooks.php');
$multibot = new MultiBot($inital_server, $master_nick, $inital_channel);
$datastore = new DataStore;
$bot_number = 1;
$inital_load = false;
$inital_join = false;
$doing_inital_load = false;
srand((float) microtime() * 10000000);
foreach($extra_connections as $extra_connection) {
$multibot->new_bot($extra_connection['server'], $extra_connection['nickname'], $extra_connection['channel']);
}
// Main bot loop
while(1) {
$read = array();
$networks = array();
foreach( $multibot->bots as $key=>$value ) {
if ( $value['connected'] ) {
$read[$key] = $value['socket'];
}
}
if ( select( $read, $network_name ) ) {
$socket = $multibot->bots[$network_name]['socket'];
$bot_nick = $multibot->bots[$network_name]['nickname'];
if ( $socket && !feof( $socket ) ) {
$data = $multibot->read($network_name);
if ( mb_strlen( $data ) > 0 ) {
$comchar = '^';
include('parser.php');
if(md5($inital_server . $master_nick) == $network_name && !$inital_join) {
if(isset($extra_channels) && is_array($extra_channels)) {
foreach($extra_channels as $channel) {
$multibot->join(md5($inital_server . $master_nick), $channel);
}
}
$inital_join = true;
}
$modules = array();
foreach(glob('modules/*.php') as $module_file) {
$module_name = substr($module_file, 8, -4);
$modules[] = $module_name;
if(!$inital_load) {
$module_text = file_get_contents($module_file);
$module_text = substr($module_text, 5, strlen($module_text) - 7);
try {
eval($module_text);
} catch(Exception $e) {
Logger::log(Logger::_WARNING, 'Initial load of the ' . $module_name . ' module failed! Caught Exception: ' . $e->getMessage());
}
$doing_inital_load = true;
}
}
if($doing_inital_load) {
$inital_load = true;
}
$module_to_load = Hooks::get($msg_cmd);
if(!empty($module_to_load) && in_array($module_to_load, $modules) && $command = 'PRIVMSG') {
echo "Loading the " . $module_to_load . " module\n";
$module_text = file_get_contents('./modules/' . $module_to_load . '.php');
$module_text = substr($module_text, 5, strlen($module_text) - 7);
try {
eval($module_text);
} catch(Exception $e) {
reply('Caught Exception in the ' . $module_to_load . ' module! ' . $e->getMessage());
}
}
if(isset($special_modules) && is_array($special_modules)) {
foreach($special_modules as $special_module) {
$module_text = file_get_contents('./modules/' . $special_module . '.php');
$module_text = substr($module_text, 5, strlen($module_text) - 7);
try {
eval($module_text);
} catch(Exception $e) {
reply('Caught Exception in the ' . $special_module . ' module! ' . $e->getMessage());
}
}
}
if($command == 'PING') {
$multibot->write($network_name, 'PONG :' . $message);
}
if($command == 'ERROR') {
echo $data;
}
if($command == 'INVITE' && $join_on_invite) {
echo $data;
echo $message . "\n";
$multibot->join($network_name, $message);
}
}
} else {
$multibot->disconnect($network_name);
}
}
}
?>