L* R*
HOME FORUM DOWNLOADS
Content
  Links
     Browse SVN
     SVN Commit log
     Documentation (Wiki)
  Developers
     Taskmanager
User
Welcome, Guest. Please login or register.
Did you miss your activation email?
November 22, 2008, 12:08:53 PM

Login with username, password and session length
Search



Advanced search
Support GoPHP5.org
BeBot - An Anarchy Online/Age Of Conan chat automaton > Forum > Modules > Modules for older versions > 0.2.x Custom/Unofficial Modules > Topic: modified Online.php
Pages: [1] 2 3   Go Down
« previous next »
Print
Author Topic: modified Online.php  (Read 3882 times)
0 Members and 1 Guest are viewing this topic.
Akarah
BeBot Contributor
Rookie
*******
Offline Offline

Posts: 72


WWW
modified Online.php
« on: December 04, 2005, 06:12:05 AM »

yup i was really bored and wanted to whip up something trivial and simple, so here is yet another "core" change, not really a module. i added some graphic elements (icons, seperators) to the Online.php file, and also integrated Alreadythere's whois caching stuff (not that we ever have to whois members... but i guess it never hurts to be thorough Wink )

sample:


file:
http://ao.rockwood.us/bebot/Online.phps

rename to .php of course - depends on Alreadythere's WhoisCache module (unless the method is never called..)

cheers,

/Aka
Logged
Wanuarmi
BeBot Contributor
Apprentice
*******
Offline Offline

Posts: 121


modified Online.php
« Reply #1 on: December 04, 2005, 06:24:05 AM »

hey wow that looks nice...

gonna try it out later

edit: do I have to install the whois cache? I tried it and its saying it cant call a function.
Logged
Akarah
BeBot Contributor
Rookie
*******
Offline Offline

Posts: 72


WWW
modified Online.php
« Reply #2 on: December 04, 2005, 07:02:27 AM »

