teamspeak php assign bot

elninocrazy

Member
Aug 16, 2016
3
0
36
hey guys, hope ya fine

im having a little issue with teamspeak php framework
i think the issue is when the script tries to update the client list

Code:
while (1) {
    $Date = date('Y-m-d H:i:s');
    try {
        foreach ($TeamSpeakConnection->clientList() as $client) {
            if ($client["client_type"])
                continue;
            $groups = explode(',', (string) $client->client_servergroups);
            if (!in_array($TeamSpeak['MemberGroup'], $groups)) {
                echo "[" . $Date . "] " . $TeamSpeak['QueyClientName'] . " " . $client['client_nickname'] . " has added to member\n";
                $TeamSpeakConnection->serverGroupClientAdd($TeamSpeak['MemberGroup'], $client['client_database_id']);
            }
        }
        sleep(5);
        echo "[" . $Date . "] " . $TeamSpeak['QueyClientName'] . " is refreshing\n";
    }
    catch (Exception $e) {
        $Date = date('Y-m-d H:i:s');
        die("[" . $Date . "] " . $TeamSpeak['QueyClientName'] . " " . $e->getMessage() . "\n" . $e->getTraceAsString() . "\n");
    }
}

the connection instance is located before the while cicle

what i wanted to do is create a alive bot which has a job to add guests users to another group.
it does add to the group when the bot is launched but if i remove the server group it doesn't work in the next re-check

could you take a look please?
 

XRV-Webix

Member
May 2, 2016
111
55
64
why would you want to add guests to another group?
If you want to do so automatically, you don't need a script. The teamspeak server can do it right from the box.
 

elninocrazy

Member
Aug 16, 2016
3
0
36
why would you want to add guests to another group?
If you want to do so automatically, you don't need a script. The teamspeak server can do it right from the box.
I just wanna do it. I mean, im coding this to a friend so he asked me to do it that way
Any sugestions?
It does add for the first time but when the re-check(when the php starts while again) it does not add the cliente to the group.
 

DifferentUser

Member
Feb 19, 2016
53
23
58
You need to empty the clientList cache by calling the method clientListReset, otherwise it will use old Data received from the first clientList

Code:
while (1) {
    $Date = date('Y-m-d H:i:s');
    $TeamSpeakConnection->clientListReset();
    try {
        foreach ($TeamSpeakConnection->clientList() as $client) {
            if ($client["client_type"])
                continue;
            $groups = explode(',', (string) $client->client_servergroups);
            if (!in_array($TeamSpeak['MemberGroup'], $groups)) {
                echo "[" . $Date . "] " . $TeamSpeak['QueyClientName'] . " " . $client['client_nickname'] . " has added to member\n";
                $TeamSpeakConnection->serverGroupClientAdd($TeamSpeak['MemberGroup'], $client['client_database_id']);
            }
        }
        sleep(5);
        echo "[" . $Date . "] " . $TeamSpeak['QueyClientName'] . " is refreshing\n";
    }
    catch (Exception $e) {
        $Date = date('Y-m-d H:i:s');
        die("[" . $Date . "] " . $TeamSpeak['QueyClientName'] . " " . $e->getMessage() . "\n" . $e->getTraceAsString() . "\n");
    }
}
 

elninocrazy

Member
Aug 16, 2016
3
0
36
Thank you so much. I've never heard about this method and I did search it for a while. I personally want to thank you for helping so now I'll release a little version of this code if there's any interest. I've seen many people using it around my community area.
 
Last edited:
Top