// 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
*/
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';
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;
}
}
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');
}
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
=======
addPlugin('irc', array(
'host' => '...',
- 'port' => '...',
'username' => '...',
'realname' => '...',
'nick' => '...',
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0\r
* @link http://status.net/\r
*/\r
-class Phergie_Extended_Bot extends Phergie_Bot {\r
+class Phergie_ExtendedBot extends Phergie_Bot {\r
/**\r
* Set up bot and connect to servers\r
*\r
* @throws Phergie_Driver_Exception\r
*/\r
public function send($command, $args = '') {\r
- $this->getDriver()->send($command, $args);\r
+ return $this->getDriver()->send($command, $args);\r
+ }\r
+\r
+ /**\r
+ * Handle incoming data on the socket using the handleEvents\r
+ * method of the Processor\r
+ *\r
+ * @return void\r
+ */\r
+ public function receive() {\r
+ $this->getProcessor()->handleEvents();\r
}\r
\r
/**\r
*/\r
\r
class Phergie_Process_Statusnet extends Phergie_Process_Async {\r
- public function __constuct(Phergie_Extended_Bot $bot, array $options) {\r
+ public function __construct(Phergie_ExtendedBot $bot, array $options) {\r
$this->usec = 0;\r
Phergie_Process_Abstract::__construct($bot, $options);\r
}\r
*/
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(
'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