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: Sharing memberlist with several bots.  (Read 1990 times)

0 Members and 1 Guest are viewing this topic.

Offline Dochere

  • BeBot User
  • **
  • Posts: 43
  • Karma: +0/-0
Sharing memberlist with several bots.
« 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?

Offline Dochere

  • BeBot User
  • **
  • Posts: 43
  • Karma: +0/-0
Re: Sharing memberlist with several bots.
« Reply #1 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.

Offline Dochere

  • BeBot User
  • **
  • Posts: 43
  • Karma: +0/-0
Re: Sharing memberlist with several bots.
« Reply #2 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.

Offline Tyrence

  • BeBot User
  • **
  • Posts: 41
  • Karma: +0/-0
Re: Sharing memberlist with several bots.
« Reply #3 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.

Offline Dochere

  • BeBot User
  • **
  • Posts: 43
  • Karma: +0/-0
Re: Sharing memberlist with several bots.
« Reply #4 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.
« Last Edit: August 04, 2010, 12:14:50 am by Dochere »

 

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