[Script] Create Your own commands with php

zukkumm

Member
Jul 13, 2016
6
0
33
I can't use this script.Can u help me? could you provide some information about how i want to use?
 

EPEffects

Member
Apr 23, 2016
19
1
35
How can i let the bot execute something, if an user joins a specific channel (for example channel id 50)? Is there any way to do it? (there should be a way... for example jts3servermod is able to poke certain user, if someone connects to a channel)

thx for your help ;)
 

EPEffects

Member
Apr 23, 2016
19
1
35
thats why i linked nimda, its a bot framework to allow you to do commands simply like that.
heres an example/tutorial
Yeah, but i just copied the ChannelGroupNotify plugin and changed it, so it fits into my code...
 

EPEffects

Member
Apr 23, 2016
19
1
35
I don't know what's wrong, but the whole bot is not working anymore...
After i run the file, this error comes up...
Code:
PHP Parse error:  syntax error, unexpected '"onWaitTimeout"' (T_CONSTANT_ENCAPSED_STRING) in /home/teamspeakbot/ChannelBot/commands.php on line 23
I reinstalled the whole library, but it still doesn't work... Now i ran the standart script, which hASVAN posted in here and it stopped working too, although it worked before...
Code:
PHP Parse error:  syntax error, unexpected ''serveradmin'' (T_CONSTANT_ENCAPSED_STRING) in /home/teamspeakbot/ChannelBot/standart.php on line 5

Can someone help me please, i tried to fix this for hours -.-'
 

tagKnife

Well-Known Member
Oct 2, 2015
343
270
146
I don't know what's wrong, but the whole bot is not working anymore...
After i run the file, this error comes up...
Code:
PHP Parse error:  syntax error, unexpected '"onWaitTimeout"' (T_CONSTANT_ENCAPSED_STRING) in /home/teamspeakbot/ChannelBot/commands.php on line 23
I reinstalled the whole library, but it still doesn't work... Now i ran the standart script, which hASVAN posted in here and it stopped working too, although it worked before...
Code:
PHP Parse error:  syntax error, unexpected ''serveradmin'' (T_CONSTANT_ENCAPSED_STRING) in /home/teamspeakbot/ChannelBot/standart.php on line 5

Can someone help me please, i tried to fix this for hours -.-'
looks like you don't know how to code.
 

EPEffects

Member
Apr 23, 2016
19
1
35
looks like you don't know how to code.
I may not be the best coder, but i know how to work with php... This is the second time use the teamspeak3 php Framework, so im new in this element...
The script i wrote stopped working suddenly and after i couldn't find any errors i reinstalled another script (this one: https://r4p3.net/threads/script-create-your-own-commands-with-php.1982/), but i still get a similar error, although it worked for me 2 days ago...

I even reinstalled the whole server and changed from ubuntu to debian... I even switched to another server but i always get the same error... I don't know how this can be, cause the SAME script worked for me 2 days ago, as i mentioned
 

tagKnife

Well-Known Member
Oct 2, 2015
343
270
146
I may not be the best coder, but i know how to work with php... This is the second time use the teamspeak3 php Framework, so im new in this element...
The script i wrote stopped working suddenly and after i couldn't find any errors i reinstalled another script (this one: https://r4p3.net/threads/script-create-your-own-commands-with-php.1982/), but i still get a similar error, although it worked for me 2 days ago...

I even reinstalled the whole server and changed from ubuntu to debian... I even switched to another server but i always get the same error... I don't know how this can be, cause the SAME script worked for me 2 days ago, as i mentioned
Yeah because reinstalling a server will magically fix your bad code. thats a new meta.
 

EPEffects

Member
Apr 23, 2016
19
1
35
Yeah because reinstalling a server will magically fix your bad code. thats a new meta.
Don't you get it! It's not the fault of the code! I downloaded this script:
PHP:
<?php
require_once("TeamSpeak3/TeamSpeak3.php");

//--------INFO------------//
$login_name = 'serveradmin';
$login_password ='';
$ip = '127.0.0.1';
$query_port = '10011';
$virtualserver_port = '9987';
$bot_name = 'TS3hASVANBot';
$ts3helpchannel = "94";
//--------INFO------------//

$ts3_VirtualServer = TeamSpeak3::factory("serverquery://".$login_name.":".$login_password."@".$ip.":".$query_port."/?server_port=".$virtualserver_port."&nickname=TEST&blocking=0");

$ts3botid = $ts3_VirtualServer->whoamiGet('client_id');
$ts3_VirtualServer->clientMove($ts3botid, $ts3helpchannel);

$arr_ClientList = $ts3_VirtualServer->clientList(array("client_platform" => "ServerQuery"));

