collapse collapse
* User Info
 
 
Welcome, Guest. Please login or register.
* Search

* Board Stats
  • stats Total Members: 989
  • stats Total Posts: 18365
  • stats Total Topics: 2500
  • stats Total Categories: 7
  • stats Total Boards: 35
  • stats Most Online: 1144

Author Topic: member command disconnecting bot  (Read 5399 times)

0 Members and 1 Guest are viewing this topic.

Offline Sabkor

  • Contributor
  • *******
  • Posts: 30
  • Karma: +0/-0
member command disconnecting bot
« 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).

Offline Ebag333

  • Contributor
  • *******
  • Posts: 134
  • Karma: +0/-0
Re: member command disconnecting bot
« Reply #1 on: August 22, 2007, 06:10:57 pm »
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).

Offline Temar

  • Contributor
  • *******
  • Posts: 1140
  • Karma: +0/-0
    • AoFiles
Re: member command disconnecting bot
« Reply #2 on: August 22, 2007, 06:18:06 pm »
[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
Quote
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

Offline Sabkor

  • Contributor
  • *******
  • Posts: 30
  • Karma: +0/-0
Re: member command disconnecting bot
« Reply #3 on: August 22, 2007, 08:00:40 pm »
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.

Offline Sabkor

  • Contributor
  • *******
  • Posts: 30
  • Karma: +0/-0
Re: member command disconnecting bot
« Reply #4 on: August 24, 2007, 01:48:38 am »
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.

Offline Temar

  • Contributor
  • *******
  • Posts: 1140
  • Karma: +0/-0
    • AoFiles
Re: member command disconnecting bot
« Reply #5 on: August 24, 2007, 02:02:23 am »
change -   
Code: [Select]
              echo "\nDEBUG: Send tell\n";

to

Code: [Select]
                echo "\nDEBUG: Send tell message = ".msg."\n";

than we can see wat the preg_match is checking and prob see the problem

Offline Sabkor

  • Contributor
  • *******
  • Posts: 30
  • Karma: +0/-0
Re: member command disconnecting bot
« Reply #6 on: August 24, 2007, 02:43:04 am »
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:

Code: [Select]
<?
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!

Offline Sabkor

  • Contributor
  • *******
  • Posts: 30
  • Karma: +0/-0
Re: member command disconnecting bot
« Reply #7 on: August 24, 2007, 04:57:36 am »
Yay!! Figured it out....

Thanks to 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:

Code: [Select]
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).

Offline Alreadythere

  • BeBot Maintainer
  • BeBot Hero
  • ******
  • Posts: 1288
  • Karma: +0/-0
Re: member command disconnecting bot
« Reply #8 on: August 24, 2007, 11:24:21 am »
Thanks for that info, think the worst that happens is an increased memory useage.

 

* Recent Posts
0.8.x updates for AO by bitnykk
[June 23, 2024, 03:19:47 pm ]


0.8.x updates for AoC by bitnykk
[June 23, 2024, 03:19:44 pm ]


[AoC] special char for items module by bitnykk
[February 09, 2024, 09:41:18 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: 398
  • 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