Bot responds to channel commands via PM

This commit is contained in:
Luke Fitzgerald 2010-08-05 10:48:15 -07:00
parent cb34d95197
commit 1f3dbe1198
3 changed files with 12 additions and 17 deletions

View 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;
}

View File

@ -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));
}
}

View 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.
*