Fixed irc bot reconnect if socket dies

This commit is contained in:
Juho Vanhanen
2015-10-06 01:24:44 +03:00
parent 434f75c919
commit 9ca61ffe90
+3 -2
View File
@@ -74,7 +74,6 @@ class ircbot {
$this->sql = $database_link; $this->sql = $database_link;
} }
$this->j = 2;
$this->config = $config; $this->config = $config;
$this->debug = $this->config['irc_debug']; $this->debug = $this->config['irc_debug'];
$this->config['irc_authtime'] = $this->config['irc_authtime'] ? $this->config['irc_authtime'] : 3; $this->config['irc_authtime'] = $this->config['irc_authtime'] ? $this->config['irc_authtime'] : 3;
@@ -150,6 +149,8 @@ class ircbot {
$this->connect_alert(); $this->connect_alert();
} }
$this->j = 2;
$this->connect(); $this->connect();
$this->log('Connected'); $this->log('Connected');
if ($this->pass) { if ($this->pass) {
@@ -159,7 +160,7 @@ class ircbot {
$this->doAuth(); $this->doAuth();
while (true) { while (true) {
foreach ($this->socket as $n => $socket) { foreach ($this->socket as $n => $socket) {
if (!is_resource($socket)) { if (!is_resource($socket) || feof($socket)) {
$this->log("Socket '$n' closed. Restarting."); $this->log("Socket '$n' closed. Restarting.");
break 2; break 2;
} }