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: !history - IGN style  (Read 3810 times)

0 Members and 1 Guest are viewing this topic.

Offline Zakus

  • BeBot Rookie
  • *
  • Posts: 18
  • Karma: +0/-0
!history - IGN style
« on: March 14, 2006, 10:56:09 pm »
Description:
A module that returns character history retrieved from auno.org in a robust format (similar in functionality to the IGN 'aunobio.php' plugin.

Commands:

!history (Can be used in tells, privategroup and guildchat)
Returns a single page of the parsed results of a lookup to auno.org, including Date, Level, AI Level, Faction, Guild (and rank)

I really found the way that the IGN bot returned info via their !history command to be nicely formatted and useful.
The one by Foxferal, while useful, was lacking in formatting.

My PHP kung fu is nearly non-existant but If nobody picks this up I'll be forced to do something ugly and probably poorly working.

Thanks in advance!

-Zakus

Offline Zakus

  • BeBot Rookie
  • *
  • Posts: 18
  • Karma: +0/-0
Re: !history - IGN style
« Reply #1 on: March 15, 2006, 01:07:20 am »
I've made some progress, but what I would like to do is call the 'whois' function from the whois module, and take apart what results.

If I can ask this in a way to not make php developers want to kill me:

It looks like I want to do something like:
Code: [Select]
$this -> whois -> whois($word2);
I could be competely off my rocker, but does that look like I'm headed in the correct direction?
-Z

Offline Naturalistic

  • Contributor
  • *******
  • Posts: 221
  • Karma: +0/-0
Re: !history - IGN style
« Reply #2 on: March 15, 2006, 01:24:03 am »
I believe it would be more like $this -> bot -> whois -> whois($name)

But I don't know how you set it up as, nor what you changed etc :P But generally that's what I used when calling external functions.
220/25 Eternalist Doctor
-----------------------------
Campalot Coding Co-ordinator and Super Admin
http://www.campalot.info/index.php

Offline Zakus

  • BeBot Rookie
  • *
  • Posts: 18
  • Karma: +0/-0
Re: !history - IGN style
« Reply #3 on: March 15, 2006, 01:27:56 am »
I'd be scary if I knew what I was doing.
Thanks for the referral, I'm going to keep hammering on this.

I actually fixed a problem with the logic that was used in the old IGN plugin.   Go me.

Offline Xenixa

  • Contributor
  • *******
  • Posts: 307
  • Karma: +0/-0
Re: !history - IGN style
« Reply #4 on: March 15, 2006, 01:30:37 am »
If you're talking about Alreadythere's whois cache module use this:
Code: [Select]
$who = $this -> bot -> whois -> lookup($name);
You can find the lookup() function in the WhoisCache.php file to see what it will return and then format as you please.
<<< Hack's in Zend Studio

All my Custom Bebot files may be Found Here <-clicky

Offline Zakus

  • BeBot Rookie
  • *
  • Posts: 18
  • Karma: +0/-0
Re: !history - IGN style
« Reply #5 on: March 15, 2006, 01:32:09 am »
That may be exactly what I was looking for.
Thanks much.
-Z

Offline Zakus

  • BeBot Rookie
  • *
  • Posts: 18
  • Karma: +0/-0
Re: !history - IGN style
« Reply #6 on: March 15, 2006, 01:43:59 am »
Well, that wasn't the module I was using afterall, but it gave me some examples to play with tomorrow.

In case anyone cares, here is what I'm messing with at this point:
--Edited to reflect new changes 03/15/2006--
Code: [Select]
<?php
  
/*
   * History.php - Online plugin to display user history
   *
   * BeBot - An Anarchy Online Chat Automaton
   * Copyright (C) 2004 Jonas Jax
   * Developed by Blondengy (RK1)
   * Special thanks goes out to Khalem (RK1) for his support.
   *
   * History.php written by Foxferal (RK1), concept borrowed from IGN Networks
   * Hacked to look more like the IGN aunobio module, using ugly code theft, by Zakus - RK1 03/15/2006
   */


  
$history = new History($bot);


  
$commands["tell"]["history"] = &$history;
  
$commands["pgmsg"]["history"] = &$history;
  
$commands["gc"]["history"] = &$history;

  
/*
    The Class itself...
  */
  
class History
  
{
var $fname
var $lname
var $orgname;    

    
/*
      Constructor:
        Hands over a referance to the "Bot" class.
    */
    
function History (&$bot)
    {
      
$this -> bot = &$bot;
    }

    
/*
      This gets called on a tell with the command
    */
    
function tell($name$msg)
    {
      
preg_match("/^" $this -> bot -> commpre "history (.+)$/i"$msg$info);
      
$info[1] = ucfirst(strtolower($info[1]));
      
      if (
$this -> bot -> aoc -> get_uid($info[1]))
        
$this -> bot -> send_tell($name$this -> player_history($info[1]));
      else
        
$this -> bot -> send_tell($name"Player <font color=#ffff00>" $info[1] . "</font> does not exist.");
    }



    
/*
      This gets called on a msg in the privgroup with the command
    */
    
function pgmsg($name$msg)
    {
      
preg_match("/^" $this -> bot -> commpre "history (.+)$/i"$msg$info);
      
$info[1] = ucfirst(strtolower($info[1]));

      if (
$this -> bot -> aoc -> get_uid($info[1]))
        
$this -> bot -> send_pgroup($this -> player_history($info[1]));
      else
        
$this -> bot -> send_pgroup("Player <font color=#ffff00>" $info[1] . "</font> does not exist.");
    }



    
/*
      This gets called on a msg in the guildchat with the command
    */
    
function gc($name$msg)
    {
      
preg_match("/^" $this -> bot -> commpre "history (.+)$/i"$msg$info);
      
$info[1] = ucfirst(strtolower($info[1]));

      if (
$this -> bot -> aoc -> get_uid($info[1]))
        
$this -> bot -> send_gc($this -> player_history($info[1]));
      else
        
$this -> bot -> send_gc("Player <font color=#ffff00>" $info[1] . "</font> does not exist.");
    }

    
/*
      Get info on player
    */
    
function player_history($name)
    {

$reply = (" No data found for (ucword2) "); 
$newurl "http://auno.org/ao/char.php?output=xml&dimension=" $this -> bot -> dimension "&name=".$name

$data file_get_contents($newurl); 

if (!stristr($data,"no character found") && !empty($data)) { 
preg_match_all('|<entry date="(.*)" level="(.*)" ailevel="(.*)" faction="(.*)" guild="(.*)" rank="(.*)" />|Ui'$data$matches); 
                
$who $this -> bot -> whois -> lookup($name); 


$blob .= "<font color=CCInfoHeadline>Character History For: \n</font>"
$blob .= "<font color=CCInfoHeadline>::: ".$who['firstname']." \"$name\" ".$who['lastname']." :::</font>\n\n";
$blob .= ":: Level/AL: <font color=CCCCTextColor>".$who['level']." / <font color=#33FF33>".$who['at_name']."(".$who['at'].")</font></font>\n";
$blob .= ":: Breed: <font color=CCCCTextColor>".$who['breed']."</font>\n";
$blob .= ":: Gender: <font color=CCCCTextColor>".$who['gender']."</font>\n";
$blob .= ":: Profession: <font color=CCCCTextColor>".$who['profession']."</font>\n";
$blob .= ":: Current Org: <font color=CCCCTextColor>".$who['org']."</font>\n";
$blob .= ":: Org Rank: <font color=CCCCTextColor>".$who['rank']."</font>\n\n";

$blob .= "<font color=CCInfoHeader>Date              Level     AI     Faction     Org. and (Rank)</font>\n"
$blob .= "¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯\n"
  
for($i 0$i count($matches[0]); $i++) { 
if(strlen($matches[2][$i])==1){$matches[2][$i]="00".$matches[2][$i];} 
if(strlen($matches[2][$i])==2){$matches[2][$i]="0".$matches[2][$i];} 
if(strlen($matches[3][$i])==1){$matches[3][$i]="0".$matches[3][$i];} 
if(empty($matches[3][$i])){$matches[3][$i]="   ";} 
if($matches[4][$i]=="Omni"){$matches[4][$i] .="   ";} 
if($matches[4][$i]=="Clan"){$matches[4][$i] .="    ";} 
$blob .= "<font color=#ffffff>".$matches[1][$i]."</font>  |  "
$blob .= "<font color=CCInfoHeader>".$matches[2][$i]."</font>  |  "
$blob .= "<font color=CCInfoText>".$matches[3][$i]."</font>  |  "
$blob .= "<font color=#ffffff>".$matches[4][$i]."</font>  |  ";

if(!empty($matches[5][$i])) 
{
$blob .= "<font color=CCInfoHeadline>".$matches[5][$i]." (".$matches[6][$i].")</font>\n";

else {$blob .= "Not in Guild\n";} 
       
   } 


return "History for ".$name." :: " $this -> bot -> make_blob("click to view"$blob);
}
else
{
return "No name specified.";
}
}
  }
?>

« Last Edit: March 15, 2006, 10:41:27 pm by Zakus »

Offline Xenixa

  • Contributor
  • *******
  • Posts: 307
  • Karma: +0/-0
Re: !history - IGN style
« Reply #7 on: March 15, 2006, 02:23:25 am »
I don't recall what IGN's History format looks like exactly. But if it looks like what I did with the alts.php for Bebot that would be nifty. You can find an example of what it looks like here:
http://bebot.link/index.php/topic,204.msg1641.html#msg1641

And the code for formating it that way is here:
http://bebot.link/index.php/topic,288.msg1761.html#msg1761

You could use the whois info for the header area then call the History to parse under that.
<<< Hack's in Zend Studio

All my Custom Bebot files may be Found Here <-clicky

Offline Khalem

  • BeBot Founder
  • Administrator
  • ********
  • Posts: 1169
  • Karma: +0/-0
    • http://www.ancarim.com
Re: !history - IGN style
« Reply #8 on: March 15, 2006, 05:44:20 pm »
Foxferals History module based on IGN (I dislike the layout)
Code: [Select]
<?php
/*
* History.php - Online plugin to display user history
*
* BeBot - An Anarchy Online Chat Automaton
* Copyright (C) 2004 Jonas Jax
* Developed by Blondengy (RK1)
* Special thanks goes out to Khalem (RK1) for his support.
*
* History.php written by Foxferal (RK1), concept borrowed from IGN Networks
*/


$history = new History($bot);


$commands["tell"]["history"] = &$history;
$commands["pgmsg"]["history"] = &$history;
$commands["gc"]["history"] = &$history;

/*
The Class itself...
*/
class History
{
        var 
$bot;



        
/*
        Constructor:
        Hands over a referance to the "Bot" class.
        */
        
function History (&$bot)
        {
                
$this -> bot = &$bot;
        }

        
/*
        This gets called on a tell with the command
        */
        
function tell($name$msg)
        {
                
preg_match("/^" $this -> bot -> commpre "history (.+)$/i"$msg$info);
                
$info[1] = ucfirst(strtolower($info[1]));

                if (
$this -> bot -> aoc -> get_uid($info[1]))
                
$this -> bot -> send_tell($name$this -> player_history($info[1]));
                else
                
$this -> bot -> send_tell($name"Player <font color=#ffff00>" $info[1] . "</font> does not exist.");
        }



        
/*
        This gets called on a msg in the privgroup with the command
        */
        
function pgmsg($name$msg)
        {
                
preg_match("/^" $this -> bot -> commpre "history (.+)$/i"$msg$info);
                
$info[1] = ucfirst(strtolower($info[1]));

                if (
$this -> bot -> aoc -> get_uid($info[1]))
                
$this -> bot -> send_pgroup($this -> player_history($info[1]));
                else
                
$this -> bot -> send_pgroup("Player <font color=#ffff00>" $info[1] . "</font> does not exist.");
        }



        
/*
        This gets called on a msg in the guildchat with the command
        */
        
function gc($name$msg)
        {
                
preg_match("/^" $this -> bot -> commpre "history (.+)$/i"$msg$info);
                
$info[1] = ucfirst(strtolower($info[1]));

                if (
$this -> bot -> aoc -> get_uid($info[1]))
                
$this -> bot -> send_gc($this -> player_history($info[1]));
                else
                
$this -> bot -> send_gc("Player <font color=#ffff00>" $info[1] . "</font> does not exist.");
        }

        
/*
        Get info on player
        */
        
function player_history($name)
        {
                if(
$name != "")
                {
                        
$result="";
                        
$file file("http://auno.org/ao/char.php?dimension=" $this -> bot -> dimension "&t=auno-print&name=".$name." ");
                        if(!
$file) return "Database is currently not reachable.";
                        while (list (
$radnr$rad) = each ($file))
                        {
                                
$result .= $rad;
                        }
                        if(!
stristr($result,"no character found"))
                        {
                                
$result preg_grep('#^<td>200#'explode("\n"$result));
                                
$ymera .= "<font color='CCInfoHeadline'>History for ".$name."<br>";
                                foreach (
$result as $line)
                                {
                                        
$result str_replace("</td>","",$line);
                                        
$result str_replace("</tr>","<td>",$result);
                                        
$result split("<td>",$result);
                                        if(empty(
$result[4]))
                                        {
                                                
$result[4]="- Not in guild";
                                        }
                                        
$ymera .= "<font color='CCInfoHeader'>• Date: </font><font color='CCInfoText'>".$result[1] ."</font><font color='CCInfoHeader'> Level: </font><font color='CCInfoText'>".$result[2] ."<br><font color='CCInfoText'>".$result[5]." ".$result[4]." (".$result[3].").</font>\n";
                                }
                                
$ymera .="<br><font color=CCInfoHeadline>Plugin by Foxferal\n\n";
                        }
                        else
                        {
                                
$ymera "Character not found";
                        }

                        return 
"History for ".$name." :: " $this -> bot -> make_blob("click to view"$ymera);
                }
                else
                {
                        return 
"No name specified.";
                }
        }
}
?>


BeBot Founder and Fixer Kingpin

MatHack

  • Guest
Re: !history - IGN style
« Reply #9 on: March 15, 2006, 05:51:14 pm »
My version (layout looks very like IGN, simply because it has the best overview):

Code: [Select]
<?php
/*
* History.php - Online plugin to display user history
*
* BeBot - An Anarchy Online Chat Automaton
* Copyright (C) 2004 Jonas Jax
* Developed by Blondengy (RK1)
* Special thanks goes out to Khalem (RK1) for his support.
*
* History.php written by Foxferal (RK1), concept borrowed from IGN Networks
*/

$history = new History($bot);

$commands["tell"]["history"] = &$history;
$commands["gc"]["history"] = &$history;

class 
History
{
var $bot;

function History (&$bot)
{
$this -> bot = &$bot;
}

function tell($name$msg)
{
preg_match("/^" $this -> bot -> commpre "history (.+)$/i"$msg$info);
$info[1] = ucfirst(strtolower($info[1]));

if ($this -> bot -> aoc -> get_uid($info[1]))
$this -> bot -> send_tell($name$this -> player_history($info[1]));
else
$this -> bot -> send_tell($name"Character <font color=#ffff00>" $info[1] . "</font> does not exist.");
}

function gc($name$msg)
{
preg_match("/^" $this -> bot -> commpre "history (.+)$/i"$msg$info);
$info[1] = ucfirst(strtolower($info[1]));

if ($this -> bot -> aoc -> get_uid($info[1]))
$this -> bot -> send_gc($this -> player_history($info[1]));
else
$this -> bot -> send_gc("Character <font color=#ffff00>" $info[1] . "</font> does not exist.");
}

function player_history($name)
{
if($name != "")
{
$result "";
$file file("http://auno.org/ao/char.php?dimension=" $this -> bot -> dimension "&t=auno-print&name=" $name " ");
if (!$file)
return "Database is currently not reachable.";
while (list ($radnr$rad) = each ($file))
$result .= $rad;
if(!stristr($result"no character found"))
{
$result preg_grep('#^<td>200#'explode("\n"$result));
$ymera .= "<font color='CCInfoHeadline'>History for " $name "<br><br>";
foreach ($result as $line)
{
$result str_replace("</td>"""$line);
$result str_replace("</tr>""<td>"$result);
$result split("<td>"$result);
if (empty($result[5]))
$result[5] = "-";
else
$result[5] = $result[5] . "</font><font color='CCInfoText'> (" $result[6] . ")";
$ymera .= sprintf("<font color='CCCCTextColor'>%s</font>  |  <font color='CCInfoText'>%03d</font>  |  <font color='CCCCTextColor'>%02d</font>  |  <font color='CCInfoText'>%s</font>  |  <font color='CCCCTextColor'>%s</font><br>"$result[1], $result[2], $result[3], $result[4], $result[5]);
}
}
else
$ymera "Character not found";

return "History for " $name " :: " $this -> bot -> make_blob("click to view"$ymera);
}
else
return "No name specified.";
}
}
?>

Offline Zakus

  • BeBot Rookie
  • *
  • Posts: 18
  • Karma: +0/-0
Re: !history - IGN style
« Reply #10 on: March 15, 2006, 10:43:10 pm »
I updated the code listing above.
I'd like input about it if possible.

Additionally, I'm trying to understand how 'make_blob' works, because sometimes the character history goes for more than 1 page, and I'd like to have the header row repeat on subsequent pages.

Any help / suggestions would be appreciated.

-Z

Offline Khalem

  • BeBot Founder
  • Administrator
  • ********
  • Posts: 1169
  • Karma: +0/-0
    • http://www.ancarim.com
Re: !history - IGN style
« Reply #11 on: March 15, 2006, 11:40:36 pm »
I would suggest looking at the Rights Management core module in 0.3.x as it uses an internal counter to detect if the blob if about to be split into multiple.
Its not perfect though as it assumes the default blob size which is subject to change :\
BeBot Founder and Fixer Kingpin

Offline Zakus

  • BeBot Rookie
  • *
  • Posts: 18
  • Karma: +0/-0
Re: !history - IGN style
« Reply #12 on: March 15, 2006, 11:43:40 pm »
Maybe I'll hold off on that header then.. sounds a bit over my head.
The world can live without the header on subsequent pages.
Choose the hill I want to die on... you know? :p

Offline jjones666

  • Contributor
  • *******
  • Posts: 353
  • Karma: +0/-0
Re: !history - IGN style
« Reply #13 on: March 19, 2007, 05:38:12 pm »
Moved discussion to here and closed this topic.

-jj-

 

* 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: 693
  • 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