X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=plugins%2FIrc%2FIrcPlugin.php;h=99dc4b2bc125e54e22b86b6e4beca3fded6cf301;hb=0b4115b2496c830fb0a4373bcc9a27050899db55;hp=c555580c38f98994974b1e6b28cfee029e866f40;hpb=326258bfef7282509d719238234038d0f6a8d3ff;p=quix0rs-gnu-social.git diff --git a/plugins/Irc/IrcPlugin.php b/plugins/Irc/IrcPlugin.php index c555580c38..99dc4b2bc1 100644 --- a/plugins/Irc/IrcPlugin.php +++ b/plugins/Irc/IrcPlugin.php @@ -47,7 +47,6 @@ set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__) . '/ext * @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; @@ -76,6 +75,7 @@ class IrcPlugin extends ImPlugin { * @return string Name of service */ public function getDisplayName() { + // TRANS: Service name for IRC. return _m('IRC'); } @@ -95,7 +95,7 @@ class IrcPlugin extends ImPlugin { * * @return string Screenname */ - public function daemon_screenname() { + public function daemonScreenname() { return $this->nick; } @@ -120,24 +120,13 @@ class IrcPlugin extends ImPlugin { * @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); } /* @@ -147,7 +136,7 @@ class IrcPlugin extends ImPlugin { * @return boolean */ public function onStartImDaemonIoManagers(&$classes) { - parent::onStartImDaemonIoManagers(&$classes); + parent::onStartImDaemonIoManagers($classes); $classes[] = new IrcManager($this); // handles sending/receiving return true; } @@ -160,15 +149,7 @@ class IrcPlugin extends ImPlugin { $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; } @@ -189,11 +170,11 @@ class IrcPlugin extends ImPlugin { * @param string $body Text to send * @return boolean true on success */ - public function send_message($screenname, $body) { + public function sendMessage($screenname, $body) { $lines = explode("\n", $body); foreach ($lines as $line) { $this->fake_irc->doPrivmsg($screenname, $line); - $this->enqueue_outgoing_raw(array('type' => 'message', 'prioritise' => 0, 'data' => $this->fake_irc->would_be_sent)); + $this->enqueueOutgoingRaw(array('type' => 'message', 'prioritise' => 0, 'data' => $this->fake_irc->would_be_sent)); } return true; } @@ -203,7 +184,7 @@ class IrcPlugin extends ImPlugin { * * @return boolean true if processing completed, false if message should be reprocessed */ - public function receive_raw_message($data) { + public function receiveRawMessage($data) { if (strpos($data['source'], '#') === 0) { $message = $data['message']; $parts = explode(' ', $message, 2); @@ -211,10 +192,10 @@ class IrcPlugin extends ImPlugin { 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; } @@ -229,13 +210,13 @@ class IrcPlugin extends ImPlugin { * @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 (!$user) { - $this->send_from_site($nick, 'Unknown user; go to ' . + $this->sendFromSite($nick, 'Unknown user; go to ' . common_local_url('imsettings') . ' to add your address to your account'); common_log(LOG_WARNING, 'Message from unknown user ' . $nick); @@ -244,15 +225,15 @@ class IrcPlugin extends ImPlugin { 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(); @@ -289,19 +270,22 @@ class IrcPlugin extends ImPlugin { * @param User $user user sending to * @return boolean success value */ - public function send_confirmation_code($screenname, $code, $user, $checked = false) { - $body = sprintf(_('User "%s" on %s has said that your %s screenname belongs to them. ' . + public function sendConfirmationCode($screenname, $code, $user, $checked = false) { + // 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) { - return $this->checked_send_confirmation_code($screenname, $code, $user); + return $this->checked_sendConfirmationCode($screenname, $code, $user); } else { - return $this->send_message($screenname, $body); + return $this->sendMessage($screenname, $body); } } @@ -314,9 +298,9 @@ class IrcPlugin extends ImPlugin { * @param User $user User sending to * @return boolean true on succes */ - public function checked_send_confirmation_code($screenname, $code, $user) { + public function checked_sendConfirmationCode($screenname, $code, $user) { $this->fake_irc->doPrivmsg('NickServ', 'INFO '.$screenname); - $this->enqueue_outgoing_raw( + $this->enqueueOutgoingRaw( array( 'type' => 'nickcheck', 'prioritise' => 1, @@ -339,16 +323,20 @@ class IrcPlugin extends ImPlugin { */ 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)) { @@ -368,7 +356,7 @@ class IrcPlugin extends ImPlugin { $this->regcheck = true; } - $this->fake_irc = new Fake_Irc; + $this->fake_irc = new FakeIrc; /* * Commands allowed to return output to a channel @@ -384,12 +372,13 @@ class IrcPlugin extends ImPlugin { * @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; }