Closed asmi046 closed 4 years ago
Примерно так можно делать:
try {
// start command
$bot->command('start', function (Message $message, $code) use ($bot) {
/** @var BotApi $bot */
$bot->sendMessage(
$message->getChat()->getId(),
Env::AUTH_RESPONSES[TelegramHelper::getLanguageCode($message->getFrom()->getLanguageCode())]['welcome'],
'html',
false,
null,
new ReplyKeyboardMarkup(
[
[
['text' => 'get me your phone number!', 'request_contact' => true],
]
],
true,
true
)
);
});
// react only on self contact
$bot->on(
function (Update $update) use ($bot) {
/** @var BotApi $bot */
$bot->sendMessage(
$update->getMessage()->getChat()->getId(),
$update->getMessage()->getContact()->getPhoneNumber()
);
},
function (Update $update) {
return $update->getMessage()
&& $update->getMessage()->getContact()
&& $update->getMessage()->getContact()->getUserId() === $update->getMessage()->getFrom()->getId();
}
);
$bot->run();
} catch (\TelegramBot\Api\Exception $e) {
// ...
}
Подскажите есть ли реализация метода KeyboardButton ( https://tlgrm.ru/docs/bots/2-0-intro#locations-and-numbers ) В целом как можно реализовать получение номера телефона?