Получить широту и долготу местоположения пользователя с помощью бота telegram

1

Как получить широту и долготу местоположения пользователя через телеграмму бота?

Модуль: ссылка

Код:

bot.onText(/getLocation/, (msg) => {
  const opts = {
    reply_markup: JSON.stringify({
      keyboard: [
        [{text: 'Location', request_location: true}],
        [{text: 'Contact', request_contact: true}],
      ],
      resize_keyboard: true,
      one_time_keyboard: true,
    }),
  };
  bot.sendMessage(msg.chat.id, 'Contact and Location request', opts);
});
Теги:
telegram-bot
node-telegram-bot-api

1 ответ

1
Лучший ответ

Решено ️

bot.on('location', (msg) => {
  console.log(msg.location.latitude);
  console.log(msg.location.longitude);
});

Ещё вопросы

Сообщество Overcoder
Наверх
Меню