+ /**
+ * Called via a callback when NickServ responds to
+ * the bots query asking if a nick is registered
+ *
+ * @param array $data Data
+ * @return void
+ */
+ public function handle_reg_response($data) {
+ // Retrieve data
+ $screenname = $data['screenname'];
+ $nickdata = $this->regchecks[$screenname];
+ $usernick = $nickdata['user']->nickname;
+
+ if (isset($this->regchecksLookup[$usernick])) {
+ if ($data['registered']) {
+ // Send message
+ $this->plugin->send_confirmation_code($screenname, $nickdata['code'], $nickdata['user'], true);
+ } else {
+ $this->plugin->send_message($screenname, _m('Your nickname is not registered so IRC connectivity cannot be enabled'));
+
+ $confirm = new Confirm_address();
+
+ $confirm->user_id = $user->id;
+ $confirm->address_type = $this->plugin->transport;
+
+ if ($confirm->find(true)) {
+ $result = $confirm->delete();
+
+ if (!$result) {
+ common_log_db_error($confirm, 'DELETE', __FILE__);
+ // TRANS: Server error thrown on database error canceling IM address confirmation.
+ $this->serverError(_('Couldn\'t delete confirmation.'));
+ return;
+ }
+ }
+ }
+
+ // Unset lookup value
+ unset($this->regchecksLookup[$usernick]);
+
+ // Unset data
+ unset($this->regchecks[$screename]);
+ }
+ }
+