getMessage(); $chat = $message->getChat(); $chat_id = $chat->getId(); $user_id = $message->getFrom()->getId(); // Make sure the Download path has been defined and exists $download_path = $this->telegram->getDownloadPath(); if (!is_dir($download_path)) { return $this->replyToChat('Download path has not been defined or does not exist.'); } // Initialise the data array for the response $data = ['chat_id' => $chat_id]; if ($chat->isGroupChat() || $chat->isSuperGroup()) { // Reply to message id is applied by default $data['reply_to_message_id'] = $message->getMessageId(); // Force reply is applied by default to work with privacy on $data['reply_markup'] = Keyboard::forceReply(['selective' => true]); } // Start conversation $conversation = new Conversation($user_id, $chat_id, $this->getName()); $message_type = $message->getType(); if (in_array($message_type, ['audio', 'document', 'photo', 'video', 'voice'], true)) { $doc = $message->{'get' . ucfirst($message_type)}(); // For photos, get the best quality! ($message_type === 'photo') && $doc = end($doc); $file_id = $doc->getFileId(); $file = Request::getFile(['file_id' => $file_id]); if ($file->isOk() && Request::downloadFile($file->getResult())) { $data['text'] = $message_type . ' file is located at: ' . $download_path . '/' . $file->getResult()->getFilePath(); } else { $data['text'] = 'Failed to download.'; } $conversation->notes['file_id'] = $file_id; $conversation->update(); $conversation->stop(); } else { $data['text'] = 'Please upload the file now'; } return Request::sendMessage($data); } }