]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Bot responds to channel commands via PM
authorLuke Fitzgerald <lw.fitzgerald@googlemail.com>
Thu, 5 Aug 2010 17:48:15 +0000 (10:48 -0700)
committerLuke Fitzgerald <lw.fitzgerald@googlemail.com>
Thu, 5 Aug 2010 17:48:41 +0000 (10:48 -0700)
plugins/Irc/IrcPlugin.php
plugins/Irc/extlib/phergie/Phergie/Plugin/Statusnet.php
plugins/Irc/ircmanager.php

index 855aa3305ede9e87ae0e22271456bfb5bb82b6b8..5b5cab2ec5f82fecf9d495a63bde97ffe7df7a80 100644 (file)
@@ -179,7 +179,16 @@ class IrcPlugin extends ImPlugin {
      * @return true if processing completed, false if message should be reprocessed
      */
     public function receive_raw_message($data) {
-        $this->handle_incoming($data['sender'], $data['message']);
+        if (strpos($data['source'], '#') === 0) {
+            $message = $data['message'];
+            $nickpos = strpos($message, $this->nick);
+            $colonpos = strpos($message, ':', $nickpos);
+            if ($nickpos === 0 && $colonpos == strlen($this->nick)) {
+                $this->handle_incoming($data['sender'], substr($message, $colonpos+1));
+            }
+        } else {
+            $this->handle_incoming($data['sender'], $data['message']);
+        }
         return true;
     }
 
index 694fefc06b0df27449d5ab659e71ea884323d7fa..ec2b427466119bd07556484a46f94432655b0e45 100644 (file)
@@ -72,9 +72,10 @@ class Phergie_Plugin_Statusnet extends Phergie_Plugin_Abstract {
         if ($this->messageCallback !== NULL) {\r
             $event = $this->getEvent();\r
             $source = $event->getSource();\r
+            $sender = $event->getNick();\r
             $message = trim($event->getText());\r
 \r
-            call_user_func($this->messageCallback, array('sender' => $source, 'message' => $message));\r
+            call_user_func($this->messageCallback, array('source' => $source, 'sender' => $sender, 'message' => $message));\r
         }\r
     }\r
 \r
index 51996bef9969595cccbe600ce15ea0fa4509304a..2ceb9db2c060f54dc8571c2fd61690ac17eeac51 100644 (file)
@@ -64,21 +64,6 @@ class IrcManager extends ImManager {
         }
     }
 
-    /**
-     * Idle processing for io manager's execution loop.
-     * Send keepalive pings to server.
-     *
-     * @return void
-     */
-    public function idle() {
-        // Call Phergie's doTick methods if necessary
-        try {
-            $this->conn->handleEvents();
-        } catch (Phergie_Driver_Exception $e) {
-            $this->conn->reconnect();
-        }
-    }
-
     /**
      * Process IRC events that have come in over the wire.
      *