collapse collapse
* User Info
 
 
Welcome, Guest. Please login or register.
* Search

* Board Stats
  • stats Total Members: 989
  • stats Total Posts: 18366
  • stats Total Topics: 2501
  • stats Total Categories: 7
  • stats Total Boards: 35
  • stats Most Online: 1144

Author Topic: an added fuction to !online  (Read 7813 times)

0 Members and 1 Guest are viewing this topic.

Offline Nytridr

  • BeBot Expert
  • ****
  • Posts: 262
  • Karma: +0/-0
    • Rising Sun
an added fuction to !online
« on: January 22, 2007, 08:20:54 pm »
OKay I would like to get another thing added to !online   I would love to see it where mulitple BeBots would update each others database so to speak with there online members.. I am in a 5 org alliance and we are all in the process of switching over to bebot from ign.. and what I would like to see is when someone does !online it would of course show who is on in the org its self.. but it would queary the other bots where they would show there online also.. since you can request onlines through tells I dont see how this could be a problem.. just have to let the bot pass it on to the org channel
Co-Prez of Rising Sun RK1 (1st & only org I will ever belong to)

Offline Malosar

  • BeBot Expert
  • ****
  • Posts: 259
  • Karma: +0/-0
    • http://www.lowerdimension.com
Re: an added fuction to !online
« Reply #1 on: January 22, 2007, 08:38:10 pm »
Bebot online system uses an array of online buddies to form that list. I am not sure but I think someone created and/or they were moving towards a dynamic db based online list where this would be possible. Without a db form for the online list it can't really be done cleanly.
Eternalist
General of The Syndicate

Offline Khalem

  • BeBot Founder
  • Administrator
  • ********
  • Posts: 1169
  • Karma: +0/-0
    • http://www.ancarim.com
Re: an added fuction to !online
« Reply #2 on: January 23, 2007, 11:00:11 pm »
The current SVN version supports this, but it is experimental and last time i looked, not yet finished.

Basically SVN version supports sharing databases using table prefixes, and by omitting prefix for some tables you get shared tables which is currently used for Whois cache as well as the new database stored Online module.
BeBot Founder and Fixer Kingpin

Offline Nytridr

  • BeBot Expert
  • ****
  • Posts: 262
  • Karma: +0/-0
    • Rising Sun
Re: an added fuction to !online
« Reply #3 on: January 24, 2007, 05:28:42 am »
here is my delema:  i am a member of a 6 org alliance and soon to be 7.  now we r all switching from ign to bebot.  and we would like to see everyone online in all orgs.  we have tried a shared online database but that was way to slow
 here is my idea.. 

 i would like to have each bot take care of there own online list in there own database.. 

how can this be done??  well i have an idea...   . 

have a new interface !online setup   that well allow u to add bots to the database as friend bots that will recive and send online information... 
with that said..
 have each bot send a tell to the others any time the online list changes..  now if nothing has been  recived by a bot in say 5 mins then it would request an update..

sending bot      tell out    !onlineupdate  player1, player2, player3

reciving bot      tell inc    !onlineupdate  player1, player2, player3

bot would get there info and add them to the online database..

player dose !online they would see there own org online plus Player1, 2, and 3 plus after there name what org they are in




Nytridr
« Last Edit: January 24, 2007, 09:58:23 am by Nytridr »
Co-Prez of Rising Sun RK1 (1st & only org I will ever belong to)

Offline jjones666

  • Contributor
  • *******
  • Posts: 353
  • Karma: +0/-0
Re: an added fuction to !online
« Reply #4 on: January 24, 2007, 11:54:12 am »
Set up a raidbot, use Glara's addallorgs plugin to add all seven orgs to the roster, then create a plugin to just show who is online (have a look at my modified admin plugin which does similar with the admin list).

Thats a quick and easy way to do it.

-jj-


Offline Malosar

  • BeBot Expert
  • ****
  • Posts: 259
  • Karma: +0/-0
    • http://www.lowerdimension.com
