BeBot - An Anarchy Online and Age Of Conan chat automaton
Archive => Age of Conan Archive => AoC 0.6 support => Topic started by: GBH on November 12, 2010, 10:55:49 am
-
I get a huge number (probably 100+) of these types of entries when I restart or launch the bot
Sancbot [BUDDY QUEUE] [BUDDY-ADD] 17205641
Sancbot [BUDDY QUEUE] [BUDDY-ADD] 17242703
Sancbot [BUDDY QUEUE] [BUDDY-ADD] 17227432
Sancbot [BUDDY QUEUE] [BUDDY-ADD] 17208441
Along with names of characters I recognise and the infamous "-1" about 30 times.
Where is this list of entities to add to the buddy queue kept? I've gone through every file in the /bebot directory searching for the names or numbers and not found a single reference. I've also tried to step through the CHAT code to figure it out from there but it's beyond my PHP skills.
What I want to do is clear this queue out of entries so it's not wasting it's time trying to add characters that simply don't exist any more.
Anyone have any ideas?
G
-
Could this be the friends list of the bot character?
-
Well it might be but as far as I know, AoC doesn't cache an arbitrary list of buddies ready to add offline which it then tries to reapply when you're online does it? It would surely just fail the names/ID's that don't exist any more and just say the person doesn't exist as it does when you do it manually.
G
-
I did not write this part of the code, so not really sure about this one. And since I don't have a working AOC bot within an active guild It is very hard for me to debug this.
However if you open up core/Buddy_Queue.php and find the following function on line 74
function do_add($uid)
{
if (!empty($uid) && $uid != 0 && $uid != -1)
{
if (!($this -> bot -> core("chat") -> buddy_exists($uid)))
{
$this -> bot -> aoc -> buddy_add($uid);
$this -> bot -> log("BUDDY QUEUE", "BUDDY-ADD", $this -> bot -> core("chat") -> get_uname($uid));
}
}
else
{
$this -> bot -> log("BUDDY QUEUE", "BUDDY-ERROR", "Tried to add " . $this -> bot -> core("chat") -> get_uname($uid) . " as a buddy when they already are one.");
}
}
Change this to:
function do_add($uid)
{
if (!empty($uid) && $uid != 0 && $uid != -1)
{
if (!($this -> bot -> core("chat") -> buddy_exists($uid)))
{
$this->bot->log("DEBUG", "BuddyQueue", $this->bot->debug_bt());
$this -> bot -> aoc -> buddy_add($uid);
$this -> bot -> log("BUDDY QUEUE", "BUDDY-ADD", $this -> bot -> core("chat") -> get_uname($uid));
}
}
else
{
$this -> bot -> log("BUDDY QUEUE", "BUDDY-ERROR", "Tried to add " . $this -> bot -> core("chat") -> get_uname($uid) . " as a buddy when they already are one.");
}
}
In Sources/Bot.php add the following function at the bottom of the file (before the last closing } and ?>)
function debug_bt()
{
$trace = debug_backtrace();
$r = '';
foreach($trace as $i=>$call)
{
if (is_object($call['object']))
{
$call['object'] = 'CONVERTED OBJECT OF CLASS '.get_class($call['object']);
}
if (is_array($call['args']))
{
foreach ($call['args'] AS &$arg)
{
if (is_object($arg))
{
$arg = 'CONVERTED OBJECT OF CLASS '.get_class($arg);
}
}
}
$r .= "#" . $i . " " . (isset($call['file']) ? $call['file'] : '') . '(' . (isset($call['line']) ? $call['line'] : '' ) . ') ';
$r .= (!empty($call['object'])?$call['object'].$call['type']:'');
$r .= $call['function'].'('.implode(', ',$call['args']).')';
$r .= "\n";
}
return $r;
}
This is likely to create a fair amount of log spam, but it will give a backtrace showing where the actual add is originating from (hopefully) or at least get us one step closer.
Then please post a backtrace of an add you know is a broken UID either here or in a PM to me.
-
Made the changes, restarted the bot, didn't get anything at all. Is it being dumped into another file or something?
G
-
Ok for some reason, on one of the restarts I did this morning it seems to have worked (but only on 1)
I've included 2 of the "adds" here
Bot [BUDDY QUEUE] [BUDDY-ADD] 17168742
Bot [DEBUG] [BuddyQueue] #0 I:\Bebot\core\Buddy_Queue.php(80) CONVERTED OBJECT OF CLASS Bot->debug_bt()
#1 I:\Bebot\core\Buddy_Queue.php(117) CONVERTED OBJECT OF CLASS Buddy_Queue_Core->do_add(117502154)
#2 I:\Bebot\main\14_Queue.php(94) CONVERTED OBJECT OF CLASS Buddy_Queue_Core->queue(buddy, Array)
#3 I:\Bebot\Sources\Bot.php(1518) CONVERTED OBJECT OF CLASS Queue_Core->cron(1)
#4 I:\Bebot\Sources\Bot.php(1550) CONVERTED OBJECT OF CLASS Bot->cronjob(1289816785, 1)
#5 I:\Bebot\Main.php(483) CONVERTED OBJECT OF CLASS Bot->cron()
#6 () callback(20, Array, )
#7 I:\Bebot\Sources\AOChat.php(471) call_user_func(callback, 20, Array, )
#8 I:\Bebot\Sources\AOChat.php(1171) CONVERTED OBJECT OF CLASS AOChat->get_packet()
#9 I:\Bebot\Sources\AOChat.php(1194) CONVERTED OBJECT OF CLASS AOChat->lookup_user(Exiator)
#10 I:\Bebot\main\15_AOChatWrapper.php(71) CONVERTED OBJECT OF CLASS AOChat->get_uid(Exiator)
#11 I:\Bebot\core\aoc\Whois.php(324) CONVERTED OBJECT OF CLASS AOChatWrapper_Core->get_uid(Exiator)
#12 I:\Bebot\main\10_Roster.php(467) CONVERTED OBJECT OF CLASS Whois_Core->lookup(Exiator)
#13 I:\Bebot\main\10_Roster.php(217) CONVERTED OBJECT OF CLASS Roster_Core->update_guild()
#14 I:\Bebot\Sources\Bot.php(1518) CONVERTED OBJECT OF CLASS Roster_Core->cron(86400)
#15 I:\Bebot\Sources\Bot.php(1550) CONVERTED OBJECT OF CLASS Bot->cronjob(1289816770, 86400)
#16 I:\Bebot\Main.php(483) CONVERTED OBJECT OF CLASS Bot->cron()
#17 () callback(60, Array, )
#18 I:\Bebot\Sources\AOChat.php(471) call_user_func(callback, 60, Array, )
#19 I:\Bebot\Sources\AOChat.php(1171) CONVERTED OBJECT OF CLASS AOChat->get_packet()
#20 I:\Bebot\Sources\AOChat.php(1194) CONVERTED OBJECT OF CLASS AOChat->lookup_user(Sancbot)
#21 I:\Bebot\main\15_AOChatWrapper.php(71) CONVERTED OBJECT OF CLASS AOChat->get_uid(Sancbot)
#22 I:\Bebot\core\aoc\Whois.php(246) CONVERTED OBJECT OF CLASS AOChatWrapper_Core->get_uid(Sancbot)
#23 I:\Bebot\main\03_Security.php(1748) CONVERTED OBJECT OF CLASS Whois_Core->lookup(Sancbot)
#24 I:\Bebot\main\03_Security.php(2000) CONVERTED OBJECT OF CLASS Security_Core->set_government()
#25 I:\Bebot\main\03_Security.php(1958) CONVERTED OBJECT OF CLASS Security_Core->cache_org_ranks()
#26 I:\Bebot\main\03_Security.php(211) CONVERTED OBJECT OF CLASS Security_Core->cache_security()
#27 I:\Bebot\Sources\Bot.php(1518) CONVERTED OBJECT OF CLASS Security_Core->cron(43200)
#28 I:\Bebot\Sources\Bot.php(1550) CONVERTED OBJECT OF CLASS Bot->cronjob(1289816770, 43200)
#29 I:\Bebot\Main.php(483) CONVERTED OBJECT OF CLASS Bot->cron()
#30 () callback(60, Array, )
#31 I:\Bebot\Sources\AOChat.php(471) call_user_func(callback, 60, Array, )
#32 I:\Bebot\Sources\AOChat.php(302) CONVERTED OBJECT OF CLASS AOChat->get_packet()
#33 I:\Bebot\Main.php(469) CONVERTED OBJECT OF CLASS AOChat->wait_for_packet()
and
Bot [BUDDY QUEUE] [BUDDY-ADD] -1
Bot [DEBUG] [BuddyQueue] #0 I:\Bebot\core\Buddy_Queue.php(80) CONVERTED OBJECT OF CLASS Bot->debug_bt()
#1 I:\Bebot\core\Buddy_Queue.php(117) CONVERTED OBJECT OF CLASS Buddy_Queue_Core->do_add(17203975)
#2 I:\Bebot\main\14_Queue.php(94) CONVERTED OBJECT OF CLASS Buddy_Queue_Core->queue(buddy, Array)
#3 I:\Bebot\Sources\Bot.php(1518) CONVERTED OBJECT OF CLASS Queue_Core->cron(1)
#4 I:\Bebot\Sources\Bot.php(1550) CONVERTED OBJECT OF CLASS Bot->cronjob(1289816798, 1)
#5 I:\Bebot\Main.php(472) CONVERTED OBJECT OF CLASS Bot->cron()
They all seem to fall into one of these two types of response.
Any ideas?
G
-
Ok.
I am assuming here that Exiator is an deleted character?
If so I think I am forming an idea on how to properly deal with this issue.
-
Hi,
Yes he is - or rather a character who's now left the guild. I've not looked closely enough to figure out whether they all are but certainly it's the vast majority of them.
Buff
-
Did you get any joy with this?
G
-
I won't have time to formulate this into code until after my midterms, but I think I can eliminate some of these at least by altering how roster updates are done, as well as improving error handling as we really should not allow buddy adds for -1 to happen even if it should have been caught earlier.
-
Just adding a screeny of the startup at our end. We host two bots, and it's the same issue with both of them, the -1's that is. I've added the code where it removes the instances of -1's in the three tables that might get "infected", but yeah, buddy queue.. :)
(http://www.exalted-aoc.com/div/botstartup.JPG)
-
Thats Khalem. No hassle at all just thankful you're looking at it so whenever you can I can wait :)
@Runemy - At least it's not just me!
G
-
Was thinking though, can this somehow be relevant to the fact that I guildkick all chars that has been inactive for more than 30 days?
-
Was thinking though, can this somehow be relevant to the fact that I guildkick all chars that has been inactive for more than 30 days?
The -1 I don't think has anything to do with it. I do also guild kick anyone inactive for 30 days or more but thats doesn't seem to be the rootof it. People get -1 kicked or not kicked. It's also totally random and can even repair itself while people are actually online as -1.
Anyway I'm sure Khalem's on it when he gets time. All good :)
G
-
Hiya Khalem. No hassle just bringing this to the top of the pile.
Any movement with this?
Cheers
GBH
-
test this:
"!buddylist clear"
wait 5 minutes than:
"!rosterupdate"
should be help.....
-
"[BUDDY QUEUE] [BUDDY-ADD] -1"
This was first thing this morning.
It made absolutely no difference at all :)
G
-
The dumb/obvious question would be:
Do you have any entries in you bot's _users table with nickname '-1'?
With that out of the way...
Which version are you running?
My guess is that this problem is tied to the workaround in AOChat.php
Line 388-402 (approx).
case AOCP_CLIENT_LOOKUP :
list($id, $name) = $packet->args;
$id = "" . $id;
$name = ucfirst(strtolower($name));
// *** FIXME ***
// This is an ugly workaround for now to deal with overflowing 32bit int in Age of Conan
if ($id == 4294967295)
{
$id = -1;
}
$this->id[$id] = $name;
$this->id[$name] = $id;
break;
So.. the bot fails to find a valid id for a character and the workaround gives the character an id of -1.
So next time the bot looks for a character name, it returns id -1 and tries to add that during the rosterupdate.
But i'm kinda dumbfounded about that workaround actually.. why doesn't it modify the packet value as well, because 4294967295 will be passed back to the the function requesting the packet.
I modified my AOChat.php line 1205 (approx) to:
if($uid == -1 || $uid == 0 || $uid == 4294967295)
Without the above modification, I got a lot of these lines:
[BUDDY] [BUDDY-ADD] Received add request for (4294967295) This user is likely in the userlist and might need to be manually removed if this error persists.
-
The dumb/obvious question would be:
Do you have any entries in you bot's _users table with nickname '-1'?
With that out of the way...
Which version are you running?
My guess is that this problem is tied to the workaround in AOChat.php
Line 388-402 (approx).
case AOCP_CLIENT_LOOKUP :
list($id, $name) = $packet->args;
$id = "" . $id;
$name = ucfirst(strtolower($name));
// *** FIXME ***
// This is an ugly workaround for now to deal with overflowing 32bit int in Age of Conan
if ($id == 4294967295)
{
$id = -1;
}
$this->id[$id] = $name;
$this->id[$name] = $id;
break;
So.. the bot fails to find a valid id for a character and the workaround gives the character an id of -1.
So next time the bot looks for a character name, it returns id -1 and tries to add that during the rosterupdate.
But i'm kinda dumbfounded about that workaround actually.. why doesn't it modify the packet value as well, because 4294967295 will be passed back to the the function requesting the packet.
I modified my AOChat.php line 1205 (approx) to:
if($uid == -1 || $uid == 0 || $uid == 4294967295)
Without the above modification, I got a lot of these lines:
[BUDDY] [BUDDY-ADD] Received add request for (4294967295) This user is likely in the userlist and might need to be manually removed if this error persists.
I get random "-1"'s in the user, whois and online tables and I manually remove them using a database editor. The whois is the one that gets the -1 most often. I think it then propagates to the other tables.
It's 0.6.7 but has happened all the way back to 0.6.4 I think. Quite a while anyway. I don't think it's particularly relevant but I can happily update if theres a chance it will sort the problem.
Cheers for looking at it.
G
-
Just posted my UserAdmin module, perhaps it will help you clean up your bot's member base.
http://bebot.link/aoc-0-6-x-customunofficial-modules/useradmin-module-for-bebot/