L* R*
HOME FORUM DOWNLOADS
Content
  Links
     Browse SVN
     SVN Commit log
     Documentation (Wiki)
  Developers
     Taskmanager
User
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 04, 2008, 04:30:04 PM

Login with username, password and session length
Search



Advanced search
Support GoPHP5.org
BeBot - An Anarchy Online/Age Of Conan chat automaton > Forum > Development > Module Requests > Topic: Teamspeak module
Pages: [1]   Go Down
« previous next »
Print
Author Topic: Teamspeak module  (Read 363 times)
0 Members and 1 Guest are viewing this topic.
eagled2
Freshman
*
Offline Offline

Posts: 11


Teamspeak module
« on: December 26, 2007, 02:19:00 PM »

I installed the teamspeak module for an older version bebot under custom modules from [url http://bebot.shadow-realm.org/index.php/topic,149.0.html]http://bebot.shadow-realm.org/index.php/topic,149.0.html[/url] and it appears to be working. I would like to see a similar maybe more like the teamspeak module in budabot.
Logged
eagled2
Freshman
*
Offline Offline

Posts: 11


Re: Teamspeak module
« Reply #1 on: December 26, 2007, 02:56:21 PM »

Oh I forgot to list the features I like from the budabot teamspeak module. First being the  help page I don't know how to get working. The ability to change server settings in game. This may be possible in this already but the only way I could figure out was changing in the file manually. Also listing all channels on server and how many people in each.
Logged
eagled2
Freshman
*
Offline Offline

Posts: 11


Re: Teamspeak module
« Reply #2 on: December 28, 2007, 03:55:33 AM »

Ok I have looked at the teamspeak module from budabot and have gotten all displayed server settings missing from the bebot teamspeak module I downloaded working except the displaying channels with members in the channel. I keep getting 2 errors whenever I insert the code for the channel list.
The errors show up in my console when I try to run the ts command in game and keep going continuously using up all bandwidth on my pc.
Code:
Warning: feof(): supplied argument is not a valid stream resource in Z:\downloads\ign\bebot\custom\modules\teamspeak.php on line 153

Warning: fgets(): supplied argument is not a valid stream resource in Z:\downloads\ign\bebot\custom\modules\teamspeak.php on line 154

And here is my teamspeak script. I marked the area of the non working code I added with a comment. If you remove or comment out that area of the code the script works just fine but no channel list. Lines 142 through 230 in my text editor is the added section.
Code:
<?
  include_once("_Colors.php");
 
  $ts = new TEAMSPEAK($bot);

  $commands["tell"]["ts"] = &$ts;
  $commands["gc"]["ts"] = &$ts;
  $commands["pgmsg"]["ts"] = &$ts;

  class TEAMSPEAK
  {
    var $bot;
    var $ip = "voice.eagled2.net"; //Server IP
    var $queryport = "51234";          //Query Port (51234 by default)
    var $serverport = "8762";          //Server Port (8767 by default)
    var $servername = "Trimmcom Co Voice Server";    // Server name
    var $displayhost = "voice.eagled2.net"; //Display ip address

    function TEAMSPEAK (&$bot)
    {
      $this -> bot = &$bot;

$this ->
help['description'] =
'Shows teamspeak server status.';
$this ->
help['command']['ts']="Shows teamspeak server status. Dispalys no server found if server is not up. All server settings are saved directly in the file by the bot owner.";

    }

    function tell($name, $msg)
    {
           if (preg_match("/^" . $this -> bot -> commpre . "ts/i", $msg, $info)) {
            $this -> bot -> send_tell($name, $this -> show_tstatus());
         }
    }

    function pgmsg($name, $msg)
    {
           if (preg_match("/^" . $this -> bot -> commpre . "ts/i", $msg, $info)) {
            $this -> bot -> send_pgroup($this -> show_tstatus());
         }
    }

    function gc($name, $msg)
    {
           if (preg_match("/^" . $this -> bot -> commpre . "ts/i", $msg, $info)) {
            $this -> bot -> send_gc($this -> show_tstatus());
         }
    }

    function show_tstatus()
    {
        $msg = "TeamSpeak Server Status";
        $blob = "";
        $infolines="";

       
        $timeToEnd = (time() + 5);
        while (!($connection1 = fsockopen($this -> ip, $this -> queryport, $errno, $errstr, 30)) AND (time() < $timeToEnd)) {
            if (time() >= $timeToEnd) {
                return false;
            }
        }
        if ($connection1) {
           fputs($connection1,"sel ".$this -> serverport."\n");
           fputs($connection1,"si\n");
           fputs($connection1,"quit\n");

           while(!feof($connection1)){
              $infolines.=fgets($connection1,1024);
           }
           $infolines = str_replace("[TS]","",$infolines);
           $infolines = str_replace("OK","",$infolines);
           $infolines = trim($infolines);

           // Servername, here but not used, uncomment if you want to use it
           $name=substr($infolines,$this -> indexOf($infolines,"server_name="),strlen($infolines));
           $name=substr($name,0,$this -> indexOf($name,"server_platform=")-strlen("server_platform="));

 //Connected Users
$indexof = strpos($infolines, "server_currentusers=") + strlen("server_currentusers=");
        $user = substr($infolines, $indexof, strlen($infolines));
$indexof = strpos($user, "server_currentchannels=") + strlen("server_currentchannels=");
        $user = substr($user, 0, $indexof - strlen("server_currentchannels="));
$user = trim($user);


 //Server Max Users
$indexof = strpos($infolines, "server_maxusers=") + strlen("server_maxusers=");
        $maxusers = substr($infolines, $indexof, strlen($infolines));
       
$indexof = strpos($maxusers, "server_allow_codec_celp51=") + strlen("server_allow_codec_celp51=");
        $maxusers = substr($maxusers, 0, $indexof - strlen("server_allow_codec_celp51="));
    $maxusers = trim($maxusers);


//Uptime of the Server
$indexof = strpos($infolines, "server_uptime=") + strlen("server_uptime=");
    $uptime = substr($infolines, $indexof, strlen($infolines));
$indexof = strpos($uptime, "server") + strlen("server_currrentusers=");
$uptime = substr($uptime, 0, $indexof - strlen("server_currrentusers="));
    $uptime = trim($uptime);
    $hours = floor($uptime/3600);
        $minutes = floor(($uptime%3600)/60);
        $seconds = floor(($uptime%3600)%60);
        if($hours>0) $uptime = $hours."h ".$minutes."m ".$seconds."s";
        else if($minutes>0) $uptime = $minutes."m ".$seconds."s";
        else $uptime = $seconds."s";       
        //Serverplatform
$indexof = strpos($infolines, "server_platform=") + strlen("server_platform=");
$platform = substr($infolines, $indexof, strlen($infolines));
$indexof = strpos($platform, "server_welcomemessage=") + strlen("server_welcomemessage=");
$platform = substr($platform, 0, $indexof - strlen("server_welcomemessage="));
    $platform = trim($platform);

 //Number of channels
        $indexof = strpos($infolines, "server_currentchannels=") + strlen("server_currentchannels=");
    $channels = substr($infolines, $indexof, strlen($infolines));
        $indexof = strpos($channels, "server_bwinlastsec=") + strlen("server_bwinlastsec=");
$channels = substr($channels, 0, $indexof - strlen("server_bwinlastsec="));
    $channels = trim($channels);

        } else {
            return "Canīt connect to the TS server. Pls try again later.";


        }

        $msg = Headertext("::::: Teamspeak Server Info :::::\n\n");
        $msg .="Get the client:  \"http://www.goteamspeak.com\" \n\n";
        $msg .="Note: To connect use ".Highlight($this -> displayhost.":".$this -> serverport)." as the connect address\n";
        $msg .="Server Name: ".Highlight($this -> servername)."\n";
        $msg .="Server Address: ".Highlight($this -> displayhost)."\n";
        $msg .="Server Port: ".Highlight($this -> serverport)."\n\n";
$msg .="Server Platform: ".Highlight($platform)."\n";
$msg .="Server Uptime: ".Highlight($uptime)."\n";
$msg .="Number of Players Currently Connected: ".Highlight($user)."\n";
        $msg .="Server Maximum: ".Highlight($maxusers)."\n";
$msg .= "Server Channels: ".Highlight($channels)."\n";
        $msg .="Players (Time Connected):\n";
//Begin Non Working code
//Get Players
$player_array = array();
$innerArray = array();
$out = "";
$j = 0;
$k = 0;

$connection = fsockopen($ip, $queryport, $errno, $errstr, 30);
fputs($connection, "pl ".$serverport."\n");
fputs($connection, "quit\n");
while(!feof($connection))
$out .= fgets($connection, 1024);

$out   = str_replace("[TS]", "", $out);
$out   = str_replace("loginname", "loginname\t", $out);
$data = explode("\t", $out);
$num = count($data);

for($i = 0; $i < count($data); $i++) {
$innerArray[$j] = $data[$i];
if($j >= 15) {
$player_array[$k] = $innerArray;
$j = 0;
$k = $k + 1;
} else
$j++;
}
fclose($connection);

//Get Channels
$cArray = array();
$innerArray = array();
$out = "";
$j = 0;
$k = 0;

$connection = fsockopen($ip, $queryport, $errno, $errstr, 30);
fputs($connection, "cl ".$serverport."\n");
fputs($connection, "quit\n");
while(!feof($connection)) {
$out .= fgets($connection, 1024);
}
$out   = str_replace("[TS]", "", $out);
$out   = str_replace("\n", "\t", $out);
$data = explode("\t", $out);
$num = count($data);

for($i=0;$i<count($data);$i++) {
if($i>=10) {
$innerArray[$j] = $data[$i];
if($j>=8) {
$cArray[$k]=$innerArray;
$j = 0;
$k = $k+1;
} else
$j++;
}
}
        fclose($connection);

//Give Channels and their users out
foreach($cArray as $channel) {
  $channel[5] = str_replace("\"", "", $channel[5]);
  $msg .= "<u>Channel: {$channel[5]}</u>\n";
  $c_id = $channel[0];
$num_players = 0;
  foreach($player_array as $player) {
    if($player[1] == $c_id) {
$num_players++;
  $name = $player[14];
                  $name = str_replace("\"","",$name);
                $name = ucfirst($name);
                $time = $player[8];

        $hours = floor($time/3600);
        $minutes = floor(($time%3600)/60);
        $seconds = floor(($time%3600)%60);

        if($hours>0) $time = $hours."h ".$minutes."m ".$seconds."s";
        else if($minutes>0) $time = $minutes."m ".$seconds."s";
        else $time = $seconds."s";
                $msg .= "<tab>- <highlight>$name<end>($time)\n";
}
}
if($num_players == 0)
$msg .= "<tab>- <highlight>None<end>\n";
}
//end non working code
#t

        $player_array = $this -> getTSChannelUsers($this -> ip, $this -> serverport, $this -> queryport);
        $count=count($player_array);

        if ($count > 1) {
            $arraycount=1;
            while ($count > 1) {
                $player=$player_array[$arraycount][14];
                $player=str_replace("\"","",$player);
                $player=ucfirst($player);
                $time=$player_array[$arraycount][8];
                $time=$this -> time_convert($time);

                $msg .= Highlight($player)."($time)\n";
                $count--;
                $arraycount++;
            }



        } else {
           $msg .= Highlight("No Players Connected");



        }
        return $this -> bot -> make_blob("Teamspeak server status", GroupText($msg));
    }
   
    function indexOf($str,$strChar)
    {
       if(strlen(strchr($str,$strChar))>0) {
          $position_num = strpos($str,$strChar) + strlen($strChar);
          return $position_num;
       } else {
          return -1;
       }
    }
   
    function getTSChannelUsers($ip,$port,$tPort)
    {
       $uArray    = array();
       $innerArray = array();
       $out      = "";
       $j         = 0;
       $k         = 0;

       $fp = fsockopen($ip, $tPort, $errno, $errstr, 30);
       if($fp) {
          fputs($fp, "pl ".$port."\n");
          fputs($fp, "quit\n");
          while(!feof($fp)) {
             $out .= fgets($fp, 1024);
          }
          $out   = str_replace("[TS]", "", $out);
          $out   = str_replace("loginname", "loginname\t", $out);
          $data    = explode("\t", $out);
          $num    = count($data);

          for($i=0;$i<count($data);$i++) {
             $innerArray[$j] = $data[$i];
             if($j>=15)
             {
                $uArray[$k]=$innerArray;
                $j = 0;
                $k = $k+1;
             } else {
                $j++;
             }
          }
          fclose($fp);
       }
        return $uArray;
    }

    function time_convert($time)
    {
       $hours = floor($time/3600);
       $minutes = floor(($time%3600)/60);
       $seconds = floor(($time%3600)%60);

       if($hours>0) $time = $hours."h ".$minutes."m ".$seconds."s";
       else if($minutes>0) $time = $minutes."m ".$seconds."s";
       else $time = $seconds."s";

       return $time;
    }
  }
?>
Can anyone offer any advice?
« Last Edit: December 28, 2007, 04:02:40 AM by eagled2 » Logged
Didju
Freshman
*
Offline Offline

Posts: 4


Re: Teamspeak module
« Reply #3 on: January 20, 2008, 07:35:32 AM »

Bump for pls...
Logged
Pages: [1]   Go Up
Print
BeBot - An Anarchy Online/Age Of Conan chat automaton > Forum > Development > Module Requests > Topic: Teamspeak module
« previous next »
 
Jump to:  

Recent
online not working after ...
by Alreadythere
[Today at 03:53:28 PM]

Bot not working after tod...
by Alreadythere
[Today at 01:04:41 PM]

Tokens Calulator
by Temar
[December 03, 2008, 01:09:03 PM]

Bebot does not work with ...
by IKShadow
[December 03, 2008, 08:54:04 AM]

!items database
by Temar
[December 03, 2008, 07:27:59 AM]

massive_pvp_time_table 1
by Sudoka
[December 03, 2008, 06:49:07 AM]

Log playtime from buddys ...
by IKShadow
[December 02, 2008, 06:48:12 AM]

[request] Raid timers
by Elesar1
[December 01, 2008, 04:41:09 PM]

Shared DB online list
by Temar
[December 01, 2008, 01:55:47 AM]

relay colors
by Temar
[December 01, 2008, 01:54:56 AM]
Stats
Members
Total Members: 1246
Latest: Vingus
Stats
Total Posts: 11192
Total Topics: 1508
Online Today: 21
Online Ever: 168
(July 01, 2007, 09:30:02 PM)
Users Online
Users: 7
Guests: 17
Total: 24
vikor
Sudoka
upstart
Glarawyn
Snarfblatt
Vingus

Powered by SMF 1.1.7 | SMF © 2006-2008, Simple Machines LLC
TinyPortal v0.9.8 © Bloc | NewDef design by Bloc
Page created in 0.423 seconds with 28 queries. (Pretty URLs adds 0.026s, 4q)
Loading...