Add New functionality in Time And Date Bot

mradar

Member
Mar 18, 2016
5
0
36
user has been warned for this post : formatting
PHP:
<?php

require_once("TeamSpeak3/TeamSpeak3.php");
date_default_timezone_set('Asia/tehran');
TeamSpeak3::init();

$user = "serveradmin";
$pass = "951753";
$serverIP = "127.0.0.1";
$botTimeChannel = 1;
$botUsersChannel = 2;

$nickname = "TimeBot";

try
{
   $ts3 = TeamSpeak3::factory("serverquery://{$user}:{$pass}@{$serverIP}:10011/?server_port=9987&blocking=0&nickname={$nickname}");

  $BotChannelTime = $ts3->channelGetById($botTimeChannel);
  $BotChannelUsuarios = $ts3->channelGetById($botUsersChannel);

  $unixTime = time();
   $realTime = date('[Y-m-d] [H:i:s]',$unixTime);
  echo $realTime."\t[INFO] Connected\n";

   $unixTime = time();
  $realTime = date('[Y-m-d] - [H:i]',$unixTime);
  if($BotChannelTime["channel_name"] != "[cspacer0] {$realTime}")
  {
  $BotChannelTime["channel_name"] = "[cspacer0] {$realTime}";
  $unixTime = time();
  $realTime = date('[Y-m-d] [H:i:s]',$unixTime);
  echo $realTime."\t[INFO] Time updated\n";
  }
  $serverInfo = $ts3->getInfo();
  $maxSlots = $serverInfo["virtualserver_maxclients"];
  $clientsOnline = $serverInfo["virtualserver_clientsonline"];
  $slotsReserved = $serverInfo["virtualserver_reserved_slots"];
  $slotsAvailable = $maxSlots - $slotsReserved;

  if($BotChannelUsuarios["channel_name"] != "[cspacer0] Users online: {$clientsOnline}/{$slotsAvailable}")
  {
  $BotChannelUsuarios["channel_name"] = "[cspacer0] Users online: {$clientsOnline}/{$slotsAvailable}";
  $unixTime = time();
  $realTime = date('[Y-m-d] [H:i:s]',$unixTime);
  echo $realTime."\t[INFO] Users online updated\n";
  }

  $unixTime = time();
  $realTime = date('[Y-m-d] [H:i:s]',$unixTime);
  die($realTime."\t[INFO] Finished.\n");
}
catch(Exception $e)
{
  $unixTime = time();
  $realTime = date('[Y-m-d] [H:i:s]',$unixTime);
  echo "Failed\n";
  die($realTime."\t[ERROR]  " . $e->getMessage() . "\n". $e->getTraceAsString() ."\n");
}
--------------------------------------------------------------------------------------------------------------------------


I need add port server and Solar date ( iran date example : 1395-05-11 )
Please Help Mee:)
 
Last edited by a moderator:

Alligatoras

Administrator
Mar 31, 2016
2,570
12
2,857
381
PHP:
<?php

require_once("TeamSpeak3/TeamSpeak3.php");
date_default_timezone_set('Asia/tehran');
TeamSpeak3::init();

$user = "serveradmin";
$pass = "951753";
$serverIP = "127.0.0.1";
$botTimeChannel = 1;
$botUsersChannel = 2;

$nickname = "TimeBot";

