[Script] Create Your own commands with php

decon20

Member
Mar 27, 2016
32
5
43
Man.. that's not an error, you're just printing the whole code he gave you.
Please, execute it as php-f script.php and post the result.
This is a bot, not a web app, you can't view it on a web browser or execute on a webserver..

Let me guess, you have NO IDEA how a bot works, don't you?
I do the same on first bot, and works... I don't know them...
 

Agusanz

Active Member
Jul 18, 2015
239
148
88
I do the same on first bot, and works... I don't know them...
1- download php teamspeak framwork.
2- make a file .php with the script this guy gave to you
3- edit the variables to fit ur needs
4- execute like php -f script.php

the Bot will connect to your teamspeak server and do his magic. if ithe execution returns an error, then you post that here.. otherwise, it works..
you don't need a browser.. you don't need a web server and the result will be on your teamspeak or your console of execution..
it works, you're executing it wrong and waiting for results in the wrong place..
 

decon20

Member
Mar 27, 2016
32
5
43
1- download php teamspeak framwork.
2- make a file .php with the script this guy gave to you
3- edit the variables to fit ur needs
4- execute like php -f script.php

the Bot will connect to your teamspeak server and do his magic. if ithe execution returns an error, then you post that here.. otherwise, it works..
you don't need a browser.. you don't need a web server and the result will be on your teamspeak or your console of execution..
it works, you're executing it wrong and waiting for results in the wrong place..
Thanks for your help @Agusanz. It works, shame on me :| @hASVAN i'm sorry for my mistake, great work mate :)
 

Norvik

Retired Staff
Contributor
Jul 18, 2015
635
588
157
Hi hASVAN I want a script to send message on channel or server or even a poke plz
PHP:
elseif($var == "!poke"){
$client = str_replace('!poke', '', $info["msg"]);
foreach($srv->clientList() as $ts3_Client)
{
if($client == $ts3_Client)
{
$srv->clientGetByName("".$client."")->poke("Your Message");
}else{
$srv->clientGetByName($info["invokername"]->toString())->message("User Not found");
}
}

Try to add this between the } and the else on line 80. It should work but I'm not quite sure since I didn't test it yet and it's really late right now so there could be a small mistake in the code :p You can use it like "!poke ridicc" and I will receive a poke with the message "Your Message".
 

hitelare2

Member
Jan 16, 2016
11
0
36
PHP:
elseif($var == "!poke"){
$client = str_replace('!poke', '', $info["msg"]);
foreach($srv->clientList() as $ts3_Client)
{
if($client == $ts3_Client)
{
$srv->clientGetByName("".$client."")->poke("Your Message");
}else{
$srv->clientGetByName($info["invokername"]->toString())->message("User Not found");
}
}

Try to add this between the } and the else on line 80. It should work but I'm not quite sure since I didn't test it yet and it's really late right now so there could be a small mistake in the code :p You can use it like "!poke ridicc" and I will receive a poke with the message "Your Message".

the script shows error
syntax error, unexpected 'else' (T_ELSE) in /root/bot/admin.php on line 90
 

Norvik

Retired Staff
Contributor
Jul 18, 2015
635
588
157
the script shows error
syntax error, unexpected 'else' (T_ELSE) in /root/bot/admin.php on line 90
Probably caused by a bracket which is missing or set to the wrong place. Could you post line 90 and every if statement which effects line 90?
 

hitelare2

Member
Jan 16, 2016
11
0
36
Probably caused by a bracket which is missing or set to the wrong place. Could you post line 90 and every if statement which effects line 90?
PHP:
<?php
require_once("libraries/TeamSpeak3/TeamSpeak3.php");

//--------INFO------------//
$login_name = 'serveradmin';
$login_password ='pass';
$ip = '127.0.0.1';
$query_port = '10011';
$virtualserver_port = '9987';
$bot_name = '#OC - [ Admin ]';
$ts3helpchannel = "95";
//--------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");
                  }
            }                   
          }elseif($var == "!poke"){
$client = str_replace('!poke', '', $info["msg"]);
foreach($srv->clientList() as $ts3_Client)
{
if($client == $ts3_Client)
{
$srv->clientGetByName("".$client."")->poke("Your Message");
}else{
$srv->clientGetByName($info["invokername"]->toString())->message("User Not found");
}
}else{
             $srv->clientGetByName($info["invokername"]->toString())->message("Command Not found");
          }
    }
           
   


}
?>
 

Norvik

Retired Staff
Contributor
Jul 18, 2015
635
588
157
PHP:
<?php
require_once("libraries/TeamSpeak3/TeamSpeak3.php");

//--------INFO------------//
$login_name = 'serveradmin';
$login_password ='pass';
$ip = '127.0.0.1';
$query_port = '10011';
$virtualserver_port = '9987';
$bot_name = '#OC - [ Admin ]';
$ts3helpchannel = "95";
//--------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");
 }
 } 
 }elseif($var == "!poke"){
$client = str_replace('!poke', '', $info["msg"]);
foreach($srv->clientList() as $ts3_Client)
{
if($client == $ts3_Client)
{
$srv->clientGetByName("".$client."")->poke("Your Message");
}else{
$srv->clientGetByName($info["invokername"]->toString())->message("User Not found");
}
}
}else{
 $srv->clientGetByName($info["invokername"]->toString())->message("Command Not found");
 }
 }
}
?>

Try this.
 

hitelare2

Member
Jan 16, 2016
11
0
36
PHP:
<?php
require_once("libraries/TeamSpeak3/TeamSpeak3.php");

//--------INFO------------//
$login_name = 'serveradmin';
$login_password ='pass';
$ip = '127.0.0.1';
$query_port = '10011';
$virtualserver_port = '9987';
$bot_name = '#OC - [ Admin ]';
$ts3helpchannel = "95";
//--------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");
}
}
}elseif($var == "!poke"){
$client = str_replace('!poke', '', $info["msg"]);
foreach($srv->clientList() as $ts3_Client)
{
if($client == $ts3_Client)
{
$srv->clientGetByName("".$client."")->poke("Your Message");
}else{
$srv->clientGetByName($info["invokername"]->toString())->message("User Not found");
}
}
}else{
$srv->clientGetByName($info["invokername"]->toString())->message("Command Not found");
}
}
}
?>

Try this.

it did join but when I type !poke [ message ] its shows error: User Not found
 

Norvik

Retired Staff
Contributor
Jul 18, 2015
635
588
157
You have to use it like !poke name. If I would like to poke you I would write !poke hitelare2 and then you would receive the message from the script.
 
Top