Functional Server Bot

XARON

get over here!
Restricted
Nov 24, 2016
162
161
118
Hi everyone, I wanted to share with you the bot I develop a long time ago and used on my own server. I've tested with PHP7 on latest TeamSpeak3 Server (3.5.0).
You can protect your server from advertisers and idiots. Must download ts3admin.class for use. Enjoy it :)


How to use?;
"screen -S bot" _> enter;
"php /bot_directory/bot.php" _> enter;
"ctrl + a + d"


Files;

Code:
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
define('MAIN', true);
date_default_timezone_set('Europe/London');
ini_set('default_charset', 'UTF-8');
setlocale(LC_ALL, 'UTF-8');
require_once('./ts3admin.class.php');
$config['server'] = array(
    'host' => '127.0.0.1',
    'server_port' => 9987,
    'query_port' => 10011,
    'username' => 'serveradmin',
    'password' => '',
    'bot_name' => 'FCD-Gaming',
    'default_channel' => 1,
    'data_file' => 'data.json',
    'music_room' => 5
);
$query = new ts3admin($config['server']['host'], $config['server']['query_port']);
if($query->getElement('success', $query->connect())) {
    $query->login($config['server']['username'], $config['server']['password']);
    $query->selectServer($config['server']['server_port']);
    $query->setName($config['server']['bot_name']);
    $core = $query->getElement('data', $query->whoAmI());
    $query->clientMove($core['client_id'], $config['server']['default_channel']);
    while(true) {
        $get_data_file1 = file_get_contents($config['server']['data_file']);
        $data_file1 = json_decode($get_data_file1, true);

        /* Module 1 - Edit Server Slot */
        if($data_file1['module_1']['last_update'] <= time()){
            $serverInfo = $query->getElement('data', $query->serverInfo());
            $online = $serverInfo['virtualserver_clientsonline']-$serverInfo['virtualserver_queryclientsonline'];
            $slot = $serverInfo['virtualserver_maxclients'];
            $data['virtualserver_maxclients'] = $online+10;
            $query->serverEdit($data);
            $data_file1['module_1']['last_update'] = time()+intval($data_file1['module_1']['check_time']);
            $data_file1 = json_encode($data_file1);
            file_put_contents($config['server']['data_file'], $data_file1);
        }

        $get_data_file2 = file_get_contents($config['server']['data_file']);
        $data_file2 = json_decode($get_data_file2, true);
        /* Module 2 - Check Channel Name */
        if($data_file2['module_2']['last_update'] <= time()){
            $channels = $query->getElement('data', $query->channelList());
            $extensions = array('.com', '.net', '.org', '.tk', '.xyz', '.ml', '.gq', '.work', '.info', '.pro', '.top', '.ga', '.pl', '.sh', '.pw', '.ovh', '.cσм', '.cøʍ');
            foreach($channels as $channel) {
                foreach($extensions as $extension) {
                    if($config['server']['music_room'] != $channel['cid']){
                        if(stristr($channel['channel_name'], $extension)) {
                            $query->channelDelete($channel['cid']);
                        }
                        $ips = preg_match('/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/', $channel['channel_name'], $result);
                        if(count($result) >= 1){
                            $query->channelDelete($channel['cid']);
                        }
                        if(preg_match_all('/[0-9]/', $channel['channel_name']) > 5) {
                            $query->channelDelete($channel['cid']);
                        }
                    }
                }
            }
            $data_file2['module_2']['last_update'] = time()+intval($data_file2['module_2']['check_time']);
            $data_file2 = json_encode($data_file2);
            file_put_contents($config['server']['data_file'], $data_file2);
        }

        $get_data_file3 = file_get_contents($config['server']['data_file']);
        $data_file3 = json_decode($get_data_file3, true);
        /* Module 3 - Check Client Name, Away Message*/
        if($data_file3['module_3']['last_update'] <= time()){
            $clients = $query->getElement('data', $query->clientList('-uid -away -voice -times -groups -info -country -icon -ip -badges'));
            $badgesArray = array('overwolf=0:', 'badges=');
            foreach($clients as $client) {
                if($client['client_type'] == 0){
                    foreach($extensions as $extension) {
                        if(stristr($client['client_nickname'], $extension)) {
                            $query->clientKick($client['clid'], 'server', 'Blacklisted nickname');
                        }
                        if(stristr($client['client_away_message'], $extension)) {
                            $query->clientKick($client['clid'], 'server', 'Blacklisted away message');
                        }
                    }
                    $ips_nick = preg_match('/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/', $client['client_nickname'], $result_nick);
                    if(count($result_nick) >= 1){
                        $query->clientKick($client['clid'], 'server', 'Blacklisted nickname');
                    }
                    $ips_away = preg_match('/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/', $client['client_away_message'], $result_away);
                    if(count($result_away) >= 1){
                        $query->clientKick($client['clid'], 'server', 'Blacklisted away message');
                    }
                    $badges = $client['client_badges'];
                    $badgesReplaced = str_replace($badgesArray, '', $badges);
                    $badgesReplaced2 = str_replace(':', ',', $badgesReplaced);
                    $count = count(explode(',', $badgesReplaced2));
                    if($count >= 4) {
                        $query->clientKick($client['clid'], 'server', 'Invalid badges');
                    }
                    if($client['client_is_recording'] == 1) {
                        $query->clientKick($client['clid'], 'server', 'Record not allowed');
                    }
                }
            }
            $data_file3['module_3']['last_update'] = time()+intval($data_file3['module_3']['check_time']);
            $data_file3 = json_encode($data_file3);
            file_put_contents($config['server']['data_file'], $data_file3);
        }
        sleep(1);
    }
}
?>

JSON:
{"module_1":{"last_update":1528672224,"check_time":"1"},"module_2":{"last_update":1542469054,"check_time":"1"},"module_3":{"last_update":1542469054,"check_time":"1"}}

Download scan for TS3 admin class:
https://www.virustotal.com/#/file/0...979e475ad8ae4520e25dfc1b531daec3c3d/relations
 

Attachments

  • ts3admin_class_by_par0noid_v_1.0.2.5.zip
    449.8 KB · Views: 29
Last edited by a moderator:

Asphyxia

Owner
Administrator
Apr 25, 2015
1,845
2
2,199
327
Wow, you have definitely done amazing work with developing this. Have you ever considered making a migration script for TeamSpeak 3 server over to Discord?

I think this could be what a lot of people are doing when they find out just a ~200 slot server will likely cost them around $300 a year with server hosting charges included. If they want to host the server themselves.
 
Last edited:
Top