Page 2 of 2

Re: automated administrator messages?

Posted: Sat Jan 02, 2010 3:59 pm
by Mr.Victor
Kent the urlencode didn't do it. When all tables are empty it cycles through no problem. As soon as it hit the first active table, it sends the message but then errors out on the rest of the tables.

Re: automated administrator messages?

Posted: Sat Jan 02, 2010 4:10 pm
by Kent Briggs
Mr.Victor wrote:Kent the urlencode didn't do it. When all tables are empty it cycles through no problem. As soon as it hit the first active table, it sends the message but then errors out on the rest of the tables.
Oh, I see the problem now. You are overwriting the $api array that holds your list of table names each time you call the API again to send the message. So it's only working once and then you are losing your list of names. You could either copy $api to another variable or just change to a different name like $api2 on subsequent calls. So inside your loops, change this:

Code: Select all

$api = Poker_API($url,$params,true);
to something like this:

Code: Select all

$api2 = Poker_API($url,$params,true);
and then reference $api2 in the rest of the loop.

Re: automated administrator messages?

Posted: Sat Jan 02, 2010 4:43 pm
by Mr.Victor
Aha! That did it. I knew it would be a simple fix but I just couldn't see it. I renamed $api to $tables and it worked like a charm. I added the &Log and now I got exactly what I wanted. Now I just have to get the cron job going and I'm good to go. Thanks Kent.

Re: automated administrator messages?

Posted: Wed Jan 06, 2010 10:17 am
by Mr.Victor
I ended up downloading z-cron for windows and running it on my VPS which is working out well. I have another question. Is there a way to make URLs in the messages clickable?

Re: automated administrator messages?

Posted: Wed Jan 06, 2010 11:25 am
by Kent Briggs
Mr.Victor wrote:Is there a way to make URLs in the messages clickable?
Not in the chat boxes (otherwise players would be spamming the chat with links that overwrote the game window). You can embed links in other areas like the Description field that is displayed when the Table Info buttons are clicked and in the Site News window. Be sure the include the target="_blank" parameter in the <a> tag to force the page into a new window.

Re: automated administrator messages?

Posted: Wed Jan 06, 2010 7:24 pm
by Mr.Victor
Hey Kent,

Found an issue. On MTTs, it only sends the message to Table 1. Any idea how to fix this?

Re: automated administrator messages?

Posted: Wed Jan 06, 2010 8:28 pm
by Kent Briggs
Mr.Victor wrote:Hey Kent,

Found an issue. On MTTs, it only sends the message to Table 1. Any idea how to fix this?
It's working for me in 2.78. I create a tournament called "T4" and gave it 3 tables. I put it online on my local machine, logged into the client and opened all three tables. I then typed this command into another browser window:

http://192.168.1.100:8087/api?password= ... sage=test1

Which returned:

Result=Ok

And in all three chat boxes it displayed:

Administrator: test1

I also went to the Tournaments tab on the Windows server console, selected the T4 tournament, clicked the Message button on the toolbar, typed in "test2" and that also displayed on all three tables:

Administrator: test2

Can you duplicate this manual test on your system?

Re: automated administrator messages?

Posted: Thu Feb 04, 2010 9:39 pm
by Mr.Victor
Some people have requested the code for this so I figured I would just share it here for all to use:

I put this code in a php file called table-message.php and called it using a cron job. You can create multiple files with different messages and call them. I have four files being called every 20 minutes so there is a message broadcast every 5 minutes on my site. Make sure to put your IP address in the four spots where it is called for.

Code: Select all

<?php

  include "API.php";  // API $url and $pw values set here
  
  $message = "PLACE YOUR MESSAGE HERE.";
  
  echo $message . "<br /><br />";

      // Get list of all ring games and send message.

  $url = "http://YOUR_IP_HERE:8087/api";
  $params = "Password=" . $pw . "&Command=RingGamesList&Fields=Name,Status";
  $api = Poker_API($url,$params,true);
  
  if ($result == "Error") die("Error: " . $api["Error"]);
  
  $namestatus = $api["RingGames"];
  
  echo "Send message to Ring Games: <br /><br />";
  
  for ($i = 1; $i <= $namestatus; $i++)
  { 
		  $name = $api["Name" . $i];
          $status = $api["Status" . $i];
	 
	 if  ($status != 'Playing: 0') // Check to make sure ring game is not empty
	  
	  // Send message to all ring game tables that aren't empty.
       {
        $url = "http://YOUR_IP_HERE:8087/api";
        $params = "Password=" . $pw . "&Command=RingGamesMessage&Name=" .  urlencode($name) . "&Message=" . urlencode($message) . "&Log=" .  urlencode($name) . ": " . urlencode($message);
        $tables = Poker_API($url,$params,true);
  
        if ($tables[Result] == "Ok") echo "<font color='#00FF00'>Message Sent to " . $name . " Ring Game Table. </font><br />";
        else echo "<font color='#FF0000'>Error: " . $tables[Error] . ".</font><br />";
	   }
	   
	 else
	    echo  "<font color='#FF0000'>" . $name . " table is empty.  No message sent. </font><br />";
  }
  
      // Get list of all tournaments and send message.

  $url = "http://YOUR_IP_HERE:8087/api";
  $params = "Password=" . $pw . "&Command=TournamentsList&Fields=Name,Status";
  $api = Poker_API($url,$params,true);
  
  if ($result == "Error") die("Error: " . $api["Error"]);
  
  $namestatus = $api["Tournaments"];
  
  echo "<br />Send message to Tournament Tables: <br /><br />";
  
  for ($i = 1; $i <= $namestatus; $i++)
  { 
		  $name = $api["Name" . $i];
          $status = $api["Status" . $i];
	 
	 if  (strstr($status,"Playing: ")) // Check to make sure tournament is running
	  
	  // Send message to all tournaments that are running.
       {
        $url = "http://YOUR_IP_HERE:8087/api";
        $params = "Password=" . $pw . "&Command=TournamentsMessage&Name=" .  urlencode($name) . "&Message=" . urlencode($message) . "&Log=" .  urlencode($name) . ": " . urlencode($message);
        $tables = Poker_API($url,$params,true);
  
        if ($tables[Result] == "Ok") echo "<font color='#00FF00'>Message Sent to " . $name . " Tournament Table. </font><br />";
        else echo "<font color='#FF0000'>Error: " . $tables[Error] . ".</font><br />";
	   }
	   
	 else
	    echo  "<font color='#FF0000'>" . $name . " is not running.  No message sent. </font><br />";
  }

?>

Re: automated administrator messages?

Posted: Sun Apr 19, 2020 8:57 pm
by BO1LER
Kent Briggs wrote:
Mr.Victor wrote:Is there a way to make URLs in the messages clickable?
Not in the chat boxes (otherwise players would be spamming the chat with links that overwrote the game window). You can embed links in other areas like the Description field that is displayed when the Table Info buttons are clicked and in the Site News window. Be sure the include the target="_blank" parameter in the <a> tag to force the page into a new window.

I can't get links in the Table Description field to be clickable. Is there a specific formatting I need to use?
Thanks.

Mike

Re: automated administrator messages?

Posted: Sun Apr 19, 2020 9:45 pm
by Kent Briggs
BO1LER wrote:I can't get links in the Table Description field to be clickable. Is there a specific formatting I need to use?
Use something like this (you have to make your own underline):

Code: Select all

<a href="http://www.example.com" target="_blank"><u>Click here</u></a> for test.