foreach($arr_ClientList as $ts3_Client)
{
    if($ts3_Client['client_nickname'] == $bot_name)
    {
        $ts3_VirtualServer->request("quit");
        exit;
    }
}
$ts3_VirtualServer->selfUpdate(array("client_nickname" => $bot_name));

TeamSpeak3_Helper_Signal::getInstance()->subscribe("serverqueryWaitTimeout", "onWaitTimeout");
TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyTextmessage", "onTextMessage");

$ts3_VirtualServer->notifyRegister("server");
$ts3_VirtualServer->notifyRegister("channel");
$ts3_VirtualServer->notifyRegister("textserver");
$ts3_VirtualServer->notifyRegister("textchannel");
$ts3_VirtualServer->notifyRegister("textprivate");


while(1)
{
    $ts3_VirtualServer->getAdapter()->wait();
}

function onWaitTimeout($time, TeamSpeak3_Adapter_Abstract $adapter)
{
    if($adapter->getQueryLastTimestamp() < time()-300)
    {
        $adapter->request('clientupdate');
    }
}

function onTextMessage(TeamSpeak3_Adapter_ServerQuery_Event $event, TeamSpeak3_Node_Host $host) {

    $info = $event->getData();
    $srv = $host->serverGetSelected();
    if($info["targetmode"] == 2)
    {
          $mystring = $info["msg"];
          $pos1 = strpos($mystring, " ");
          if($pos1 > 0){
          $var = substr($mystring, 0, $pos1);
          }else{
          $var = $mystring;
          }     
          if($var == "!say"){         
            $srv->message("".str_replace('!say ', '', "[b][color=green]".$info["msg"]."[/color][/b]")."");               
          }elseif($var == "!kick"){
            $client = str_replace('!kick ', '', $info["msg"]);
            foreach($srv->clientList() as $ts3_Client)
            {
                  if($client == $ts3_Client)
                  {
                     $srv->clientGetByName("".$client."")->kick(TeamSpeak3::KICK_SERVER, "");
                  }else{
                    $srv->clientGetByName($info["invokername"]->toString())->message("User Not found");
                  }
            }                   
          }else{
             $srv->clientGetByName($info["invokername"]->toString())->message("Command Not found");
          }
    }
           
   


}
?>
and ran it and the same error appeared, although the script worked 2 days ago!
 

EPEffects

Member
Apr 23, 2016
19
1
35
Don't you get it! It's not the fault of the code! I downloaded this script:
PHP:
<?php
require_once("TeamSpeak3/TeamSpeak3.php");

//--------INFO------------//
$login_name = 'serveradmin';
$login_password ='';
$ip = '127.0.0.1';
$query_port = '10011';
$virtualserver_port = '9987';
$bot_name = 'TS3hASVANBot';
$ts3helpchannel = "94";
//--------INFO------------//

$ts3_VirtualServer = TeamSpeak3::factory("serverquery://".$login_name.":".$login_password."@".$ip.":".$query_port."/?server_port=".$virtualserver_port."&nickname=TEST&blocking=0");

$ts3botid = $ts3_VirtualServer->whoamiGet('client_id');
$ts3_VirtualServer->clientMove($ts3botid, $ts3helpchannel);

$arr_ClientList = $ts3_VirtualServer->clientList(array("client_platform" => "ServerQuery"));

foreach($arr_ClientList as $ts3_Client)
{
    if($ts3_Client['client_nickname'] == $bot_name)
    {
        $ts3_VirtualServer->request("quit");
        exit;
    }
}
$ts3_VirtualServer->selfUpdate(array("client_nickname" => $bot_name));

TeamSpeak3_Helper_Signal::getInstance()->subscribe("serverqueryWaitTimeout", "onWaitTimeout");
TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyTextmessage", "onTextMessage");

$ts3_VirtualServer->notifyRegister("server");
$ts3_VirtualServer->notifyRegister("channel");
$ts3_VirtualServer->notifyRegister("textserver");
$ts3_VirtualServer->notifyRegister("textchannel");
$ts3_VirtualServer->notifyRegister("textprivate");


while(1)
{
    $ts3_VirtualServer->getAdapter()->wait();
}

function onWaitTimeout($time, TeamSpeak3_Adapter_Abstract $adapter)
{
    if($adapter->getQueryLastTimestamp() < time()-300)
    {
        $adapter->request('clientupdate');
    }
}

