master
lub 9 years ago
parent 5943169367
commit 75e09f81be

@ -631,8 +631,8 @@ to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found. the "copyright" line and a pointer to where the full notice is found.
{one line to give the program's name and a brief idea of what it does.} TS3-Autochannel
Copyright (C) {year} {name of author} Copyright (C) 2015 Simon Körner
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -652,7 +652,7 @@ Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode: notice like this when it starts in an interactive mode:
{project} Copyright (C) {year} {fullname} TS3-Autochannel Copyright (C) 2015 Simon Körner
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details. under certain conditions; type `show c' for details.
@ -671,4 +671,4 @@ into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>. <http://www.gnu.org/philosophy/why-not-lgpl.html>.

@ -11,6 +11,4 @@ There are some requirements to the channel structure:
The root channels can be nested of course and you can set exceptional channels which are ignored during the excecution. The root channels can be nested of course and you can set exceptional channels which are ignored during the excecution.
![reference tree](https://cdn.mediacru.sh/FKlUC2WMHvAo.jpe) You can have a look at it live on the TS3 server gamemodeon.de
![live and in action](https://cdn.mediacru.sh/whvu4UCSep_d.jpg)

@ -1,8 +1,8 @@
<?php <?php
$framework = 'ts3/TeamSpeak3.php'; //get the TeamSpeak 3 PHP Framework from http://addons.teamspeak.com/directory/tools/integration/TeamSpeak-3-PHP-Framework.html $framework = 'ts3phpframework/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'); $roots = array('Game Area', 'WoW');
$exceptions = array('Ladder'); $exceptions = array('Ladder Room');
$default = 'Group 1'; $default = 'Group 1';
$host = 'ts3.1337community.org'; $host = 'ts3.1337community.org';

@ -2,5 +2,45 @@
require_once('config.inc.php'); require_once('config.inc.php');
require_once('functions.php'); require_once('functions.php');
require_once($framework); require_once($framework);
$server = TeamSpeak3::factory('serverquery://'.$user.':'.$passwd.'@'.$host.':'.$queryport.'/?server_port='.$voiceport); $server = TeamSpeak3::factory('serverquery://'.$user.':'.$passwd.'@'.$host.':'.$queryport.'/?server_port='.$voiceport);
require_once('main.php');
$exceptions = array_unique(array_merge($exceptions, $roots));
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)) {
$groupCount--;
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, $options);
}
}
if(empty($groups) OR $i == 0) {
createChannel($server, $default, $sub, $options, array('channel_flag_permanent' => TRUE));
}
}
}

@ -1,40 +0,0 @@
<?php
$exceptions = array_unique(array_merge($exceptions, $roots));
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)) {
$groupCount--;
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, $options);
}
}
if(empty($groups) OR $i == 0) {
createChannel($server, $default, $sub, $options, array('channel_flag_permanent' => TRUE));
}
}
}
Loading…
Cancel
Save