From 1f3dbe11989a320be6f82e9d02e8c2dbd7b1cb4d Mon Sep 17 00:00:00 2001 From: Luke Fitzgerald Date: Thu, 5 Aug 2010 10:48:15 -0700 Subject: [PATCH] Bot responds to channel commands via PM --- plugins/Irc/IrcPlugin.php | 11 ++++++++++- .../extlib/phergie/Phergie/Plugin/Statusnet.php | 3 ++- plugins/Irc/ircmanager.php | 15 --------------- 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/plugins/Irc/IrcPlugin.php b/plugins/Irc/IrcPlugin.php index 855aa3305e..5b5cab2ec5 100644 --- a/plugins/Irc/IrcPlugin.php +++ b/plugins/Irc/IrcPlugin.php @@ -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; } diff --git a/plugins/Irc/extlib/phergie/Phergie/Plugin/Statusnet.php b/plugins/Irc/extlib/phergie/Phergie/Plugin/Statusnet.php index 694fefc06b..ec2b427466 100644 --- a/plugins/Irc/extlib/phergie/Phergie/Plugin/Statusnet.php +++ b/plugins/Irc/extlib/phergie/Phergie/Plugin/Statusnet.php @@ -72,9 +72,10 @@ class Phergie_Plugin_Statusnet extends Phergie_Plugin_Abstract { if ($this->messageCallback !== NULL) { $event = $this->getEvent(); $source = $event->getSource(); + $sender = $event->getNick(); $message = trim($event->getText()); - call_user_func($this->messageCallback, array('sender' => $source, 'message' => $message)); + call_user_func($this->messageCallback, array('source' => $source, 'sender' => $sender, 'message' => $message)); } } diff --git a/plugins/Irc/ircmanager.php b/plugins/Irc/ircmanager.php index 51996bef99..2ceb9db2c0 100644 --- a/plugins/Irc/ircmanager.php +++ b/plugins/Irc/ircmanager.php @@ -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. * -- 2.39.5