]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/Irc/extlib/phergie/Phergie/Driver/Streams.php
Revert "Merged in Phergie changes"
[quix0rs-gnu-social.git] / plugins / Irc / extlib / phergie / Phergie / Driver / Streams.php
index bb0c611aa38e032df3eb1ad10ac3279a3e3cc49a..3f2ce052b1fc780f60d2427881c73f001137d8d8 100755 (executable)
@@ -219,6 +219,14 @@ class Phergie_Driver_Streams extends Phergie_Driver_Abstract
      */
     public function getEvent()
     {
+        // Check the socket is still active
+        if (feof($this->socket)) {
+            throw new Phergie_Driver_Exception(
+                'EOF detected on socket',
+                Phergie_Driver_Exception::ERR_CONNECTION_READ_FAILED
+            );
+        }
+
         // Check for a new event on the current connection
         $buffer = fgets($this->socket, 512);
 
@@ -244,6 +252,8 @@ class Phergie_Driver_Streams extends Phergie_Driver_Abstract
                 = array_pad(explode(' ', ltrim($buffer, ':'), 3), 3, null);
             if (strpos($prefix, '@') !== false) {
                 $hostmask = Phergie_Hostmask::fromString($prefix);
+            } else {
+                $hostmask = new Phergie_Hostmask(null, null, $prefix);
             }
         }
 
@@ -261,8 +271,9 @@ class Phergie_Driver_Streams extends Phergie_Driver_Abstract
 
         case 'privmsg':
         case 'notice':
-            $ctcp = substr(strstr($args, ':'), 1);
-            if (substr($ctcp, 0, 1) === "\x01" && substr($ctcp, -1) === "\x01") {
+            $args = $this->parseArguments($args, 2);
+            list($source, $ctcp) = $args;
+            if (substr($ctcp, 0, 1) === "\001" && substr($ctcp, -1) === "\001") {
                 $ctcp = substr($ctcp, 1, -1);
                 $reply = ($cmd == 'notice');
                 list($cmd, $args) = array_pad(explode(' ', $ctcp, 2), 2, null);
@@ -283,7 +294,7 @@ class Phergie_Driver_Streams extends Phergie_Driver_Abstract
                     }
                     break;
                 case 'action':
-                    $args = array($this->getConnection()->getNick(), $args);
+                    $args = array($source, $args);
                     break;
 
                 default:
@@ -291,11 +302,9 @@ class Phergie_Driver_Streams extends Phergie_Driver_Abstract
                     if ($reply) {
                         $cmd .= 'Response';
                     }
-                    $args = array($this->getConnection()->getNick(), $ctcp);
+                    $args = array($source, $args);
                     break;
                 }
-            } else {
-                $args = $this->parseArguments($args, 2);
             }
             break;