BeBot - An Anarchy Online and Age Of Conan chat automaton
Development => Coding and development discussion => Topic started by: pusikas on April 04, 2007, 05:27:32 pm
-
Lately, I am getting some very strange behavior from the bot, and so far, I have been unable to pinpoint it. I posted in the !alts thread before, but that is probably the wrong place.
I am using a 2.11 bot with most of the modules that are confirmed to work from JJ's list.
The first thing is very annoying: Me (Luuv) gets my id in the members table set to 0 occasionally. This results in the bot crashing when I log on. If I delete the row and do a "!member del Luuv" and then a "!member Luuv", it works again - for a while.
The second thing is stranger, I noticed it with the new Alts-module that JJ posted, but the !is command gets confused as well. http://bebot.link/index.php/topic,204.msg5504.html#msg5504 (http://bebot.link/index.php/topic,204.msg5504.html#msg5504) shows some of my pain. :)
Another example: I have someone on guestlist that is not in org. Now check out the following crap and tell me why this happens:
[2007-04-04 15:15:52] [TELL] [INC] Luuv: !is ilikethongs
[2007-04-04 15:15:52] [BUDDY] [LOG] Ilikethongs logged [on] (guest)
[2007-04-04 15:15:52] [TELL] [OUT] -> Luuv: Ilikethongs is online
[2007-04-04 15:16:30] [TELL] [INC] Luuv: !is ilikethongs
[2007-04-04 15:16:30] [BUDDY] [ERROR] Ilikethongs logged on despite of already being marked as logged on!!
[2007-04-04 15:16:34] [TELL] [INC] Luuv: !is ilikethongs
[2007-04-04 15:16:34] [TELL] [OUT] -> Luuv: Ilikethongs is online
[2007-04-04 15:16:35] [TELL] [INC] Luuv: !is ilikethongs
[2007-04-04 15:16:35] [TELL] [OUT] -> Luuv: Ilikethongs is online
[2007-04-04 15:16:37] [TELL] [INC] Luuv: !is ilikethongs
[2007-04-04 15:16:37] [TELL] [OUT] -> Luuv: Ilikethongs is online
[2007-04-04 15:16:38] [TELL] [INC] Luuv: !is ilikethongs
[2007-04-04 15:16:38] [TELL] [OUT] -> Luuv: Ilikethongs is online
After that, the person logs off, and I get the following without stating another !is:
[2007-04-04 15:23:58] [BUDDY] [LOG] Ilikethongs logged [off] (guest)
[2007-04-04 15:23:58] [TELL] [OUT] -> Luuv: Ilikethongs is offline
So the first time I do !is, the bot notices a logon and tells me the guy is online. The second time, the bot complains that he is already logged on, but never tells me that he is online. Each time after that, ths !is command works ok. All the time, the !alts command shows him as offline.
I can't figure out when and why this started to happen. I can install a vanilla bot and see if it happens there as well. Any other ideas what I could try, or why this might happen? Looks to me like the problems come from the buddy functions in AOChat.php, but I never touched that file - I use the one that came with the 2.11 bot.
-
The first thing is very annoying: Me (Luuv) gets my id in the members table set to 0 occasionally. This results in the bot crashing when I log on. If I delete the row and do a "!member del Luuv" and then a "!member Luuv", it works again - for a while.
Could you get me the error that gets output to console/log when this happens as i'd like to fix the crash at the very least :)
I'm not quite sure where this actually occurs. But i think the best way to track it down would be to add a debug line to all instances in the bot where the id is potentially inserted into the database and output a warning to console/log with debug info.
The second thing is stranger, I noticed it with the new Alts-module that JJ posted, but the !is command gets confused as well. http://bebot.link/index.php/topic,204.msg5504.html#msg5504 (http://bebot.link/index.php/topic,204.msg5504.html#msg5504) shows some of my pain. :)
Another example: I have someone on guestlist that is not in org. Now check out the following crap and tell me why this happens:
[2007-04-04 15:15:52] [TELL] [INC] Luuv: !is ilikethongs
[2007-04-04 15:15:52] [BUDDY] [LOG] Ilikethongs logged [on] (guest)
[2007-04-04 15:15:52] [TELL] [OUT] -> Luuv: Ilikethongs is online
[2007-04-04 15:16:30] [TELL] [INC] Luuv: !is ilikethongs
[2007-04-04 15:16:30] [BUDDY] [ERROR] Ilikethongs logged on despite of already being marked as logged on!!
[2007-04-04 15:16:34] [TELL] [INC] Luuv: !is ilikethongs
[2007-04-04 15:16:34] [TELL] [OUT] -> Luuv: Ilikethongs is online
[2007-04-04 15:16:35] [TELL] [INC] Luuv: !is ilikethongs
[2007-04-04 15:16:35] [TELL] [OUT] -> Luuv: Ilikethongs is online
[2007-04-04 15:16:37] [TELL] [INC] Luuv: !is ilikethongs
[2007-04-04 15:16:37] [TELL] [OUT] -> Luuv: Ilikethongs is online
[2007-04-04 15:16:38] [TELL] [INC] Luuv: !is ilikethongs
[2007-04-04 15:16:38] [TELL] [OUT] -> Luuv: Ilikethongs is online
After that, the person logs off, and I get the following without stating another !is:
[2007-04-04 15:23:58] [BUDDY] [LOG] Ilikethongs logged [off] (guest)
[2007-04-04 15:23:58] [TELL] [OUT] -> Luuv: Ilikethongs is offline
So the first time I do !is, the bot notices a logon and tells me the guy is online. The second time, the bot complains that he is already logged on, but never tells me that he is online. Each time after that, ths !is command works ok. All the time, the !alts command shows him as offline.
I can't figure out when and why this started to happen. I can install a vanilla bot and see if it happens there as well. Any other ideas what I could try, or why this might happen? Looks to me like the problems come from the buddy functions in AOChat.php, but I never touched that file - I use the one that came with the 2.11 bot.
Ohh boy. I knew this would come back to bite me in the arse somehow.
Basically this is whats happening:
- Person logs on, gets tagged as logged on by the online cache
- !is is called for this person, adds the person as a buddy to generate a logged on/off event. Cache catches said event, throws a warning to console and never passes the event on to anything in the bot.
- !is sits and waits for the event which never arrives, until the person logs off and generates an event that is different from the cached event.
Although im a bit puzzled towards why you get a response to subsequent !is commands for the same person O.o
-
Could you get me the error that gets output to console/log when this happens as i'd like to fix the crash at the very least :)
I'm not quite sure where this actually occurs. But i think the best way to track it down would be to add a debug line to all instances in the bot where the id is potentially inserted into the database and output a warning to console/log with debug info.
The crash happens here:
[04-Apr-2007 17:00:51] PHP Fatal error: Cannot use string offset as an array in /usr/local/vbot/modules/Logon_GUILD.php on line 108
The line 108 looks like this:
$res .= " (Lvl <font color=#ffffff>" . $result[0][3] . "</font> / <font color=#00ff60>" . $result[0][6] . " (" . $result[0][7] . ")</font> <font color=#ffffff>" . $result[0][4] . "</font> " . $result[0][5] . ") logged on.";
I think that line is slightly modified, not the original anymore. But if I am not mistaken, the problem is this line:
$id = $this -> bot -> aoc -> get_uid($name);
That gets the "real" ID of the user logging on, not the one that is in the database (due to the default value of zero, it is 0 in the database). The following SELECT on the members table doesn't fetch any rows. But maybe I misinterpret the code here. No idea. :)
It hasn't happened to my own toons anymore. I inserted some debug messages and am hoping for the error that causes the 0 to be inserted into the ID column to come back. Well, I wouldn't mind if I never get it again, either. :)
Some sanity check on the SELECT might help, so that the logon message is surpressed if the SELECT returns no rows, and a message like "$name logged on, but his entry in the members table is faulty" as output.
Edit: I changed the Logon_GUILD.php a bit, so that it no longer crashes the bot when a toon with ID = 0 i nthe database logs on. Dunno if I am the only one with this problem, but still, here it is. :) Contains my own take on the colors for logons, so it may not be for everyone...
-
Try inserting a line above the one that is causing the error that reads
var_dump($result);
That should print out what $result contains. The error message indicates that it does not contain an array as is expected. (ie it might be NULL, FALSE or contain a string).
Hope that helps.
-
Reason why the bot crashes is clear - just update any character id with 0 in the database and see what happens when that person logs on. :)
What I do not understand is why the ID gets updated with zero in the first place. It has happened to my own toon twice and to one other toon in the org so far. I have added some debug code in the Roster_GUILD module where I suspect it may happen (I booby-trapped the area around the REPLACE command), but this crap hasnt occured again so far, so no news on that one. I am sitting here an HOPING for the bot messing it up again. That's new. :)
-
Crash fixed in SVN.
Improper error checking.
-
Small note on the !is problem.
The only real solution here is to rewrite !Is to take into account the cache as the cache is needed.
-
Sooo... nothing I can do, I guess. I do not even think I fully undersdtand what the problem is. ^^
-
Not unless we can figure out where and why it's inserting a 0.
I'll see if i can find some time to look over this once again and maybe add some error checking to avoid null id's from being entered in the first place. But 0.2.x is a mess.
-
Today the bot did it again, but a bit differently, which is why my booby-traps didnt fire. It did not REPLACE with zero - it just deleted me entirely.
[2007-04-10 03:08:16] [BUDDY] [ADD] 0
[2007-04-10 03:08:16] [BUDDY] [ADD] Younggunz
[2007-04-10 03:08:16] [BUDDY] [ADD] Miiii
[2007-04-10 03:08:16] [BUDDY] [DEL] Luuv
[2007-04-10 03:08:16] [ROSTER] [UPDATE] Luuv removed
[2007-04-10 03:08:16] [ROSTER] [UPDATE] Roster update complete. Added 3 members, removed 1.
WTH? Not only did it remove me for no apparent reason, it also added a member named "0". Way to go. I checked for PHP errors or warnings, and there were none in the logs around that time.
The whois-cache seems to work smoothly, I am currently thinking about just removing that roster update as it currently is and just copy over the relevant stuff form the whois-cache twice a day or so... is there any reason not to do it this way? Before I try that and find out the hard way, someone tell me please. :)
-
I use the cache 100% for our raidbot, it works fine.
-jj-
-
Yep, that works nicely so far, and is faster as well. :)
-
In the end, you may possibly get the same error, unless you keep the whois cache up to date. I'd not thought of doing this for the org, can you PM me with the code? :-)
-jj-
-
Curious. Could it be Funcom XML somehow screwing up? If my memory serves, nickname is taken directly from XML, which means in the XML version there should have been a member with the nickname 0. Bizarre.
-
Hmmm... what might have happened (didn't check the time) is that the Roster Update and the whois-cache update ran at the same time. They won't interfere directly, but accessing those FC pages isn't exactly fast from where I live. Didn't see any timeouts in the php-errorlog, tho. Also, I am sitting behind a transparent proxy - maybe it messed those requests up. But I Dunno how I should test THAT. Good news is, that I haven't had any more problems since I am updating the members table from the whois cache. If they did interfere before, they can't do that anymore, and I have never spotted any wrong entries in the cache.
!is and JJ's !alts command still are a bit unreliable, and spam my console with strange messages, but nothing I can't bear.