From: Luke Fitzgerald Date: Tue, 20 Jul 2010 18:16:59 +0000 (-0700) Subject: Code now functional - lots of error checking and extras missing still though X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=efdf9b6d4e3c6e8c4ce49a5d5f9e42658d1dc004;p=quix0rs-gnu-social.git Code now functional - lots of error checking and extras missing still though --- diff --git a/plugins/Irc/IrcPlugin.php b/plugins/Irc/IrcPlugin.php index 0422a6389b..a9044df8d2 100644 --- a/plugins/Irc/IrcPlugin.php +++ b/plugins/Irc/IrcPlugin.php @@ -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'); } diff --git a/plugins/Irc/README b/plugins/Irc/README index bed57e1e45..5b86a04499 100644 --- a/plugins/Irc/README +++ b/plugins/Irc/README @@ -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' => '...', diff --git a/plugins/Irc/extlib/phergie/Phergie/ExtendedBot.php b/plugins/Irc/extlib/phergie/Phergie/ExtendedBot.php index 32bb8bad37..113bb8b51b 100644 --- a/plugins/Irc/extlib/phergie/Phergie/ExtendedBot.php +++ b/plugins/Irc/extlib/phergie/Phergie/ExtendedBot.php @@ -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(); } /** diff --git a/plugins/Irc/extlib/phergie/Phergie/Process/Statusnet.php b/plugins/Irc/extlib/phergie/Phergie/Process/Statusnet.php index c5999956b3..672e6f610b 100644 --- a/plugins/Irc/extlib/phergie/Phergie/Process/Statusnet.php +++ b/plugins/Irc/extlib/phergie/Phergie/Process/Statusnet.php @@ -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); } diff --git a/plugins/Irc/ircmanager.php b/plugins/Irc/ircmanager.php index 549936ae7b..2157964f61 100644 --- a/plugins/Irc/ircmanager.php +++ b/plugins/Irc/ircmanager.php @@ -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