function onTextMessage(TeamSpeak3_Adapter_ServerQuery_Event $event, TeamSpeak3_Node_Host $host) {

    $info = $event->getData();
    $srv = $host->serverGetSelected();
    if($info["targetmode"] == 2)
    {
          $mystring = $info["msg"];
          $pos1 = strpos($mystring, " ");
          if($pos1 > 0){
          $var = substr($mystring, 0, $pos1);
          }else{
          $var = $mystring;
          }    
          if($var == "!say"){        
            $srv->message("".str_replace('!say ', '', "[b][color=green]".$info["msg"]."[/color][/b]")."");              
          }elseif($var == "!kick"){
            $client = str_replace('!kick ', '', $info["msg"]);
            foreach($srv->clientList() as $ts3_Client)
            {
                  if($client == $ts3_Client)
                  {
                     $srv->clientGetByName("".$client."")->kick(TeamSpeak3::KICK_SERVER, "");
                  }else{
                    $srv->clientGetByName($info["invokername"]->toString())->message("User Not found");
                  }
            }                  
          }else{
             $srv->clientGetByName($info["invokername"]->toString())->message("Command Not found");
          }
    }
          
  


}
?>
and ran it and the same error appeared, although the script worked 2 days ago!
SHORT UPDATE:
I found the error! I don't know why, but after i put the code into a code cleaner, the cleaner found out that there were invisible signs hidden in the code... I removed them and now everything is working! (Without using a weird Nimba Bot with unnecessary Features :p)
 

hASVAN

Active Member
Jun 7, 2015
76
40
93
can't right now but if you want i can tell you how to do it
 

XARON

get over here!
Restricted
Nov 24, 2016
162
161
118
PHP:
<?php
require_once("TeamSpeak3/TeamSpeak3.php");

//--------INFO------------//
$login_name = 'serveradmin';
$login_password ='';
$ip = '127.0.0.1';
$query_port = '10011';
$virtualserver_port = '9987';
$bot_name = 'TS3hASVANBot';
$ts3helpchannel = "94";
//--------INFO------------//

$ts3_VirtualServer = TeamSpeak3::factory("serverquery://".$login_name.":".$login_password."@".$ip.":".$query_port."/?server_port=".$virtualserver_port."&nickname=TEST&blocking=0");

$ts3botid = $ts3_VirtualServer->whoamiGet('client_id');
$ts3_VirtualServer->clientMove($ts3botid, $ts3helpchannel);

$arr_ClientList = $ts3_VirtualServer->clientList(array("client_platform" => "ServerQuery"));

foreach($arr_ClientList as $ts3_Client)
{
    if($ts3_Client['client_nickname'] == $bot_name)
    {
        $ts3_VirtualServer->request("quit");
        exit;
    }
}
$ts3_VirtualServer->selfUpdate(array("client_nickname" => $bot_name));

TeamSpeak3_Helper_Signal::getInstance()->subscribe("serverqueryWaitTimeout", "onWaitTimeout");
TeamSpeak3_Helper_Signal::getInstance()->subscribe("notifyTextmessage", "onTextMessage");

$ts3_VirtualServer->notifyRegister("server");
$ts3_VirtualServer->notifyRegister("channel");
$ts3_VirtualServer->notifyRegister("textserver");
$ts3_VirtualServer->notifyRegister("textchannel");
$ts3_VirtualServer->notifyRegister("textprivate");


while(1)
{
    $ts3_VirtualServer->getAdapter()->wait();
}

function onWaitTimeout($time, TeamSpeak3_Adapter_Abstract $adapter)
{
    if($adapter->getQueryLastTimestamp() < time()-300)
    {
        $adapter->request('clientupdate');
    }
}

function onTextMessage(TeamSpeak3_Adapter_ServerQuery_Event $event, TeamSpeak3_Node_Host $host) {

    $info = $event->getData();
    $srv = $host->serverGetSelected();
    if($info["targetmode"] == 2)
    {
          $mystring = $info["msg"];
          $pos1 = strpos($mystring, " ");
          if($pos1 > 0){
          $var = substr($mystring, 0, $pos1);
          }else{
          $var = $mystring;
          }     
          if($var == "!say"){         
            $srv->message("".str_replace('!say ', '', "[b][color=green]".$info["msg"]."[/color][/b]")."");               
          }elseif($var == "!kick"){
            $client = str_replace('!kick ', '', $info["msg"]);
            foreach($srv->clientList() as $ts3_Client)
            {
                  if($client == $ts3_Client)
                  {
                     $srv->clientGetByName("".$client."")->kick(TeamSpeak3::KICK_SERVER, "");
                  }else{
                    $srv->clientGetByName($info["invokername"]->toString())->message("User Not found");
                  }
            }                   
          }else{
             $srv->clientGetByName($info["invokername"]->toString())->message("Command Not found");
          }
    }
           
   


}
?>
Example:
3jTJtDU.png
Use case switch.
 
Top