automated administrator messages?

For general discussion of the Poker Mavens software

Re: automated administrator messages?

Postby Mr.Victor » Sat Jan 02, 2010 3:59 pm

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.
Mr.Victor
 
Posts: 88
Joined: Tue Dec 22, 2009 8:27 am

Re: automated administrator messages?

Postby Kent Briggs » Sat Jan 02, 2010 4:10 pm

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.
Kent Briggs - [email protected]
Briggs Softworks - http://www.briggsoft.com
Kent Briggs
Site Admin
 
Posts: 3763
Joined: Wed Mar 19, 2008 8:47 pm

Re: automated administrator messages?

Postby Mr.Victor » Sat Jan 02, 2010 4:43 pm

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.
Mr.Victor
 
Posts: 88
Joined: Tue Dec 22, 2009 8:27 am

Re: automated administrator messages?

Postby Mr.Victor » Wed Jan 06, 2010 10:17 am

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?
Mr.Victor
 
Posts: 88
Joined: Tue Dec 22, 2009 8:27 am

Re: automated administrator messages?

Postby Kent Briggs » Wed Jan 06, 2010 11:25 am

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.
Kent Briggs - [email protected]
Briggs Softworks - http://www.briggsoft.com
Kent Briggs
Site Admin
 
Posts: 3763
Joined: Wed Mar 19, 2008 8:47 pm

Re: automated administrator messages?

Postby Mr.Victor » Wed Jan 06, 2010 7:24 pm

Hey Kent,

Found an issue. On MTTs, it only sends the message to Table 1. Any idea how to fix this?
Mr.Victor
 
Posts: 88
Joined: Tue Dec 22, 2009 8:27 am

Re: automated administrator messages?

Postby Kent Briggs » Wed Jan 06, 2010 8:28 pm

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=x&command=tournamentsmessage&name=T4&message=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?
Kent Briggs - [email protected]
Briggs Softworks - http://www.briggsoft.com
Kent Briggs
Site Admin
 
Posts: 3763
Joined: Wed Mar 19, 2008 8:47 pm

Re: automated administrator messages?

Postby Mr.Victor » Thu Feb 04, 2010 9:39 pm

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 />";
  }

?>
Mr.Victor
 
Posts: 88
Joined: Tue Dec 22, 2009 8:27 am

Previous

Return to General

Who is online

Users browsing this forum: No registered users and 7 guests