Re: an added fuction to !online
« Reply #5 on: January 24, 2007, 02:02:25 pm »
If all the bots are on the same server then an online database would easily be the fastest solution possible.
Eternalist
General of The Syndicate

Offline Glarawyn

  • BeBot Hero
  • ******
  • Posts: 521
  • Karma: +0/-0
Re: an added fuction to !online
« Reply #6 on: January 24, 2007, 05:57:28 pm »
Set up a raidbot, use Glara's addallorgs plugin to add all seven orgs to the roster, then create a plugin to just show who is online (have a look at my modified admin plugin which does similar with the admin list).

Thats a quick and easy way to do it.

-jj-



Depends on the size of the orgs involved. If the total membership of all 7 orgs is less than 1,000 no worries.

I setup my OrgRaidRoster module to only add members that are over 180. (I think this feature is in the released version?) This worked fine and kept the buddy list under 1,000.

Then I modified the default Online.php to always show everyone who is online. Finally I rearranged the Online window to show people who were in the bots channel first, then display everyone who was online. I also changed some of the wording around. As an added bonus, I added a list command to list everyone who is on the bot channel.

This isn't really release worthy. I use whois cache on all my bots, so I just modded this for a bot that has the whois cache module installed instead of detecting whois cache and falling back to normal whois methods if it's not present. Odds are good that there are other similar issues, but this is what I did with Online for our multiorg raidbot:

Code: [Select]
<?
/*
* 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: 2006-08-29 20:27:13 +0200 (Tue, 29 Aug 2006) $
* Revision: $Id: Online.php 227 2006-08-29 18:27:13Z shadowmaster $
*
* Modified by Glarawyn to have list mode!
*
*/


$online = new Online($bot);


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

