# HG changeset patch # User Dan # Date 1228657554 18000 # Node ID d751247002594e7ae882603016d70ef21e5741ae # Parent 2cfcd2801e5a4809dc3c94f6b4f40226027b95a0 Timeout recovery should avoid getting the bot throttled now :) diff -r 2cfcd2801e5a -r d75124700259 enanobot.php --- a/enanobot.php Sun Dec 07 01:55:03 2008 -0500 +++ b/enanobot.php Sun Dec 07 08:45:54 2008 -0500 @@ -175,7 +175,7 @@ } $part_cache = array(); } - else if ( in_array($message['nick'], $privileged_list) && preg_match('/^Shutdown(?: (.+))$/i', $message['message'], $match) && $message['action'] == 'PRIVMSG' ) + else if ( in_array($message['nick'], $privileged_list) && preg_match('/^Shutdown(?: (.+))?$/i', $message['message'], $match) && $message['action'] == 'PRIVMSG' ) { $GLOBALS['_shutdown'] = true; $quitmessage = empty($match[1]) ? "Remote bot shutdown ordered by {$message['nick']}" : $match[1]; @@ -195,7 +195,7 @@ function enanobot_timeout_event($irc) { // uh-oh. - $irc->close(); + $irc->close('client ping timeout (restarting connection)'); if ( defined('LIBIRC_DEBUG') ) { $now = date('r'); @@ -220,9 +220,11 @@ if ( defined('LIBIRC_DEBUG') ) { $now = date('r'); - echo "!!! [$now] Reconnection succesful, ghosting old login\n"; + echo "!!! [$now] Reconnection successful, ghosting old login (waiting 5 seconds to avoid throttling)\n"; } + fputs($conn, "QUIT :This bot needs better exception handling. But until then I'm going to need to make repeated TCP connection attempts when my ISP craps out. Sorry :-/\r\n"); fclose($conn); + sleep(5); break; } else diff -r 2cfcd2801e5a -r d75124700259 libirc.php --- a/libirc.php Sun Dec 07 01:55:03 2008 -0500 +++ b/libirc.php Sun Dec 07 08:45:54 2008 -0500 @@ -424,7 +424,7 @@ $this->quitted = true; // Part all channels if ( !$partmsg ) - $partmsg = 'IRC bot powered by PHP/' . PHP_VERSION . ' libirc/' . REQUEST_IRC_VERSION; + $partmsg = 'Closing connection (no reason given)'; foreach ( $this->channels as $channel ) {