try
{
   $ts3 = TeamSpeak3::factory("serverquery://{$user}:{$pass}@{$serverIP}:10011/?server_port=9987&blocking=0&nickname={$nickname}");

  $BotChannelTime = $ts3->channelGetById($botTimeChannel);
  $BotChannelUsuarios = $ts3->channelGetById($botUsersChannel);

  $unixTime = time();
   $realTime = date('[Y-m-d] [H:i:s]',$unixTime);
  echo $realTime."\t[INFO] Connected\n";

   $unixTime = time();
  $realTime = date('[Y-m-d] - [H:i]',$unixTime);
  if($BotChannelTime["channel_name"] != "[cspacer0] {$realTime}")
  {
  $BotChannelTime["channel_name"] = "[cspacer0] {$realTime}";
  $unixTime = time();
  $realTime = date('[Y-m-d] [H:i:s]',$unixTime);
  echo $realTime."\t[INFO] Time updated\n";
  }
  $serverInfo = $ts3->getInfo();
  $maxSlots = $serverInfo["virtualserver_maxclients"];
  $clientsOnline = $serverInfo["virtualserver_clientsonline"];
  $slotsReserved = $serverInfo["virtualserver_reserved_slots"];
  $slotsAvailable = $maxSlots - $slotsReserved;

  if($BotChannelUsuarios["channel_name"] != "[cspacer0] Users online: {$clientsOnline}/{$slotsAvailable}")
  {
  $BotChannelUsuarios["channel_name"] = "[cspacer0] Users online: {$clientsOnline}/{$slotsAvailable}";
  $unixTime = time();
  $realTime = date('[Y-m-d] [H:i:s]',$unixTime);
  echo $realTime."\t[INFO] Users online updated\n";
  }

  $unixTime = time();
  $realTime = date('[Y-m-d] [H:i:s]',$unixTime);
  die($realTime."\t[INFO] Finished.\n");
}
catch(Exception $e)
{
  $unixTime = time();
  $realTime = date('[Y-m-d] [H:i:s]',$unixTime);
  echo "Failed\n";
  die($realTime."\t[ERROR]  " . $e->getMessage() . "\n". $e->getTraceAsString() ."\n");
}
--------------------------------------------------------------------------------------------------------------------------


I need add port server and Solar date ( iran date example : 1395-05-11 )
Please Help Mee:)

About the Port:

Change this:
PHP:
$user = "serveradmin";
$pass = "951753";
$serverIP = "127.0.0.1";
$botTimeChannel = 1;
$botUsersChannel = 2;

$nickname = "TimeBot";
with this:
PHP:
$user = "serveradmin";
$pass = "951753";
$serverIP = "127.0.0.1";
$serverport = "9987";
$botTimeChannel = 1;
$botUsersChannel = 2;

$nickname = "TimeBot";

And change this:
PHP:
$ts3 = TeamSpeak3::factory("serverquery://{$user}:{$pass}@{$serverIP}:10011/?server_port=9987&blocking=0&nickname={$nickname}");
with this:
PHP:
$ts3 = TeamSpeak3::factory("serverquery://{$user}:{$pass}@{$serverIP}:10011/?server_port={$serverport}&blocking=0&nickname={$nickname}");


About the Date:

Change this:

PHP:
$realTime = date('[Y-m-d] [H:i:s]',$unixTime);
with this: (in both lines that exists)
PHP:
$realTime = date('[Y-d-m] [H:i:s]',$unixTime);


I hope this will help you! :)
 

mradar

Member
Mar 18, 2016
5
0
36
About the Port:

Change this:
PHP:
$user = "serveradmin";
$pass = "951753";
$serverIP = "127.0.0.1";
$botTimeChannel = 1;
$botUsersChannel = 2;

$nickname = "TimeBot";
with this:
PHP:
$user = "serveradmin";
$pass = "951753";
$serverIP = "127.0.0.1";
$serverport = "9987";
$botTimeChannel = 1;
$botUsersChannel = 2;

$nickname = "TimeBot";

And change this:
PHP:
$ts3 = TeamSpeak3::factory("serverquery://{$user}:{$pass}@{$serverIP}:10011/?server_port=9987&blocking=0&nickname={$nickname}");
with this:
PHP:
$ts3 = TeamSpeak3::factory("serverquery://{$user}:{$pass}@{$serverIP}:10011/?server_port={$serverport}&blocking=0&nickname={$nickname}");


About the Date:

Change this:

PHP:
$realTime = date('[Y-m-d] [H:i:s]',$unixTime);
with this: (in both lines that exists)
PHP:
$realTime = date('[Y-d-m] [H:i:s]',$unixTime);


I hope this will help you! :)
thank you
 
Top