Added more commenting
This commit is contained in:
parent
a9d9e077ba
commit
067633a608
|
@ -35,11 +35,25 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
|
|||
class ChannelResponseChannel extends IMChannel {
|
||||
protected $ircChannel;
|
||||
|
||||
/**
|
||||
* Construct a ChannelResponseChannel
|
||||
*
|
||||
* @param IMplugin $imPlugin IMPlugin
|
||||
* @param string $ircChannel IRC Channel to reply to
|
||||
* @return ChannelResponseChannel
|
||||
*/
|
||||
public function __construct($imPlugin, $ircChannel) {
|
||||
$this->ircChannel = $ircChannel;
|
||||
parent::__construct($imPlugin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message using the plugin
|
||||
*
|
||||
* @param User $user User
|
||||
* @param string $text Message text
|
||||
* @return void
|
||||
*/
|
||||
public function output($user, $text) {
|
||||
$text = $user->nickname.': ['.common_config('site', 'name') . '] ' . $text;
|
||||
$this->imPlugin->send_message($this->ircChannel, $text);
|
||||
|
|
|
@ -34,7 +34,14 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
|
|||
class Fake_Irc extends Phergie_Driver_Streams {
|
||||
public $would_be_sent = null;
|
||||
|
||||
/**
|
||||
* Store the components for sending a command
|
||||
*
|
||||
* @param string $command Command
|
||||
* @param array $args Arguments
|
||||
* @return void
|
||||
*/
|
||||
protected function send($command, $args = '') {
|
||||
$this->would_be_sent = array('command' => $command, 'args' => $args);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -66,8 +66,8 @@ class IrcPlugin extends ImPlugin {
|
|||
public $regregexp = null;
|
||||
|
||||
public $transport = 'irc';
|
||||
public $whiteList;
|
||||
public $fake_irc;
|
||||
protected $whiteList;
|
||||
protected $fake_irc;
|
||||
|
||||
/**
|
||||
* Get the internationalized/translated display name of this IM service
|
||||
|
@ -81,8 +81,8 @@ class IrcPlugin extends ImPlugin {
|
|||
/**
|
||||
* Normalize a screenname for comparison
|
||||
*
|
||||
* @param string $screenname screenname to normalize
|
||||
* @return string an equivalent screenname in normalized form
|
||||
* @param string $screenname Screenname to normalize
|
||||
* @return string An equivalent screenname in normalized form
|
||||
*/
|
||||
public function normalize($screenname) {
|
||||
$screenname = str_replace(" ","", $screenname);
|
||||
|
@ -101,8 +101,8 @@ class IrcPlugin extends ImPlugin {
|
|||
/**
|
||||
* Validate (ensure the validity of) a screenname
|
||||
*
|
||||
* @param string $screenname screenname to validate
|
||||
* @return boolean
|
||||
* @param string $screenname Screenname to validate
|
||||
* @return boolean true if screenname is valid
|
||||
*/
|
||||
public function validate($screenname) {
|
||||
if (preg_match('/\A[a-z0-9\-_]{1,1000}\z/i', $screenname)) {
|
||||
|
@ -141,6 +141,7 @@ class IrcPlugin extends ImPlugin {
|
|||
/*
|
||||
* Start manager on daemon start
|
||||
*
|
||||
* @param array &$versions Array to insert manager into
|
||||
* @return boolean
|
||||
*/
|
||||
public function onStartImDaemonIoManagers(&$classes) {
|
||||
|
@ -152,7 +153,7 @@ class IrcPlugin extends ImPlugin {
|
|||
/**
|
||||
* Get a microid URI for the given screenname
|
||||
*
|
||||
* @param string $screenname
|
||||
* @param string $screenname Screenname
|
||||
* @return string microid URI
|
||||
*/
|
||||
public function microiduri($screenname) {
|
||||
|
@ -164,7 +165,7 @@ class IrcPlugin extends ImPlugin {
|
|||
*
|
||||
* @param string $screenname Screenname to send to
|
||||
* @param string $body Text to send
|
||||
* @return boolean success value
|
||||
* @return boolean true on success
|
||||
*/
|
||||
public function send_message($screenname, $body) {
|
||||
$lines = explode("\n", $body);
|
||||
|
@ -178,7 +179,7 @@ class IrcPlugin extends ImPlugin {
|
|||
/**
|
||||
* Accept a queued input message.
|
||||
*
|
||||
* @return true if processing completed, false if message should be reprocessed
|
||||
* @return boolean true if processing completed, false if message should be reprocessed
|
||||
*/
|
||||
public function receive_raw_message($data) {
|
||||
if (strpos($data['source'], '#') === 0) {
|
||||
|
@ -196,6 +197,15 @@ class IrcPlugin extends ImPlugin {
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper for handling incoming messages from a channel requiring response
|
||||
* to the channel instead of via PM
|
||||
*
|
||||
* @param string $nick Screenname the message was sent from
|
||||
* @param string $channel Channel the message originated from
|
||||
* @param string $message Message text
|
||||
* @param boolean true on success
|
||||
*/
|
||||
protected function handle_channel_incoming($nick, $channel, $notice_text) {
|
||||
$user = $this->get_user($nick);
|
||||
// For common_current_user to work
|
||||
|
@ -232,9 +242,9 @@ class IrcPlugin extends ImPlugin {
|
|||
/**
|
||||
* Attempt to handle a message from a channel as a command
|
||||
*
|
||||
* @param User $user user the message is from
|
||||
* @param User $user User the message is from
|
||||
* @param string $channel Channel the message originated from
|
||||
* @param string $body message text
|
||||
* @param string $body Message text
|
||||
* @return boolean true if the message was a command and was executed, false if it was not a command
|
||||
*/
|
||||
protected function handle_channel_command($user, $channel, $body) {
|
||||
|
@ -277,10 +287,10 @@ class IrcPlugin extends ImPlugin {
|
|||
* Only sends the confirmation message if the nick is
|
||||
* registered
|
||||
*
|
||||
* @param string $screenname screenname sending to
|
||||
* @param string $code the confirmation code
|
||||
* @param User $user user sending to
|
||||
* @return boolean success value
|
||||
* @param string $screenname Screenname sending to
|
||||
* @param string $code The confirmation code
|
||||
* @param User $user User sending to
|
||||
* @return boolean true on succes
|
||||
*/
|
||||
public function checked_send_confirmation_code($screenname, $code, $user) {
|
||||
$this->fake_irc->doPrivmsg('NickServ', 'INFO '.$screenname);
|
||||
|
@ -345,7 +355,7 @@ class IrcPlugin extends ImPlugin {
|
|||
/**
|
||||
* Get plugin information
|
||||
*
|
||||
* @param array $versions array to insert information into
|
||||
* @param array $versions Array to insert information into
|
||||
* @return void
|
||||
*/
|
||||
public function onPluginVersion(&$versions) {
|
||||
|
|
|
@ -23,17 +23,16 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
|
|||
* IRC background connection manager for IRC-using queue handlers,
|
||||
* allowing them to send outgoing messages on the right connection.
|
||||
*
|
||||
* Input is handled during socket select loop, keepalive pings during idle.
|
||||
* Any incoming messages will be handled.
|
||||
* Input is handled during socket select loop, Any incoming messages will be handled.
|
||||
*
|
||||
* In a multi-site queuedaemon.php run, one connection will be instantiated
|
||||
* for each site being handled by the current process that has IRC enabled.
|
||||
*/
|
||||
|
||||
class IrcManager extends ImManager {
|
||||
public $conn = null;
|
||||
public $regchecks = array();
|
||||
public $regchecksLookup = array();
|
||||
protected $conn = null;
|
||||
protected $regchecks = array();
|
||||
protected $regchecksLookup = array();
|
||||
|
||||
/**
|
||||
* Initialize connection to server.
|
||||
|
@ -67,7 +66,7 @@ class IrcManager extends ImManager {
|
|||
/**
|
||||
* Process IRC events that have come in over the wire.
|
||||
*
|
||||
* @param resource $socket
|
||||
* @param resource $socket Socket to handle input on
|
||||
* @return void
|
||||
*/
|
||||
public function handleInput($socket) {
|
||||
|
@ -142,7 +141,6 @@ class IrcManager extends ImManager {
|
|||
|
||||
/**
|
||||
* Called via a callback when a message is received
|
||||
*
|
||||
* Passes it back to the queuing system
|
||||
*
|
||||
* @param array $data Data
|
||||
|
@ -201,7 +199,7 @@ class IrcManager extends ImManager {
|
|||
/**
|
||||
* Send a message using the daemon
|
||||
*
|
||||
* @param $data Message
|
||||
* @param $data Message data
|
||||
* @return boolean true on success
|
||||
*/
|
||||
public function send_raw_message($data) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user