BeBot - An Anarchy Online and Age Of Conan chat automaton
Archive => Anarchy Online Archive => BeBot 0.4 support => Topic started by: Sabkor on August 21, 2007, 10:50:26 pm
-
When the member command is executed on our new version of the bot (v0.4.1), the bot immediately gets disconnected, and then reconnects after the 60 second timeout.
To me, it seems like the bot is not splitting the outgoing tell, so just ends up with a huge blob that causes the chat server to drop it. I don't know why this would happen with just this one command and I thought before I started slogging through code, I'd see if someone else had any ideas. Here's my log, showing that everything is all in one blob:
[2007-08-21 20:38:55] [TELL] [INC] Sabkor: !member
[2007-08-21 20:38:56] [TELL] [OUT] -> Sabkor: 840 members in Cobot :: [link]click to view[/link]
I decreased max_blobsize in configuration file from 12000 to 6000, with the same results (bot getting disconnected).
-
Tried the trunk yet? (5.0)
It shouldn't be due to the blob size. It might be due to some invalid text (or a bad blob).
-
[2007-08-21 20:38:55] [TELL] [INC] Sabkor: !member
[2007-08-21 20:38:56] [TELL] [OUT] -> Sabkor: 840 members in Cobot :: [link]click to view[/link]
normaly the out is like
560 members in Leetboss2 :: click to view (page 1 of 7)
and same for rest of pages
i noticed u dont have a page thing so maybe it is going all into 1
-
Yeah, that's what I'm trying to find the solution to, Temar. For some reason, the members list is not being automatically split into proper blob sizes... I modified the members to dump to a file instead of sending to a /tell. It's a 97KB file, and for some reason (as shown by my log) BeBot is attempting to send it all in one blob, instead of splitting it out to pages, and I don't understand why.
-
I redownloaded v0.4.1 and re-extracted bot.php and roster.php, just in case... Didn't work...
I added the following lines in the send_tell() function in bot.php:
echo "\nDEBUG: Send tell\n";
if (preg_match("/<a href=\"(.+)\">/isU", $msg, $info))
{
echo "\nDEBUG: Inside preg_match\n";
if (strlen($info[1]) > $this -> maxsize)
{
echo "\nDEBUG: Inside maxsize\n";
$this -> cut_size($msg, "tell", $to, $low);
$send = false;
}
}
and here's the output I get now:
Cobot [2007-08-23 23:45:58] [TELL] [INC] Sabkor: !member
DEBUG: Send tell
Cobot [2007-08-23 23:45:59] [TELL] [OUT] -> Sabkor: 842 members in Cobot :: [link]click to view[/link]
So, for some reason, the regex is not matching on mine and therefore, not splitting it. Attempts to send as a HUGE blob and chokes. Still investigating to figure out why.
-
change -
echo "\nDEBUG: Send tell\n";
to
echo "\nDEBUG: Send tell message = ".msg."\n";
than we can see wat the preg_match is checking and prob see the problem
-
I have the message file if you like, but it's huge... I'll attach it here. Some more information on this... I created the following script and ran it against the dump file that I created:
<?
function cut_size($msg, $type, $to="", $pri=0)
{
preg_match("/^(.*)<a href=\"(.+)\">(.*)$/isU", $msg, $info);
$info[2] = str_replace("<br>","\n",$info[2]);
$content = explode("\n", $info[2]);
$page = 0;
$result[$page] = "";
echo $msg;
foreach($content as $line)
{
if ((strlen($result[$page]) + strlen($line) + 12) < 6000)
$result[$page] .= $line . "\n";
else
{
$page++;
$result[$page] .= $line . "\n";
}
}
$between = "";
for ($i = 0; $i <= $page; $i++)
{
if ($i != 0) $between = "text://";
$msg = $info[1] . "<a href=\"" . $between . $result[$i] . "\">" . $info[3] .
" <font color=#ffffff>(page ".($i+1)." of ".($page+1).")</font>";
echo "\nTell: ".($i+1)." of ".($page+1);
//echo "\nTell: \n".$msg;
if ($i != $page) sleep((int)(6000 * 0.0006));
}
}
$filename = "C:\\GuildBOT\\BeBot\\membersdump.txt";
$handle = fopen($filename, "r");
$msg = fread($handle, filesize($filename));
echo strlen($msg);
if (preg_match("/<a href=\"(.+)\">/isU", $msg, $info)) {
echo "regX match\n";
//echo "Array info element [1]: " . $info[1];
} else
echo "no regX match";
if (strlen($info[1]) > 6000)
{
cut_size($msg, "tell", "", 0);
$send = false;
}
?>
So it should just open my dump file, attempt to regex it, and then split it, if it works, output the page numbers on my screen. The regex fails when it is passed the entire dump file. But if I remove most of the data from it manually (over half the users), it works fine. Does anyone know if the preg_match function has a limit to the size of the passed in string?
NOTES for attached dump file. I modified the roster member function to output <br> instead of \n, as when dumped to a file, \n actually becomes the CRLF.
I also attached both copies of the files that I was using to test, the one in the "doesn't" folder is the one I'm having trouble with, the "works" one, is the exact same file, just with a bunch of the members manually removed from the file.
Thanks for any ideas!
-
Yay!! Figured it out....
Thanks to http://ca3.php.net/manual/en/function.preg-last-error.php (http://ca3.php.net/manual/en/function.preg-last-error.php), I used that function, which returns a 2 after bombing, which is PREG_BACKTRACK_LIMIT_ERROR. Putting the following configuration line in the php.ini file, it now works:
pcre.backtrack_limit=1000000
This increases the backtrack limit by 10 times (and doesn't seem to adversely affect the length of time it takes to run).
-
Thanks for that info, think the worst that happens is an increased memory useage.