Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once("libraries/TeamSpeak3/TeamSpeak3.php");
- function connection() {
- global $ts3_VirtualServer;
- global $config;
- $ts3_VirtualServer = TeamSpeak3::factory("serverquery://{$config['serveradmin']}:{$config['password']}@{$config['address']}:{$config['queryport']}/?server_port={$config['port']}&nickname={$config['nickname']}");
- }
- //Connection
- $config = array(
- "address" => "localhost",
- "queryport" => "10011",
- "serveradmin" => "serveradmin",
- "password" => "qwerty",
- "port" => "9987",
- "nickname" => "CodexBOT"
- );
- //Channels order
- $channels = array(
- "A" => 5, //CID
- "B" => 6,
- "-" => 50
- //... insert other
- );
- try {
- while (1) {
- connection();
- foreach ($ts3_VirtualServer->channelList() as $channelList) {
- if (preg_match('/\[PERMANENT\]/', $channelList['channel_name'])) {
- $ChannelName = preg_replace('/\[PERMANENT\]/', "", $channelList['channel_name']);
- foreach ($channels as $channel => $cid) {
- $subChannels = $ts3_VirtualServer->channelGetById($cid)->subChannelList();
- if(!empty($subChannels))
- $lastId = end($subChannels)->getId();
- else
- $lastId = null;
- if (preg_match('/^\s/', $ChannelName))
- $ChannelName = preg_replace('/^\s/', "", $ChannelName);
- foreach ($subChannels as $subChannel) {
- if ($ChannelName == $subChannel['channel_name']) {
- if (strlen($ChannelName) > 11) {
- $channelList->modify(array(
- "channel_description" => '[COLOR=#ffaa00][B]it s not possible to make this channel permanent because there is already one channel with this name. Rename this channel in different way (Adding always the tag [COLOR=#000000][PERMANENT][/COLOR]) for getting your channel.[/B][/COLOR]'
- ));
- }
- if (strlen($ChannelName) < 12) {
- $channelList->modify(array(
- "channel_name" => '[READ DESCRIPTION] ' . $ChannelName,
- "channel_description" => '[COLOR=#ffaa00][B]it s not possible to make this channel permanent because there is already one channel with this name. Rename this channel in different way (Adding always the tag [COLOR=#000000][PERMANENT][/COLOR]) for getting your channel.[/B][/COLOR]'
- ));
- }
- }
- }
- if ($ChannelName != $subChannel['channel_name'] || empty($subChannel)) {
- if ($ChannelName[0] === $channel || $ChannelName[0] === strtolower($channel)) {
- $ts3_VirtualServer->channelMove($channelList['cid'], $cid , $lastId);
- $channelList->modify(array("channel_name" => $ChannelName,
- "channel_flag_permanent" => 1
- ));
- }
- if (preg_match('/[^A-Za-z]/', $channel)) {
- if (!ctype_alpha($ChannelName[0])) {
- $ts3_VirtualServer->channelMove($channelList['cid'], $cid , $lastId);
- $channelList->modify(array("channel_name" => $ChannelName,
- "channel_flag_permanent" => 1
- ));
- }
- }
- }
- }
- }
- }
- $ts3_VirtualServer->logout();
- sleep(3);
- }
- } catch(TeamSpeak3_Exception $e) {
- echo "Error " . $e->getCode() . ": " . $e->getMessage();
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement