forked from Xortdan/TBot
-
Notifications
You must be signed in to change notification settings - Fork 1
/
core5.php
106 lines (97 loc) · 3.2 KB
/
core5.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
<?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/functions/commands.php");
require_once("include/cache/version.php");
//global $serverInfo;
//global $online;
//global $user;
//global $channels;
//global $groups;
global $footer;
global $config;
global $needgroups;
global $loopdate2;
global $do;
$needgroups = "";
$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;
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());
if($config[1]['server']['defaultchannel'] != $config[$instance_number]['bot']['channel'])
{
$tsAdmin->clientMove($whoami['client_id'] , $config[$instance_number]['bot']['channel']);
}
echo "/\/\ Instancja nr. ".$instance_number."\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;
}
echo "\n\nWykorzystanie ramu: \n";
while(true)
{
$loopdate = date('Y-m-d G:i:s');
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_info = "";
$ram = memory_get_usage(false);
$ram = round($ram/1024/1024, 2);
$instance_info = $ram.",";
$ff = fopen("include/cache/instance_info/core5.txt", "w+");
fputs($ff, $instance_info);
fclose($ff);
echo date('H:i d.m.Y')." - ".$ram." MB\n";
}
}
$loopdate2 = date('Y-m-d G:i:s');
commands();
}
}
else
{
echo "Problem z połączeniem \n";
}
}
else
{
echo "/\/\ Instancja nr. ".$instance_number." wyłączona\n";
}
?>