forked from GNUsocial/gnu-social
Code now functional - lots of error checking and extras missing still though
This commit is contained in:
parent
1e5198645c
commit
efdf9b6d4e
@ -33,10 +33,9 @@ if (!defined('STATUSNET')) {
|
|||||||
// your code file can't be executed directly from the web.
|
// your code file can't be executed directly from the web.
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// We bundle the Phergie library...
|
// We bundle the Phergie library...
|
||||||
set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__) . '/extlib/phergie');
|
set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__) . '/extlib/phergie');
|
||||||
require 'Phergie/Autoload.php';
|
|
||||||
Phergie_Autoload::registerAutoloader();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plugin for IRC
|
* Plugin for IRC
|
||||||
@ -50,9 +49,16 @@ Phergie_Autoload::registerAutoloader();
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
class IrcPlugin extends ImPlugin {
|
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 $password = null;
|
||||||
public $publicFeed = array();
|
public $nickservpassword = null;
|
||||||
|
public $channels = null;
|
||||||
|
public $transporttype = null;
|
||||||
|
public $encoding = null;
|
||||||
|
|
||||||
public $transport = 'irc';
|
public $transport = 'irc';
|
||||||
|
|
||||||
@ -116,6 +122,10 @@ class IrcPlugin extends ImPlugin {
|
|||||||
include_once $dir . '/'. $cls .'.php';
|
include_once $dir . '/'. $cls .'.php';
|
||||||
return false;
|
return false;
|
||||||
default:
|
default:
|
||||||
|
if (substr($cls, 0, 7) == 'Phergie') {
|
||||||
|
include_once str_replace('_', DIRECTORY_SEPARATOR, $cls) . '.php';
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -173,9 +183,6 @@ class IrcPlugin extends ImPlugin {
|
|||||||
if (!isset($this->host)) {
|
if (!isset($this->host)) {
|
||||||
throw new Exception('must specify a host');
|
throw new Exception('must specify a host');
|
||||||
}
|
}
|
||||||
if (!isset($this->port)) {
|
|
||||||
throw new Exception('must specify a port');
|
|
||||||
}
|
|
||||||
if (!isset($this->username)) {
|
if (!isset($this->username)) {
|
||||||
throw new Exception('must specify a username');
|
throw new Exception('must specify a username');
|
||||||
}
|
}
|
||||||
|
@ -13,14 +13,14 @@ See the StatusNet README for more about queuing and daemons.
|
|||||||
Settings
|
Settings
|
||||||
========
|
========
|
||||||
host*: Hostname of IRC server
|
host*: Hostname of IRC server
|
||||||
port*: Port of IRC server
|
port: Port of IRC server (defaults to 6667)
|
||||||
username*: Username of bot
|
username*: Username of bot
|
||||||
realname*: Real name of bot
|
realname*: Real name of bot
|
||||||
nick*: Nickname of bot
|
nick*: Nickname of bot
|
||||||
password: Password
|
password: Password
|
||||||
nickservpassword: NickServ password for identification
|
nickservpassword: NickServ password for identification
|
||||||
channels: Channels for bot to idle in
|
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
|
encoding: Set to UTF8 to enable UTF8 encoding
|
||||||
|
|
||||||
* required
|
* required
|
||||||
@ -29,7 +29,6 @@ Example
|
|||||||
=======
|
=======
|
||||||
addPlugin('irc', array(
|
addPlugin('irc', array(
|
||||||
'host' => '...',
|
'host' => '...',
|
||||||
'port' => '...',
|
|
||||||
'username' => '...',
|
'username' => '...',
|
||||||
'realname' => '...',
|
'realname' => '...',
|
||||||
'nick' => '...',
|
'nick' => '...',
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
||||||
* @link http://status.net/
|
* @link http://status.net/
|
||||||
*/
|
*/
|
||||||
class Phergie_Extended_Bot extends Phergie_Bot {
|
class Phergie_ExtendedBot extends Phergie_Bot {
|
||||||
/**
|
/**
|
||||||
* Set up bot and connect to servers
|
* Set up bot and connect to servers
|
||||||
*
|
*
|
||||||
@ -53,7 +53,17 @@ class Phergie_Extended_Bot extends Phergie_Bot {
|
|||||||
* @throws Phergie_Driver_Exception
|
* @throws Phergie_Driver_Exception
|
||||||
*/
|
*/
|
||||||
public function send($command, $args = '') {
|
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
class Phergie_Process_Statusnet extends Phergie_Process_Async {
|
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;
|
$this->usec = 0;
|
||||||
Phergie_Process_Abstract::__construct($bot, $options);
|
Phergie_Process_Abstract::__construct($bot, $options);
|
||||||
}
|
}
|
||||||
|
@ -81,13 +81,14 @@ class IrcManager extends ImManager {
|
|||||||
*/
|
*/
|
||||||
public function connect() {
|
public function connect() {
|
||||||
if (!$this->conn) {
|
if (!$this->conn) {
|
||||||
$this->conn = new Phergie_Extended_Bot;
|
$this->conn = new Phergie_ExtendedBot;
|
||||||
|
|
||||||
$password = isset($this->plugin->password) ? $this->plugin->password : '';
|
$port = empty($this->plugin->port) ? 6667 : $this->plugin->port;
|
||||||
$transport = isset($this->plugin->transport) ? $this->plugin->transport : 'tcp';
|
$password = empty($this->plugin->password) ? '' : $this->plugin->password;
|
||||||
$encoding = isset($this->plugin->encoding) ? $this->plugin->encoding : 'ISO-8859-1';
|
$transport = empty($this->plugin->transporttype) ? 'tcp' : $this->plugin->transporttype;
|
||||||
$nickservpassword = isset($this->plugin->nickservpassword) ? $this->plugin->nickservpassword : '';
|
$encoding = empty($this->plugin->encoding) ? 'ISO-8859-1' : $this->plugin->encoding;
|
||||||
$channels = isset($this->plugin->channels) ? $this->plugin->channels : array();
|
$nickservpassword = empty($this->plugin->nickservpassword) ? '' : $this->plugin->nickservpassword;
|
||||||
|
$channels = empty($this->plugin->channels) ? array() : $this->plugin->channels;
|
||||||
|
|
||||||
$config = new Phergie_Config;
|
$config = new Phergie_Config;
|
||||||
$config->readArray(
|
$config->readArray(
|
||||||
@ -95,10 +96,10 @@ class IrcManager extends ImManager {
|
|||||||
'connections' => array(
|
'connections' => array(
|
||||||
array(
|
array(
|
||||||
'host' => $this->plugin->host,
|
'host' => $this->plugin->host,
|
||||||
'port' => $this->plugin->port,
|
'port' => $port,
|
||||||
'username' => $this->plugin->username,
|
'username' => $this->plugin->username,
|
||||||
'realname' => $this->plugin->realname,
|
'realname' => $this->plugin->realname,
|
||||||
'nick' => $this->plugin->nickname,
|
'nick' => $this->plugin->nick,
|
||||||
'password' => $password,
|
'password' => $password,
|
||||||
'transport' => $transport,
|
'transport' => $transport,
|
||||||
'encoding' => $encoding
|
'encoding' => $encoding
|
||||||
|
Loading…
Reference in New Issue
Block a user