* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
* @link http://status.net/
*/
-
class IrcPlugin extends ImPlugin {
public $host = null;
public $port = null;
* @return string Name of service
*/
public function getDisplayName() {
+ // TRANS: Service name for IRC.
return _m('IRC');
}
* @return boolean hook value; true means continue processing, false means stop.
*/
public function onAutoload($cls) {
- $dir = dirname(__FILE__);
-
- switch ($cls) {
- case 'IrcManager':
- include_once $dir . '/'.strtolower($cls).'.php';
- return false;
- case 'Fake_Irc':
- case 'Irc_waiting_message':
- case 'ChannelResponseChannel':
- 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;
+ // in the beginning of this file, we have added an include path
+ if (substr($cls, 0, 7) == 'Phergie') {
+ include_once str_replace('_', DIRECTORY_SEPARATOR, $cls) . '.php';
+ return false;
}
+
+ return parent::onAutoload($cls);
}
/*
* @return boolean
*/
public function onStartImDaemonIoManagers(&$classes) {
- parent::onStartImDaemonIoManagers(&$classes);
+ parent::onStartImDaemonIoManagers($classes);
$classes[] = new IrcManager($this); // handles sending/receiving
return true;
}
$schema = Schema::get();
// For storing messages while sessions become ready
- $schema->ensureTable('irc_waiting_message',
- array(new ColumnDef('id', 'integer', null,
- false, 'PRI', null, null, true),
- new ColumnDef('data', 'blob', null, false),
- new ColumnDef('prioritise', 'tinyint', 1, false),
- new ColumnDef('attempts', 'integer', null, false),
- new ColumnDef('created', 'datetime', null, false),
- new ColumnDef('claimed', 'datetime')));
-
+ $schema->ensureTable('irc_waiting_message', Irc_waiting_message::schemaDef());
return true;
}
if (in_array($command, $this->whiteList)) {
$this->handle_channel_incoming($data['sender'], $data['source'], $message);
} else {
- $this->handle_incoming($data['sender'], $message);
+ $this->handleIncoming($data['sender'], $message);
}
} else {
- $this->handle_incoming($data['sender'], $data['message']);
+ $this->handleIncoming($data['sender'], $data['message']);
}
return true;
}
* @param boolean true on success
*/
protected function handle_channel_incoming($nick, $channel, $notice_text) {
- $user = $this->get_user($nick);
+ $user = $this->getUser($nick);
// For common_current_user to work
global $_cur;
$_cur = $user;
if ($this->handle_channel_command($user, $channel, $notice_text)) {
common_log(LOG_INFO, "Command message by $nick handled.");
return;
- } else if ($this->is_autoreply($notice_text)) {
+ } else if ($this->isAutoreply($notice_text)) {
common_log(LOG_INFO, 'Ignoring auto reply from ' . $nick);
return;
- } else if ($this->is_otr($notice_text)) {
+ } else if ($this->isOtr($notice_text)) {
common_log(LOG_INFO, 'Ignoring OTR from ' . $nick);
return;
} else {
common_log(LOG_INFO, 'Posting a notice from ' . $user->nickname);
- $this->add_notice($nick, $user, $notice_text);
+ $this->addNotice($nick, $user, $notice_text);
}
$user->free();
* @return boolean success value
*/
public function sendConfirmationCode($screenname, $code, $user, $checked = false) {
- $body = sprintf(_('User "%s" on %s has said that your %s screenname belongs to them. ' .
+ // TRANS: Body text for e-mail confirmation message for IRC.
+ // TRANS: %1$s is a user nickname, %2$s is the StatusNet sitename,
+ // TRANS: %3$s is the plugin display name ("IRC"), %4$s is the confirm address URL.
+ $body = sprintf(_m('User "%1$s" on %2$s has said that your %3$s screenname belongs to them. ' .
'If that\'s true, you can confirm by clicking on this URL: ' .
- '%s' .
+ '%4$s' .
' . (If you cannot click it, copy-and-paste it into the ' .
- 'address bar of your browser). If that user isn\'t you, ' .
- 'or if you didn\'t request this confirmation, just ignore this message.'),
+ 'address bar of your browser). If that user is not you, ' .
+ 'or if you did not request this confirmation, just ignore this message.'),
$user->nickname, common_config('site', 'name'), $this->getDisplayName(), common_local_url('confirmaddress', array('code' => $code)));
if ($this->regcheck && !$checked) {
*/
public function initialize() {
if (!isset($this->host)) {
- throw new Exception('must specify a host');
+ // TRANS: Exception thrown when initialising the IRC plugin fails because of an incorrect configuration.
+ throw new Exception(_m('You must specify a host.'));
}
if (!isset($this->username)) {
- throw new Exception('must specify a username');
+ // TRANS: Exception thrown when initialising the IRC plugin fails because of an incorrect configuration.
+ throw new Exception(_m('You must specify a username.'));
}
if (!isset($this->realname)) {
- throw new Exception('must specify a "real name"');
+ // TRANS: Exception thrown when initialising the IRC plugin fails because of an incorrect configuration.
+ throw new Exception(_m('You must specify a "real name".'));
}
if (!isset($this->nick)) {
- throw new Exception('must specify a nickname');
+ // TRANS: Exception thrown when initialising the IRC plugin fails because of an incorrect configuration.
+ throw new Exception(_m('You must specify a nickname.'));
}
if (!isset($this->port)) {
$this->regcheck = true;
}
- $this->fake_irc = new Fake_Irc;
+ $this->fake_irc = new FakeIrc;
/*
* Commands allowed to return output to a channel
* @param array $versions Array to insert information into
* @return void
*/
- public function onPluginVersion(&$versions) {
+ public function onPluginVersion(array &$versions) {
$versions[] = array('name' => 'IRC',
- 'version' => STATUSNET_VERSION,
+ 'version' => GNUSOCIAL_VERSION,
'author' => 'Luke Fitzgerald',
'homepage' => 'http://status.net/wiki/Plugin:IRC',
'rawdescription' =>
+ // TRANS: Plugin description.
_m('The IRC plugin allows users to send and receive notices over an IRC network.'));
return true;
}