hASVAN
Active Member
- Jun 7, 2015
- 76
- 40
- 93
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");
}
}
}
?>
Last edited: