BeBot - An Anarchy Online and Age Of Conan chat automaton

Archive => Anarchy Online Archive => AO 0.6 support => Topic started by: Dochere on August 03, 2010, 01:56:52 pm

Title: Sharing memberlist with several bots.
Post by: Dochere on August 03, 2010, 01:56:52 pm
Heya!



I'm working on a project to run multiple bots, but where im now stuck where bots need to restart to see any member changes made in the database.

Instead of having 2 bots run on same tables and database prefix, i modified one of the bots to use same database but different table prefix, but read/write to the users table, points table and raid table.

I have found some sort of solution to this,  i recon it has with caching, as it caches users? Cause if i restart the bot it will work as intended. Vice-versa if i remove a user.


Heres and example:
Quote
Start Bot#1 and Bot#2

I add user Test on Bot#1.

I then try to do !join with test on Bot#2. I then get I only listen to members of this bot.

I then restart Bot#2 and try !join again. Works.

So lets say i remove a user. I then remove it from Bot#1 again.

Bot#2 will still think i am a member and i can do whatever i please as a member until the bot is restarted.


Anyone got any ideas how i can re-cache this information regularly?
Title: Re: Sharing memberlist with several bots.
Post by: Dochere on August 03, 2010, 11:21:28 pm
I've debugged my way into "Security.php" and "function get_access_level()" but i cant seem to find a way to work around the cached data. What i was thinking was rewirte it to do a sql query as a last statement in the check but this but its a dirty workaround not too well thought out, as im planning to expand with more bots in the future it will put the database under huge load, when just checking the user rights over and over.
Title: Re: Sharing memberlist with several bots.
Post by: Dochere on August 03, 2010, 11:32:07 pm
Yeey i found a solution.


At end for the function i add a sql that checks the user permissions, if it does not match the cache the cache is updated with new permissions.

This has a minor drawback. It will only update when it fails completely as in user not found in cache. If i remove a user on other bot cache will still remain on bot 2. Adding a cron to make sure it updates regularly.
Title: Re: Sharing memberlist with several bots.
Post by: Tyrence on August 03, 2010, 11:41:47 pm
it's probably caching that the bot is doing itself.  What I mean is, it probably loads a list of the members into memory so every time someone sends it a tell it doesn't have to hit the db.

So what you need to do is update the bot so it makes a call out to the db every time.

EDIT: Guess you figured that out already.  You posted while i was posting. :P

I am running into this same problem (how to link bots but still keep them from hitting the db every time).  It would be nice if there was a db proxy you could put in between the bot and mysql that would hold all the data in memory, and perform reads on the in-memory data, but still write to the disk.  And allow both bots to use the same in-memory instance.
Title: Re: Sharing memberlist with several bots.
Post by: Dochere on August 04, 2010, 12:11:59 am
Heres and absolute fix:



Line 206: AccessControl.php
Code: [Select]

// Checks if $user is allowed to use $command in the $channel, true if yes, false if no.
function check_rights($user, $command, $msg, $channel)
{


$this -> bot -> core("security") -> cache_security(); // Update the cache.


This will update the cache every time a user send a valid command to bot.

(I'll see over a few weeks how it performs, but from what I've tested myself its instant)

Oh yeah, this will also see if the user has been banned, deleted. Without the need for a cron task.
SimplePortal 2.3.7 © 2008-2024, SimplePortal