E
E
Eugene2020-10-14 18:18:28
PHP
Eugene, 2020-10-14 18:18:28

How, when clicking on the Telegram bot button, the user could write to me?

There are such buttons:

switch($message) { // в переменной $message содержится сообщение, которое мы отправляем боту.
    case '/start': $bot->sendMessage($user_id, "Привет <i>".$first_name."</i>! Посмотри этот сайт https://www.cbssao.ru//", ); break;
    case 'Наши библиотеки': $bot->sendMessage($user_id, "Адреса наших библиотек: http://www.cbssao.ru/libraries.html?ru&list&map", []); break;
    case 'Наш Youtube канал': $bot->sendMessage($user_id, $first_name.", подпишись и поставь колокольчик https://www.youtube.com/channel/UCl0xOV9OsaatnS8hNczn30w ", []); break;
    case 'Наш Instagram канал': $bot->sendMessage($user_id, $first_name.", подпишись  https://www.instagram.com/bibliosever/", []); break;
    case 'Контакты библиотеки № 21': $bot->sendMessage($user_id, "http://cbssao.ru/contacts.html?ru", []); break;
    case 'Продлить книгу': $bot->sendMessage($user_id, "888", []); break;
    case '***': $bot->sendMessage($user_id, "888", []); break;


How, when the user presses the "Renew book" button, he could write me a text (phone number and ticket number)
For example:
The reader clicks on the "Renew book" button, writes me the ticket number, and I send this number to people involved in the renewal.
On an example of a specific code please. Thanks in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
hesy, 2020-10-15
@hesy

$bot->command('/start', function () use ($bot) {
        $bot->say('Старт!', [
            [
                'Продлить книгу',
            ]
        ]);
    });

$bot->hear('Продлить книгу', function () use ($bot) {
        $bot->setState('book');
        $bot->say('Напишите номер книги.');
    });

$bot
    ->state('book', ['Назад'])
    ->hear(['{default}'], function () use ($bot) {
        // проверка и отправка заявки ...
        $bot->say('Заявка отправлена!');
    });

Working with states is described here

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question