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