Remaining time Temaspeak bot


SUBMITTED BY: Todlich

DATE: Aug. 13, 2016, 5:52 p.m.

FORMAT: PHP

SIZE: 1.7 kB

HITS: 1441

  1. <?php
  2. /* START: Credits
  3. RTTB = Remaining time Temaspeak bot
  4. Author: Key1 (Github: @Todliwch)
  5. */// END: Credits
  6. require("teamspeak.class.php"); //Include Teamspeak PHP Class
  7. // START: Teamspeak server details
  8. $address = 'localhost'; //Teamspeak address
  9. $qport = 10011 ; //Query port
  10. $port = 9987; //Port
  11. $user = 'username'; //Query username (normal use: serveradmin)
  12. $password = 'password'; //Query password
  13. $name = 'Countbot'; //Bot name
  14. $cid = 2; //Channel ID that you want.
  15. $timezone = "Asia/Tehran"; //Timezone (for example: Asia/Tehran)
  16. $target = "2016-07-12 12:00:00"; //Your target's date
  17. // END: Teamspeak server details
  18. date_default_timezone_set($timezone); // Set timezone
  19. $con = new ts3admin($address, $qport); // Connect to server
  20. if($con->getElement('success', $con->connect())) { //If connection was successfully
  21. $con->login($user, $password); //Login into query
  22. $con->selectServer($port); //Select server by port. (You can use server id instead of port)
  23. $con->setName($name); //Set the bot's name
  24. while(1) {
  25. $date = strtotime($target) - time(); //Convert string to time and count remaining date
  26. $days = floor($date / 86400); //Count remaining days
  27. $hours = floor(($date % 86400) / 3600); //Count remaining hours
  28. $cstr = "[cspacer]{$days}d and {$hours}h remaining..."; //Channel's name string (Use '$days' for remaining days and '$hours' for remaining hours)
  29. $con -> channelEdit($cid, array('channel_name' => $cstr)); //Set channel's name
  30. sleep(60); //Run the loop every 60seconds(1minute) and check date. (Edit it optionaly)
  31. }
  32. } else {
  33. die("Unable to connect to $address:$port..."); //If connection was not successfully
  34. }
  35. ?>

comments powered by Disqus