BeBot - An Anarchy Online and Age Of Conan chat automaton

Archive => Anarchy Online Archive => BeBot 0.4 support => Topic started by: Civildeath on October 17, 2007, 09:24:39 am

Title: Split buddy list by alphabet letters
Post by: Civildeath on October 17, 2007, 09:24:39 am
Request:
Please help me with syntax in PHP so that the bot will only add members to the buddy list if they are in a certain range of the alphabet.  So like one bot would only add members to its buddy list if the members names started with A-G and another bot would only add names starting with H-Z. 

Background:
I'm trying to solve the over 1000 buddy list limit issue.  I already have two bots sharing an online table from two different orgs and that works great.  The problem is that one org is over 1000 members so some members don't get seen that are from that org (the bot toon starts getting errors from AO saying it has exceeded the buddy list limit.)  The org that is less then 1000 always shows up just fine in the shared online table though.  So sharing the online table between bots seems to effectively get around the 1000 limit.

Proposed solution:
I would like to use two bots for the org over 1000 members.  One of the bots would only keep track of A-G and the other bot would keep track of H-Z and then store the results in the online table.  I have been trying to figure out the logic/syntax in php to have the bots do this though.
Title: Re: Split buddy list by alphabet letters
Post by: Alreadythere on October 17, 2007, 11:52:14 am
preg_match("/^[a-g]/im", $name) and preg_match("/^[h-z]/im", $name) should be your friends.

Just one point, FC only shows 1k members in their XML, even if the org is much larger.
Title: Re: Split buddy list by alphabet letters
Post by: Glarawyn on October 17, 2007, 09:03:52 pm
I've solved the issue previously by tracking when the bot last saw user X.

On Campalot, if you haven't raided in the last 365 days the bot doesn't add you to the list. Campalot's highly customized BeBot 0.2 though, and the code shows the hackish state of things. ;)

In 0.4 the bot tracks last logon and logoffs, though if the user isn't on the roster they would have to speak in GC before the bot will see them...
Title: Re: Split buddy list by alphabet letters
Post by: Civildeath on October 18, 2007, 10:57:47 pm
Thanks for the tips ...

So I tried to qualify that people only get added if their name startes with A-M by putting an if statement around the buddy-add command.  It is still adding peoples who name start after M.  I am not sure why though ... I added in a staement to echo the regular expression and it is correctly returning the first letter of the name so it seems like the if statement should be filtering.

if (preg_match("/^[a-m]/im",$member["nickname"]))
{
     if (!$this -> bot -> aoc -> buddy_exists($member["id"]))
     {
     $this -> bot -> aoc -> buddy_add($member["id"]);
     $this -> bot -> log("ROSTER", "BUDDY-ADD", $member["nickname"]);
     }
}
Title: Re: Split buddy list by alphabet letters
Post by: Alreadythere on October 18, 2007, 11:17:28 pm
I think you have to adapt the notify module too, it defines which user stay in the buddy list.

Best check the code for buddy_add() calls in core, and perhaps in modules/Roster.php.
SimplePortal 2.3.7 © 2008-2025, SimplePortal