collapse collapse
* User Info
 
 
Welcome, Guest. Please login or register.
* Search

* Board Stats
  • stats Total Members: 989
  • stats Total Posts: 18363
  • stats Total Topics: 2500
  • stats Total Categories: 7
  • stats Total Boards: 35
  • stats Most Online: 1144

Author Topic: Teamspeak module  (Read 1882 times)

0 Members and 1 Guest are viewing this topic.

Offline eagled2

  • BeBot Rookie
  • *
  • Posts: 11
  • Karma: +0/-0
Teamspeak module
« on: December 26, 2007, 08:19:00 pm »
I installed the teamspeak module for an older version bebot under custom modules from [url http://bebot.link/index.php/topic,149.0.html]http://bebot.link/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.

Offline eagled2

  • BeBot Rookie
  • *
  • Posts: 11
  • Karma: +0/-0
Re: Teamspeak module
« Reply #1 on: December 26, 2007, 08: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.

Offline eagled2

  • BeBot Rookie
  • *
  • Posts: 11
  • Karma: +0/-0
Re: Teamspeak module
« Reply #2 on: December 28, 2007, 09: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: [Select]
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: [Select]
<?
  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, 10:02:40 am by eagled2 »

Offline Didju

  • BeBot Rookie
  • *
  • Posts: 4
  • Karma: +0/-0
Re: Teamspeak module
« Reply #3 on: January 20, 2008, 01:35:32 pm »
Bump for pls...

 

* Recent Posts
[AoC] special char for items module by bitnykk
[February 09, 2024, 09:41:18 pm]


0.8.x updates for AoC by bitnykk
[January 30, 2024, 11:16:08 pm]


0.8.x updates for AO by bitnykk
[January 30, 2024, 11:15:37 pm]


BeBot still alive & kicking ! by bitnykk
[December 17, 2023, 12:58:44 am]


Bebot and Rasberry by bitnykk
[November 29, 2023, 11:04:14 pm]

* Who's Online
  • Dot Guests: 508
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.
* Forum Staff
bitnykk admin bitnykk
Administrator
Khalem admin Khalem
Administrator
WeZoN gmod WeZoN
Global Moderator
SimplePortal 2.3.7 © 2008-2024, SimplePortal