Code now functional - lots of error checking and extras missing still though

This commit is contained in:
Luke Fitzgerald 2010-07-20 11:16:59 -07:00
parent 1e5198645c
commit efdf9b6d4e
5 changed files with 38 additions and 21 deletions

View File

@ -33,10 +33,9 @@ if (!defined('STATUSNET')) {
// your code file can't be executed directly from the web.
exit(1);
}
// We bundle the Phergie library...
set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__) . '/extlib/phergie');
require 'Phergie/Autoload.php';
Phergie_Autoload::registerAutoloader();
/**
* Plugin for IRC
@ -50,9 +49,16 @@ Phergie_Autoload::registerAutoloader();
*/
class IrcPlugin extends ImPlugin {
public $user = null;
public $host = null;
public $port = null;
public $username = null;
public $realname = null;
public $nick = null;
public $password = null;
public $publicFeed = array();
public $nickservpassword = null;
public $channels = null;
public $transporttype = null;
public $encoding = null;
public $transport = 'irc';
@ -116,6 +122,10 @@ class IrcPlugin extends ImPlugin {
include_once $dir . '/'. $cls .'.php';
return false;
default:
if (substr($cls, 0, 7) == 'Phergie') {
include_once str_replace('_', DIRECTORY_SEPARATOR, $cls) . '.php';
return false;
}
return true;
}
}
@ -173,9 +183,6 @@ class IrcPlugin extends ImPlugin {
if (!isset($this->host)) {
throw new Exception('must specify a host');
}
if (!isset($this->port)) {
throw new Exception('must specify a port');
}
if (!isset($this->username)) {
throw new Exception('must specify a username');
}

View File

@ -13,14 +13,14 @@ See the StatusNet README for more about queuing and daemons.
Settings
========
host*: Hostname of IRC server
port*: Port of IRC server
port: Port of IRC server (defaults to 6667)
username*: Username of bot
realname*: Real name of bot
nick*: Nickname of bot
password: Password
nickservpassword: NickServ password for identification
channels: Channels for bot to idle in
transport: Set to 'ssl' to enable SSL
transporttype: Set to 'ssl' to enable SSL
encoding: Set to UTF8 to enable UTF8 encoding
* required
@ -29,7 +29,6 @@ Example
=======
addPlugin('irc', array(
'host' => '...',
'port' => '...',
'username' => '...',
'realname' => '...',
'nick' => '...',

View File

@ -25,7 +25,7 @@
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
* @link http://status.net/
*/
class Phergie_Extended_Bot extends Phergie_Bot {
class Phergie_ExtendedBot extends Phergie_Bot {
/**
* Set up bot and connect to servers
*
@ -53,7 +53,17 @@ class Phergie_Extended_Bot extends Phergie_Bot {
* @throws Phergie_Driver_Exception
*/
public function send($command, $args = '') {
$this->getDriver()->send($command, $args);
return $this->getDriver()->send($command, $args);
}
/**
* Handle incoming data on the socket using the handleEvents
* method of the Processor
*
* @return void
*/
public function receive() {
$this->getProcessor()->handleEvents();
}
/**

View File

@ -27,7 +27,7 @@
*/
class Phergie_Process_Statusnet extends Phergie_Process_Async {
public function __constuct(Phergie_Extended_Bot $bot, array $options) {
public function __construct(Phergie_ExtendedBot $bot, array $options) {
$this->usec = 0;
Phergie_Process_Abstract::__construct($bot, $options);
}

View File

@ -81,13 +81,14 @@ class IrcManager extends ImManager {
*/
public function connect() {
if (!$this->conn) {
$this->conn = new Phergie_Extended_Bot;
$this->conn = new Phergie_ExtendedBot;
$password = isset($this->plugin->password) ? $this->plugin->password : '';
$transport = isset($this->plugin->transport) ? $this->plugin->transport : 'tcp';
$encoding = isset($this->plugin->encoding) ? $this->plugin->encoding : 'ISO-8859-1';
$nickservpassword = isset($this->plugin->nickservpassword) ? $this->plugin->nickservpassword : '';
$channels = isset($this->plugin->channels) ? $this->plugin->channels : array();
$port = empty($this->plugin->port) ? 6667 : $this->plugin->port;
$password = empty($this->plugin->password) ? '' : $this->plugin->password;
$transport = empty($this->plugin->transporttype) ? 'tcp' : $this->plugin->transporttype;
$encoding = empty($this->plugin->encoding) ? 'ISO-8859-1' : $this->plugin->encoding;
$nickservpassword = empty($this->plugin->nickservpassword) ? '' : $this->plugin->nickservpassword;
$channels = empty($this->plugin->channels) ? array() : $this->plugin->channels;
$config = new Phergie_Config;
$config->readArray(
@ -95,10 +96,10 @@ class IrcManager extends ImManager {
'connections' => array(
array(
'host' => $this->plugin->host,
'port' => $this->plugin->port,
'port' => $port,
'username' => $this->plugin->username,
'realname' => $this->plugin->realname,
'nick' => $this->plugin->nickname,
'nick' => $this->plugin->nick,
'password' => $password,
'transport' => $transport,
'encoding' => $encoding