]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Code now functional - lots of error checking and extras missing still though
authorLuke Fitzgerald <lw.fitzgerald@googlemail.com>
Tue, 20 Jul 2010 18:16:59 +0000 (11:16 -0700)
committerLuke Fitzgerald <lw.fitzgerald@googlemail.com>
Tue, 20 Jul 2010 18:16:59 +0000 (11:16 -0700)
plugins/Irc/IrcPlugin.php
plugins/Irc/README
plugins/Irc/extlib/phergie/Phergie/ExtendedBot.php
plugins/Irc/extlib/phergie/Phergie/Process/Statusnet.php
plugins/Irc/ircmanager.php

index 0422a6389bb72221ba938b4ddac1d7fca78f2ab6..a9044df8d250301d960c2a0eb0b2e27eb12903d8 100644 (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');
         }
index bed57e1e4580a7b314545aee68197c4242e3ba80..5b86a0449931fd2a4ae3d8d69a3a874c0c3145dc 100644 (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' => '...',
index 32bb8bad379ddc99bb3c689cd09dc1317e7d3811..113bb8b51bccd52e106f643beffcfef55dc1cb36 100644 (file)
@@ -25,7 +25,7 @@
  * @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
@@ -53,7 +53,17 @@ class Phergie_Extended_Bot extends Phergie_Bot {
     * @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
index c5999956b3f3e40671eb9f245d0e1fe4b131b0ce..672e6f610b663d610b562a4fe7e457f68aec5a59 100644 (file)
@@ -27,7 +27,7 @@
  */\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
index 549936ae7b486bb9812322a51152d6e1975b247d..2157964f614bcc575746502ce3561b0ed556a332 100644 (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