R
R
Roman Morenets2020-02-27 17:26:44
PHP
Roman Morenets, 2020-02-27 17:26:44

How to get the last few messages sent?

There is a bot that contains several buttons to go to sections. From each section you can leave an application. The script accepts the application and sends it to the mail. The code is something like this:

function getresult_custom($data){
    # Выводим кнопку "Вернуться назад"
  if($data['message'] == $data['label']){
    # Формируем кнопку "Вернуться назад":
    $keyboard[] = array($_lang['back_button']);
    # Выводим описание модуля:
    tgApi(
      'sendMessage',
      array(
        'chat_id' => $data['source']['message']['chat']['id'],
        'text' => ''Описание раздела,
        'parse_mode' => 'Markdown',
        'reply_markup' => json_encode(
          array(
            'keyboard' => $keyboard,
            'resize_keyboard' => true,
            'one_time_keyboard' => false
          )
        )
      )
    );               
    } else {
        $form_result = $data['message'];
        $send_email = sendEmail($form_result);
        return "Ваша заявка успешно отправлена! \nТекст заявки: ". $form_result ."\nМы перезвоним Вам в течение 15 минут. \nНажмите 'Вернуться назад' для выхода.";       
    }
}

The script works, but there is a problem - the script allows you to get only the last message sent by the user. And I would like to get everything that the user has typed, including the name of the section (that is, the text on the button for entering the section). Perhaps a different approach is needed for this? It is not possible to pass more than one message to the function.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Aksentiev, 2020-02-27
@romapad

Keep your message history and do whatever you want with it.
Bot can't get history

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question