-
Notifications
You must be signed in to change notification settings - Fork 6
/
core6.php
122 lines (111 loc) · 3.87 KB
/
core6.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<?php
require_once("include/lib/ts3admin.class.php");
require_once("include/configs/config.php");
require_once("include/functions/functions.php");
require_once("include/language/".$config['bot']['laguage'].".php");
require_once("include/cache/version.php");
global $serverInfo;
global $online;
global $user;
global $channels;
global $groups;
global $footer;
global $config;
global $useruptime;
$datazero_group_icon = '1970-01-01 00:00:00';
$useruptime = Array();
$footer = "\n\n[hr][right][i]".$version."[/i][/right][hr] [right][url=https://xtrust.pl][img]https://xtrust.pl/botbanner.png[/img][/url]";
$instance_number = str_replace("core", "", $_SERVER['SCRIPT_NAME']);
$instance_number = str_replace(".php", "", $instance_number);
$instance_number = (int) $instance_number;
$instance_enable = 0;
if($config[$instance_number]['enable'])
{
$tsAdmin = new ts3admin($config[$instance_number]['server']['ip'], $config[$instance_number]['server']['queryport']);
if($tsAdmin->getElement('success', $tsAdmin->connect()))
{
echo "
\e[1m \e[32m
▀▀█▀▀ █▀▀▄ █▀▀█ ▀▀█▀▀ ▄▀▀▄
░░█░░ █▀▀▄ █░░█ ░░█░░ █▄▄░
░░▀░░ ▀▀▀░ ▀▀▀▀ ░░▀░░ ▀▄▄▀
\e[0m
";
echo "Bot połączony pomyślnie\n\n";
$tsAdmin->login($config[$instance_number]['query']['login'], $config[$instance_number]['query']['password']);
$tsAdmin->selectServer($config[$instance_number]['server']['port']);
$tsAdmin->setName("Tbot ".$config[$instance_number]['bot']['name']);
$whoami = $tsAdmin->getElement('data', $tsAdmin->whoAmI());
$tsAdmin->clientMove($whoami['client_id'] , $config[$instance_number]['bot']['channel']);
$instance = count($config[$instance_number]['functions']);
for($i=0; $i<$instance; $i++)
{
$function_name = $config[$instance_number]['functions'][$i];
if($config['function'][$function_name]['enable']==true)
{
$instance_enable++;
}
}
echo "/\/\ Instancja nr. ".$instance_number."\n";
echo "/\/\ Aktywnych funkcji: ".$instance_enable."\n";
function intervaltosecond($interval)
{
$interval['hours']+= $interval['days']*24;
$interval['minutes']+= $interval['hours']*60;
$interval['seconds']+= $interval['minutes']*60;
return $interval['seconds'];
}
function ready($data1, $data2, $interval)
{
if((strtotime($data1) - strtotime($data2)) >= $interval)
{
$now = true;
}
else
{
$now = false;
}
return $now;
}
while(true)
{
$loopdate = date('Y-m-d G:i:s');
//$serverInfo = $tsAdmin->getElement('data', $tsAdmin->serverInfo());
//$online = $serverInfo['virtualserver_clientsonline'] - $serverInfo['virtualserver_queryclientsonline'];
//$user = $tsAdmin->clientList("-uid -away -voice -times -groups -info -icon -country -ip -badges");
//$channels = $tsAdmin->channelList("-topic -flags -voice -limits -icon -secondsempty");
//$groups = $tsAdmin->serverGroupList();
if($config['bot']['loop']['enable']==true)
{
if(ready($loopdate, $config['bot']['loop']['datazero'], intervaltosecond($config['bot']['loop']['interval'])) == true)
{
loop();
$config['bot']['loop']['datazero'] = $loopdate;
}
}
$instance = count($config[$instance_number]['functions']);
for($i=0; $i<$instance; $i++)
{
$function_name = $config[$instance_number]['functions'][$i];
if($config['function'][$function_name]['enable']==true)
{
if(ready($loopdate, $config['function'][$function_name]['datazero'], intervaltosecond($config['function'][$function_name]['interval'])) == true)
{
$function_name();
$config['function'][$function_name]['datazero'] = $loopdate;
}
}
}
sleep($config[$instance_number]['bot']['speed']);
}
}
else
{
echo "Problem z połączeniem \n";
}
}
else
{
echo "/\/\ Instancja nr. ".$instance_number." wyłączona\n";
}
?>