$commands["tell"]["list"] = &$online;
$commands["pgmsg"]["list"] = &$online;
$commands["gc"]["list"] = &$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)
    { // Start function tell()
        $reply = $this -> handler($name, $msg, "tell");
        if ($reply <> FALSE)
            $this -> bot -> send_tell($name, $reply);
    } // End function tell()
   
    /*
    This gets called on a tell with the command from person outside guild
    */
    function tell2($name, $msg)
    { // Start function tell2()
        $reply = $this -> handler($name, $msg. "tell");
        if ($reply <> FALSE)
            $this -> bot -> send_tell($name, $reply);
    } // End function tell2()
   
    /*
    This gets called on a msg in the privgroup with the command
    */
    function pgmsg($name, $msg)
    { // Start function pgmsg()
        $reply = $this -> handler($name, $msg, "pgmsg");
        if ($reply <> FALSE)
            $this -> bot -> send_pgroup($reply);
    } // End function pgmsg()
   
    /*
    This gets called on a msg in the guildchat with the command
    */
    function gc($name, $msg)
    { // Start function gc()
        $reply = $this -> handler($name, $msg, "gc");
        if ($reply <> FALSE)
            $this -> bot -> send_gc($reply);
    } // End function gc()

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

    /*
    This function handles all the inputs and returns FALSE if the
    handler should not send output, otherwise returns a string
    sutible for output via send_tell, send_pgroup, and send_gc.
   
    */
    function handler($name, $msg, $source)
    { // Start function handler()
        if (preg_match("/^" . $this -> bot -> commpre . "online.*$/i", $msg, $info)) // Old School
        {
            $disponline = "both";
            return $this -> online_msg($msg, $disponline);
        }
        else if (preg_match("/^" . $this -> bot -> commpre . "list$/i", $msg, $info))
        {
            return $this -> online_list($name, $source);
        }
        else
            $this -> bot -> send_help($name);
    } // End function handler()

    /*
    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_window($this -> guild, $info[1]);
        $pgroup = $this -> online_window($this -> pgroup, $info[1]);

        $online = "";
        $msg = "";

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



        $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 -> whois -> lookup($name);
            $result[0] = $name;
            $result[1] = $content['level'];
            $result[2] = $content['org'];
            $result[3] = $content['profession'];
            $result[4] = $this -> bot -> aoc -> get_uid($name);
        }
        else
        $result = $result[0];

        if (empty($result[3]))
        $result[3] = "Unknown";
        if (empty($result[1]))
        $result[1] = "?";

        $result[5] = "none";

        return $result;
    }

    /*
    make the list of online players
    */
    function online_window($online, $like)
    {
        $prof_based = "";
        $online_window = "";
        $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_window .= "\n<font color=CCInfoHeader>" . $key . "</font>\n";
                    ksort($prof);
                    foreach ($prof as $player)
                    {
                        $online_num++;
                        $main = $this -> bot -> alts -> main($player[4]);
                        $alts = $this -> bot -> alts -> get_alts($main);
                        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[5] != "none" && !empty($player[5]))
                        $chatclient = "(" . $player[5] . ") ";
                        else
                        $chatclient = "";
                        $online_window .= "<font color=CCCCTextColor> - Lvl " . $player[1] . " <font color=CCInfoText>" . $player[0] . "</font> (" . $player[2] . ") " . $chatclient . $alts . "</font>\n";
                    }
                }
            }
        }

        return array($online_num, $online_window);
    }
   
    function online_list($name, $source)
    { // Start function online_list()
        $req = $this -> bot -> whois -> lookup($name);
        $conlevel = $req['level'];
        unset($req);
       
        if ($source == "pgmsg")
            $online = $this -> pgroup;
        else if ($source == "gc")
            $online = $this -> guild;
        else // Tell, figure it out based on $this -> bot -> guildbot
        {
            if ($this -> bot -> guildbot)
                $online = $this -> guild;
            else
                $online = $this -> pgroup;
        }
        if (empty($online))
            return "Nobody online.";
       
        $numonline = count($online);   
        $inside = $numonline." people online: ";
   
        // 0 nickname, 1 level, 2 org, 3 profession, 4 CharID
        ksort($online); // Should be alphabatized now.
        $lvlsort = array();
        foreach ($online as $player)
        {
            $player[5] = $this -> con2rgb($player[1], $conlevel);           
            $lvlsort[$player[1]][$player[0]] =  $player;
        }
        krsort($lvlsort);
        foreach ($lvlsort as $level)
        {
            foreach ($level as $char)
            {
                $inside .= "<font color=".$char[5].">".$char[0]."</font>, ";
            }
        }
        $inside = rtrim($inside, ", ");
        return $inside;
    } // End function online_list();       
   
    /*
        I stole this from Helpbot, and modified it to take a targetlevel
        and a requestor level instead of a percentage.     
        I also modified the return value to be just a HTML color code (#XXXXXX)     
        Thanks Beaker for this handy function! http://www.kuren.org/ao/helpbot/
       
        This function returns the color code of the color the hp bar that a
        player of requestorlevel would see for a player of targetlevel.
        ie:
        if requestorlevel is 220 and targetlevel is 5, a grey color code would be returned.
        if requestorlevel is 220 and targetlevel is 200, a greenish color code would be returned.
        if requesterlevel is 200 and targetlevel is 220, a orangish/redish color code would be returned.
        if requestorlevel and targetlevel are equal, a yello color code is returned.
    */       
    function con2rgb($targetlevel, $requestorlevel)
    { // Start function con2rgb()   
        $percent = $targetlevel/$requestorlevel*100.000001;
        $G = 214.0001-(($percent-100.0001)/100.0001)*4.0001*214.0001;
        if ($G<0)
            $G=0;
        elseif ($G>214)
            $G="D6";
        else
        {
            if ($G<16)
                $G=sprintf("0%X",$G);
            else
                $G=sprintf("%X",$G);
        }
   
        $R = 214.00001-(100.0001-$percent)*4.0001/100.0001*214.0001;
        if ($R<0)
            $R=0;
        elseif ($R>214)
            $R="D6";
        else
        {
            if ($R<16)
                $R=sprintf("0%X",$R);
            else
                $R=sprintf("%X",$R);
        }
        if ($percent<75.0001)
            return "#909090";
        if ($percent>124.9999)
            return "#D60000";
   
        return "#".$R.$G."00";
    } // End function con2rgb()

    /*
    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;
        }
    }
}
?>

Offline Nytridr

  • BeBot Expert
  • ****
  • Posts: 262
  • Karma: +0/-0
    • Rising Sun
Re: an added fuction to !online
« Reply #7 on: January 24, 2007, 08:35:07 pm »
Total members is close to 3k online people is easly under 1k but.. .. so that isnt a posbility.. and I dont want to add other org members into my bots personal database..  and running all org bots on one computer isnt an option, so..

The only options I can see is what I said above so far.. but I am no coder.. I can modify with out a problem.. (anyone can)  but putting together the code to do just what I want to above .. well I could start by taking a look at the GCR commands and stuff like that.. but I wouldnt know how to read in any of the information and populate the database to show them online.

I am learning but I think doing all that is above my scope of knollege of php atm.

I want all the differnt notify bots to beable to be listed and read out of the bot.conf file also, and I have yet to figure out how to do that one, with reading it in and so on.

Nytridr
« Last Edit: January 24, 2007, 11:27:37 pm by Nytridr »
Co-Prez of Rising Sun RK1 (1st & only org I will ever belong to)

Offline Scorth

  • BeBot Rookie
  • *
  • Posts: 1
  • Karma: +0/-0
Re: an added fuction to !online
« Reply #8 on: January 25, 2007, 04:19:45 am »
Quote
The current SVN version supports this, but it is experimental and last time i looked, not yet finished.

Basically SVN version supports sharing databases using table prefixes, and by omitting prefix for some tables you get shared tables which is currently used for Whois cache as well as the new database stored Online module.

I'm working with nytridr on this project.  I've tested out the svn version of online that reads from online db, and it works for the most part.  This module seems to be well on the way of supporting what we need to do with a multi-org alliance.  I was curious if it was still in development though.  It would be great if it was able to pull online users from the online table and list them according to org, which i believe would simply need an extra column "org_name". And of course getting the fancy mode from the old online would be great as well.  I have noticed that pulling from db like this returns a much quicker query than the previous !online did, especially when running from a remote db.  Sometimes query's could take up to 30sec when using the old online as opposed to the db version, so i'm really hoping this module continues development, it would really make multi-org alliances easier to connect

Offline Glarawyn

  • BeBot Hero
  • ******
  • Posts: 521
  • Karma: +0/-0
Re: an added fuction to !online
« Reply #9 on: January 25, 2007, 09:36:14 pm »
I'm suppose I'm still the owner of the online project in SVN. I'm still working on it, but it's not the highest thing on my priority list at the moment. Expect more updates in the coming weeks... :)

If you have anything you'd like to see in the new version, let us know now while we're developing.

For your situation, I could add a command that sends back a tell with the online list in some easy to parse format. Maybe XML in a text window, or a delimited list, etc...

Offline Wolfbiter

  • Contributor
  • *******
  • Posts: 149
  • Karma: +0/-0
    • KAZE
Re: an added fuction to !online
« Reply #10 on: January 25, 2007, 10:58:26 pm »
I have something similar on a bot I run, it just sends a tell to the other bot with who sent it, and if it's gc/tell/pgmsg, then the other bot replies in a set syntax with the same info and a list of people that are online "!command online WhoAskedForIt tell/gc/pgmsg player1 player2 player3 playerN" and then the first bot just foreach() the playerlist and fetches info from the whois table.
Too many toons.

Offline Nytridr

  • BeBot Expert
  • ****
  • Posts: 262
  • Karma: +0/-0
    • Rising Sun
Re: an added fuction to !online
« Reply #11 on: January 26, 2007, 12:53:28 am »

For your situation, I could add a command that sends back a tell with the online list in some easy to parse format. Maybe XML in a text window, or a delimited list, etc...

I think we are speaking the same here..   since tells are pretty quick and such.. but I have a sneak thought that getting tells back may take a bit to long.   unless I am missing what you are saying.

I would like to have things in such a way where

1 bot or 20 bots it wouldnt matter... would have to come up with something like gcr bots where we can list what bots we will send and recive from.

the !online would list in fancy mode  with org name listed.. btw, varchar  needs to be increased a bit.. 100 works good for our alliance since some have some pretty long org names.

here is the way I am kind of picturing how things could work, I know you will do what you think is right, just an idea.

org1,   Player123 logged on.
       botorg1 sees that player123 is on friends list and sees him log on, and sends a tell to all other bots.

botorg2  sees the tells and added the person to his friends list and now will show him online.
botorg3  sees the tells and added the person to his friends list and now will show him online.
botorg4 sees the tells and added the person to his friends list and now will show him online.
botorg5 sees the tells and added the person to his friends list and now will show him online.
botorg6 sees the tells and added the person to his friends list and now will show him online.
extra extra extra.

org1, player123 logged off
       botorg1  again sees this and sends a tell to the others and they remove them from friends list.



org1,  botorg1 at first start up.

botorg1 sends a tell with each person that is online and the other bots update there list.


IDK, how hard this would be to do.. but instead of having thousands of members on the bots friends list, this would keep it to a minium.

Nytridr

Co-Prez of Rising Sun RK1 (1st & only org I will ever belong to)

Offline Wolfbiter

  • Contributor
  • *******
  • Posts: 149
  • Karma: +0/-0
    • KAZE
Re: an added fuction to !online
« Reply #12 on: January 26, 2007, 01:44:31 am »
Problem with reliability on bot logon/off if bots keep info "live" instead of fetching when needing it. Yes, it will be slower if they have to ask for it, but it would be more reliable. Or if you can use a central database with remote access.
Too many toons.

Offline Nytridr

  • BeBot Expert
  • ****
  • Posts: 262
  • Karma: +0/-0
    • Rising Sun
Re: an added fuction to !online
« Reply #13 on: January 26, 2007, 02:17:45 am »
well if I could get everyone to connect to a remote database that would be feezable.. but the problems I have seen so far is that if the database goes down.. then the bot will not reconnect.   and the onlinedb is not really developed.. would love to see it looking like the normal online does with the org name just in text next to the name.. or so on.. to may outside varibles that the bot has no control over that could stop things.. and if the database goes down then all bots are down till it can be restarted.   

idk getting all the orgs to connect to one database may work.. just have to get htem all connected.

Nytridr
« Last Edit: January 26, 2007, 03:23:39 am by Nytridr »
Co-Prez of Rising Sun RK1 (1st & only org I will ever belong to)

Offline Nytridr

  • BeBot Expert
  • ****
  • Posts: 262
  • Karma: +0/-0
    • Rising Sun
Re: an added fuction to !online
« Reply #14 on: January 28, 2007, 05:59:32 am »
I have something similar on a bot I run, it just sends a tell to the other bot with who sent it, and if it's gc/tell/pgmsg, then the other bot replies in a set syntax with the same info and a list of people that are online "!command online WhoAskedForIt tell/gc/pgmsg player1 player2 player3 playerN" and then the first bot just foreach() the playerlist and fetches info from the whois table.

Would this work with 5 or 6 differnt bots? if so can I get it from ya..

Nytridr
Co-Prez of Rising Sun RK1 (1st & only org I will ever belong to)

 

* Recent Posts
Com bot module by bitnykk
[November 25, 2024, 05:36:11 pm ]


0.8.x updates for AO by bitnykk
[June 23, 2024, 03:19:47 pm ]


0.8.x updates for AoC by bitnykk
[June 23, 2024, 03:19:44 pm ]


[AoC] special char for items module by bitnykk
[February 09, 2024, 09:41:18 pm ]


BeBot still alive & kicking ! by bitnykk
[December 17, 2023, 12:58:44 am ]

* Who's Online
  • Dot Guests: 345
  • 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