i played around with using the images shown during profession selection, but they weren't designed to be alphabetized, and i didn't want to mess up the script any more than i did (ksort() is great.. sorting by fc's order is probably NOT great Wink )
Logged
Wanuarmi
BeBot Contributor
Apprentice
*******
Offline Offline

Posts: 121


modified Online.php
« Reply #3 on: December 04, 2005, 07:06:12 AM »

is there a version that doesnt use the whois cache? I really liked this... also does the privgroup online list looks like the guild online list?
Logged
Alreadythere
BeBot Maintainer
Administrator
Grandmaster
********
Offline Offline

Posts: 1077


modified Online.php
« Reply #4 on: December 04, 2005, 07:21:46 AM »

Quote from: "Wanuarmi"
is there a version that doesnt use the whois cache? I really liked this...


Just replace only the function online_list(), should do the trick I think.
Or use Akarah's file, and use the whois() function out of your old Online.php.

Not 100% sure which of those two things is the better way Smiley
Logged
Akarah
BeBot Contributor
Rookie
*******
Offline Offline

Posts: 72


WWW
modified Online.php
« Reply #5 on: December 04, 2005, 07:22:45 AM »

yup the only changes affecting display are in online_list()

i didn't test the privgroup, but it uses the same function, so it should.
Logged
Wanuarmi
BeBot Contributor
Apprentice
*******
Offline Offline

Posts: 121


modified Online.php
« Reply #6 on: December 04, 2005, 07:37:51 AM »

cool thanks Smiley
Logged
Khalem
BeBot Founder
Administrator
Grandmaster
********
Offline Offline

Gender: Male
Posts: 670



WWW
modified Online.php
« Reply #7 on: December 04, 2005, 12:10:49 PM »

I like it, and the icons ara rather unintrusive too.

Now, one thing we need, a switch option to allow icons usage to be disabled or enabled.
Logged

BeBot Founder and Fixer Kingpin
Madman coder and destroyer of good code
Akarah
BeBot Contributor
Rookie
*******
Offline Offline

Posts: 72


WWW
modified Online.php
« Reply #8 on: December 04, 2005, 04:28:54 PM »

i thought about that as i was falling asleep Wink
Logged
Xenixa
BeBot Contributor
Expert
*******
Offline Offline

Posts: 307



modified Online.php
« Reply #9 on: December 04, 2005, 09:15:53 PM »

Oooh, nice one. Smiley
Copied the bits you added for the graphics into my copy since mines custom modified for formating. Org likes it alot Smiley

Might I suggest using the settings table if you implement a switch to turn those Icons on/off? Any thing that can be toggled on/off I been keeping in the settings table using that custom function floating around (get_setting) for bot.php
Logged

<<< Hack's in Zend Studio

All my Custom Bebot files may be Found Here <-clicky
Wanuarmi
BeBot Contributor
Apprentice
*******
Offline Offline

Posts: 121


modified Online.php
« Reply #10 on: December 05, 2005, 02:44:46 AM »

made some modifications so the AI level would show if you are not using the whois cache module

Code:
<?
  /*
   * Online.php - Online plugin to display online users
   *
   * 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.
   *
   * File last changed at $LastChangedDate: 2004-12-29 01:41:32 +0100 (Wed, 29 Dec 2004) $
   * Revision: $Id: Online.php 8 2004-12-29 00:41:32Z blondengy $
   */

 
  $online = new Online($bot);


  $commands["tell"]["online"] = &$online;
  $commands["pgmsg"]["online"] = &$online;
  $commands["gc"]["online"] = &$online;
 
  $commands["pgjoin"][] = &$online;
  $commands["pgleave"][] = &$online;
  $commands["buddy"][] = &$online;

  $commands["connect"][] = &$online;
  $commands["disconnect"][] = &$online;



  /*
    The Class itself...
  */
  class Online
  {
    var $bot;
    var $guild;
    var $pgroup;
    var $connected;
   
   

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



    /*
      This gets called on a tell with the command
    */
    function tell($name, $msg)
    {
    $disponline = (($this -> bot -> guildbot) ? "both": "pgroup");
    $this -> bot -> send_tell($name, $this -> online_msg($msg, $disponline));
    }



    /*
      This gets called on a msg in the privgroup with the command
    */
    function pgmsg($name, $msg)
    {
      if ($this -> bot -> is_member($name))
      {
      $disponline = (($this -> bot -> guildbot) ? "both": "pgroup");
      $this -> bot -> send_pgroup($this -> online_msg($msg, $disponline));
      }
    }


    /*
      Gets called on a GC message
    */
    function gc($name, $msg)
    {
    $disponline = (($this -> bot -> guildbot) ? "both": "pgroup");
    $this -> bot -> send_gc($this -> online_msg($msg, $disponline));
    }




    /*
      This gets called if someone joins the privgroup
    */
    function pgjoin($name)
    {
      $this -> pgroup[$name] = $this -> whois($name);
    }



    /*
      This gets called if someone leaves the privgroup
    */
    function pgleave($name)
    {
      if (isset($this -> pgroup[$name]))
        unset($this -> pgroup[$name]);
    }



    /*
      This gets called if a buddy logs on/off
    */
    function buddy($name, $msg)
    {
      if ($this -> bot -> is_member($name))
      {
        if ($msg == 1)
          $this -> guild[$name] = $this -> whois($name);
         
        else if (isset($this -> guild[$name]))
          unset($this -> guild[$name]);
      }
    }



     /*
      This gets called when bot disconnects
    */
    function disconnect()
    {
      $this -> guild = array();
      $this -> pgroup = array();
    }



     /*
      This gets called when bot connects
    */
    function connect()
    {
      $this -> connected = time() + 120;
    }



/*
Makes the message.
*/
function online_msg($msg, $what)
{
      preg_match("/^" . $this -> bot -> commpre . "online (.+)$/i", $msg, $info);
     
      if ($info[1] == "all")
$info[1] = "";

      $guild = $this -> online_list($this -> guild, $info[1]);
      $pgroup = $this -> online_list($this -> pgroup, $info[1]);
     
      $online = "";
      $msg = "";
     
      if (($what == "both") || ($what == "guild"))
      {
        $online .= "<font color=CCInfoHeadline>::: " . $guild[0] . " members online in Guild :::</font>\n" . $guild[1];
        $online .= "\n<font color=CCCCTextColor>------------------------------\n";
        $msg .= "<font color=#ffff00>" . $guild[0] . "</font> members online in Guild. ";
    }
    if (($what == "both") || ($what == "pgroup"))
    {
      $online .= "<font color=CCInfoHeadline>::: " . $pgroup[0] . " players in Privategroup :::</font>\n" . $pgroup[1];
        $msg .= "<font color=#ffff00>" . $pgroup[0] . "</font> members in Privategroup. ";
      }


      $msg .= ":: " . $this -> bot -> make_blob("click to view", $online);

      return $msg;
}



    /*
      Gets info on player
    */
    function whois($name)
    {
    $second = (($this -> bot -> guildbot) ? "rank_name" : "guild");
      $result = $this -> bot -> db -> select("SELECT nickname, level, $second, profession, id FROM members WHERE id = " . $this -> bot -> aoc -> get_uid($name));

      if (empty($result))
      {
       $content = $this -> bot -> get_site("http://www.anarchy-online.com/character/bio/d/" . $this -> bot -> dimension . "/name/" . strtolower($name) . "/bio.xml");
        $result[0] = $name;
        $result[1] = $this -> bot -> xmlparse($content, "level");
        $result[2] = $this -> bot -> xmlparse($content, "organization_name");
        $result[3] = $this -> bot -> xmlparse($content, "profession");
        $result[4] = $this -> bot -> aoc -> get_uid($name);
$result[5] = $this -> bot -> xmlparse($content, "defender_rank_id");
      }
      else
 {
        $result = $result[0];
$content = $this -> bot -> get_site("http://www.anarchy-online.com/character/bio/d/" . $this -> bot -> dimension . "/name/" . strtolower($name) . "/bio.xml");
$result[5] = $this -> bot -> xmlparse($content, "defender_rank_id");
 }

      if (empty($result[3]))
        $result[3] = "Unknown";
      if (empty($result[1]))
        $result[1] = "?";
      if (empty($result[2]))
        $result[2] = "<i>soloer</i>";
      if (empty($result[5]))
        $result[5] = "?";
     
 $result[6] = "none";
 
      return $result;
    }



    /*
    make the list of online players
    */
    function online_list($online, $like)
    {
        $profgfx["Meta-Physicist"] = "16308";
        $profgfx["Adventurer"] = "84203";
        $profgfx["Engineer"] = "16252";
        $profgfx["Soldier"] = "16237";
        $profgfx["Keeper"] = "84197";
        $profgfx["Shade"] = "39290";
        $profgfx["Fixer"] = "16300";
        $profgfx["Agent"] = "16186";
        $profgfx["Trader"] = "117993";
        $profgfx["Doctor"] = "44235";
        $profgfx["Enforcer"] = "100998";
        $profgfx["Bureaucrat"] = "16341";
        $profgfx["Martial Artist"] = "16196";
        $profgfx["Nano-Technician"] = "16283";
        $prof_based = "";
        $online_list = "";
        $online_num = 0;

        if (!empty($online))
        {
            foreach ($online as $player)
            {
                $prof_based[$player[3]][(sprintf("%03d", (220 - $player[1])) . $player[0])] = $player;
            }

            ksort($prof_based);

            foreach ($prof_based as $key => $prof)
            {
                if (preg_match("/" . $like . "/i", $key))
                {
                    $online_list .= "\n<img src=tdb://id:GFX_GUI_FRIENDLIST_SPLITTER>\n";
                    $online_list .= "<img src=rdb://" . $profgfx[$key] . ">";
                    $online_list .= " <font color=CCInfoHeader>" . $key . "</font>\n";
                    $online_list .= "<img src=tdb://id:GFX_GUI_FRIENDLIST_SPLITTER>\n";
                    ksort($prof);
                    foreach ($prof as $player)
                    {
                        $admin = "";
                        $online_num++;
                        $main = $this -> bot -> alts -> main($player[4]);
                        $alts = $this -> bot -> alts -> get_alts($main);

                        if ($this -> bot -> admin -> in_group($player[0], "superadmin"))
                        {
                            $admin = " :: <font color=#FF0000>Superadmin</font> ";
                        }
                        else if ($this -> bot -> admin -> in_group($player[0], "admin"))
                        {
                            $admin = " :: <font color=#FF0000>Admin</font> ";
                        }
                        else if ($this -> bot -> admin -> in_group($player[0], "raidleader"))
                        {
                            $admin = " :: <font color=#FF0000>Raidleader</font> ";
                        }



                        if (empty($alts))
                        {
                            $alts = "";
                        }
                        else if ($main == $this -> bot -> aoc -> get_uname($player[4]))
                        {
                            $alts = ":: <a href='chatcmd:///tell <botname> <pre>alts " . $player[0] . "'>Alts</a> ::";
                        }
                        else
                        {
                            $alts = ":: <a href='chatcmd:///tell <botname> <pre>alts " . $player[0] . "'>" . $main . "'s Alts</a> ";
                        }

                        if ($player[6] != "none")
                        {
                            $chatclient = "(" . $player[6] . ") ";
                        }
                        else
                        {
                            $chatclient = "";
                        }

                        $online_list .= "<font color=CCCCTextColor> - L " . $player[1] . " / AL " . $player[5] . " <font color=CCInfoText>" . $player[0] . "</font> (" . $player[2] . ") " . $admin . $chatclient . $alts . "</font>";

                        if($this -> bot -> commands["tell"]["afk"] -> afk[$player[0]])
                        {
                            $online_list .= ":: <font color=#FFFFFF>( AFK )</font>\n";
                        }
                        else
                        {
                            $online_list .= "\n";
                        }
                    }
                }
            }
        }

        return array($online_num, $online_list);
    }



    /*
      Is called if user is using a chat client...
    */
    function chatclient($name, $type)
    {
      if (isset($this -> guild[$name]))
      {
        $this -> guild[$name][5] = $type;
      }
      if (isset($this -> pgroup[$name]))
      {
        $this -> pgroup[$name][5] = $type;
      }
    }
  }
?>
Logged
Akarah
BeBot Contributor
Rookie
*******
Offline Offline

Posts: 72


WWW
modified Online.php
« Reply #11 on: December 05, 2005, 05:01:31 AM »

updated link in first post, Online.php now includes a way to change modes

/tell <bot> !online mode fancy to enable
/tell <bot> !online mode basic to disable

this doesn't really scale, and will need to be rewritten if i add more modes, since in a couple places i only do if (fancy) {} else {}


but i don't foresee adding any more modes to the one i use anyway ;p
Logged
Xenixa
BeBot Contributor
Expert
*******
Offline Offline

Posts: 307



modified Online.php
« Reply #12 on: December 05, 2005, 06:40:42 AM »

Quote from: "Wanuarmi"
made some modifications so the AI level would show if you are not using the whois cache module
...snip


Heheh, I did that long ago. Post on this forum down there somewhere from me in which also I fixed the displaying of AFK. Tongue
Logged

<<< Hack's in Zend Studio

All my Custom Bebot files may be Found Here <-clicky
Khalem
BeBot Founder
Administrator
Grandmaster
********
Offline Offline

Gender: Male
Posts: 670



WWW
Re: modified Online.php
« Reply #13 on: December 12, 2005, 09:50:25 PM »

Added to SVN
Logged

BeBot Founder and Fixer Kingpin
Madman coder and destroyer of good code
Xenixa
BeBot Contributor
Expert
*******
Offline Offline

Posts: 307



Re: modified Online.php
« Reply #14 on: January 12, 2006, 08:32:33 PM »

Just minor update to this Module to Keep guest list players from showing in the Members area of the Online list after they are added to the Guest List.

In side this function:
Code:
    /*
      This gets called if a buddy logs on/off
    */
    function buddy($name, $msg)
    {
      if ($this -> bot -> is_member($name))
      {
        if ($msg == 1)
          $this -> guild[$name] = $this -> whois($name);
         
        else if (isset($this -> guild[$name]))
          unset($this -> guild[$name]);
      }
    }
Change the if ($this -> bot -> is_member($name)) To read:
Code:
if ($this -> bot -> is_member($name) == 1)

Discovered when fixing auto invites.
Logged

<<< Hack's in Zend Studio

All my Custom Bebot files may be Found Here <-clicky
Pages: [1] 2 3   Go Up
Print
BeBot - An Anarchy Online/Age Of Conan chat automaton > Forum > Modules > Modules for older versions > 0.2.x Custom/Unofficial Modules > Topic: modified Online.php
« previous next »
 
Jump to:  

Recent
Change text in remember "...
by gerborg
[November 21, 2008, 05:14:57 PM]

Log playtime from buddys ...
by Temar
[November 20, 2008, 10:33:57 AM]

Vote Core module and Simp...
by Temar
[November 19, 2008, 09:26:52 AM]

Restrict access for one m...
by Organizer
[November 19, 2008, 03:21:19 AM]

Custom / Revised Modules ...
by Elesar1
[November 17, 2008, 03:51:46 PM]

TWC
by Temar
[November 16, 2008, 11:39:12 AM]

Are there any FUN modules...
by Elesar1
[November 15, 2008, 07:39:15 PM]

Call to a member function...
by exxie
[November 15, 2008, 09:29:31 AM]

Ported Modules
by Alreadythere
[November 14, 2008, 06:10:07 PM]

cURL and other non-defaul...
by Temar
[November 14, 2008, 04:11:44 PM]
Stats
Members
Total Members: 1235
Latest: DDDepressionnn
Stats
Total Posts: 11037
Total Topics: 1496
Online Today: 18
Online Ever: 168
(July 01, 2007, 09:30:02 PM)
Users Online
Users: 4
Guests: 17
Total: 21
xlDanek
Temar
Stealth
gerborg

Powered by SMF 1.1.7 | SMF © 2006-2008, Simple Machines LLC
TinyPortal v0.9.8 © Bloc | NewDef design by Bloc
Page created in 0.423 seconds with 29 queries. (Pretty URLs adds 0.047s, 4q)
Loading...