Initial Push
parent
1f78f0d83f
commit
fe0fbbeea4
@ -0,0 +1,2 @@
|
||||
ts3
|
||||
config.inc.php
|
@ -1,4 +1,16 @@
|
||||
TS3-Autochannel
|
||||
===============
|
||||
|
||||
Keeps your TS3 group channel amount at a minimum
|
||||
This little PHP script automatically creates Channels if all others are occupied and also deletes them after they aren't needed any more.
|
||||
|
||||
There are some requirements to the channel structure:
|
||||
|
||||
1. A root channel
|
||||
2. sub channels (genres, games, modes...)
|
||||
3. group channels <- these are for users
|
||||
|
||||
The root channels can be nested of course and you can set exceptional channels which are ignored during the excecution.
|
||||
|
||||
![reference tree](https://raw.githubusercontent.com/GameModeOn/TS3-Autochannel/master/images/reference.jpg)
|
||||
|
||||
![live and in action](https://raw.githubusercontent.com/GameModeOn/TS3-Autochannel/master/images/live.jpg)
|
||||
|
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
$framework = 'ts3/TeamSpeak3.php'; //get the TeamSpeak 3 PHP Framework from http://addons.teamspeak.com/directory/tools/integration/TeamSpeak-3-PHP-Framework.html
|
||||
|
||||
$roots = array('[spacer]Game Area', 'WoW');
|
||||
$exceptions = array('Ladder');
|
||||
$default = 'Group 1';
|
||||
|
||||
$host = 'ts3.1337community.org';
|
||||
$queryport = 10011;
|
||||
$voiceport = 9987;
|
||||
$user = 'serveradmin';
|
||||
$passwd = 'supersecret';
|
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
require_once('config.inc.php');
|
||||
require_once($framework);
|
||||
|
||||
$exceptions = array_unique(array_merge($exceptions, $roots));
|
||||
|
||||
$server = TeamSpeak3::factory('serverquery://'.$user.':'.$passwd.'@'.$host.':'.$queryport.'/?server_port='.$voiceport);
|
||||
|
||||
foreach($roots as $root) {
|
||||
$root = $server->channelGetByName($root);
|
||||
$subs = $root->subChannelList();
|
||||
foreach($subs as $sub) {
|
||||
if(catchExceptions($sub['channel_name'], $exceptions)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$groups = $sub->subChannelList();
|
||||
$groupCount = count($groups);
|
||||
|
||||
$delete = false;
|
||||
$i = 0;
|
||||
foreach($groups as $group) {
|
||||
if(catchExceptions($group['channel_name'], $exceptions)) {
|
||||
continue;
|
||||
}
|
||||
$i++;
|
||||
if($delete == true AND $group['total_clients'] == 0) {
|
||||
$group->delete();
|
||||
}
|
||||
if($group['total_clients'] == 0) {
|
||||
$delete = true;
|
||||
}
|
||||
if($i == $groupCount AND $delete == false) {
|
||||
$regex = '#([0-9]{1,3})#e';
|
||||
$replacement = '("$1" + 1)';
|
||||
$newName = preg_replace($regex, $replacement, $group['channel_name']);
|
||||
createChannel($server, $newName, $sub);
|
||||
}
|
||||
}
|
||||
if(empty($groups) OR $i == 0) {
|
||||
createChannel($server, $default, $sub);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function createChannel($server, $name, $parent) {
|
||||
return $server->channelCreate(
|
||||
array(
|
||||
'channel_name' => $name,
|
||||
'channel_flag_permanent' => TRUE,
|
||||
'cpid' => $parent->getId()
|
||||
)
|
||||
);
|
||||
}
|
||||
function catchExceptions($name, $excpetions) {
|
||||
foreach($excpetions as $exception) {
|
||||
if($name == $exception) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 22 KiB |
Binary file not shown.
After Width: | Height: | Size: 17 KiB |
Loading…
Reference in New Issue