/** * Build response. * * @param mixed $response * * @return string */ protected function response($response) { if (is_string($response)) { $message = new Text(['content' => $response]); } $return = ''; if ($this->isMessage($response)) { $return = $this->buildReply($this->input->get('ToUserName'), $this->input->get('FromUserName'), $response); if ($this->input->isEncrypted()) { $return = $this->cryptor->encryptMsg($return, $this->input->get('nonce'), $this->input->get('timestamp')); } } return $return; }
/** * Build response. * * @param mixed $response * * @return string */ protected function response($response) { is_string($response) && ($response = MessageBuilder::make('text')->with('content', $response)); $return = null; if ($response instanceof AbstractMessage) { $response->from($this->input->get('ToUserName'))->to($this->input->get('FromUserName')); $this->call('responseCreated', [$response]); $return = $response->buildForReply(); if ($this->input->isEncrypted()) { $return = $this->cryptor->encryptMsg($return, $this->input->get('nonce'), $this->input->get('timestamp')); } } $return = $this->call('served', [$return], $return); return $return; }