[Script] Create Your own commands with php

zukkumm

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

EPEffects

Member
Joined
Apr 23, 2016
Messages
19
Reaction score
1
Points
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 ;)
 

tagKnife

Well-Known Member
Joined
Oct 2, 2015
Messages
343
Reaction score
270
Points
146

EPEffects

Member
Joined
Apr 23, 2016
Messages
19
Reaction score
1
Points
35
I don't want to use nimba, i want an example as i wrote before...
 

Agusanz

Active Member
Joined
Jul 18, 2015
Messages
239
Reaction score
148
Points
88
I don't want to use nimba, i want an example as i wrote before...
he's not telling you to use nimda.. https://github.com/JABirchall/NimdaTS3 read the source code if you're interesed.
reading someone's else source code its a great way to learn intead of asking everything. He put a lot of time into that bot, find your answer there..
 

EPEffects

Member
Joined
Apr 23, 2016
Messages
19
Reaction score
1
Points
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
Joined
Apr 23, 2016
Messages
19
Reaction score
1
Points
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
Joined
Oct 2, 2015
Messages
343
Reaction score
270
Points
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
Joined
Apr 23, 2016
Messages
19
Reaction score
1
Points
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
Joined
Oct 2, 2015
Messages
343
Reaction score
270
Points
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
Joined
Apr 23, 2016
Messages
19
Reaction score
1
Points
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
Joined
Apr 23, 2016
Messages
19
Reaction score
1
Points
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)
 

growndex

CipherSpeak Developer
Joined
Jun 2, 2017
Messages
20
Reaction score
4
Points
56
@hASVAN Could you make an interactive conversation between bot and user?
 

hASVAN

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

XARON

get over here!
Restricted
Joined
Nov 24, 2016
Messages
162
Reaction score
161
Points
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