How can I get users' live location when they share it with a Telegram Bot?
I am using node-telegram-bot-api in this project. I have managed to get the bot request one-time location from the users. Here's the code:
import TelegramBot from 'node-telegram-bot-api';
const token = 'XXXXXXXXXXXXXXXXXXX'
// Create a bot that uses 'polling' to fetch new updates
const bot = new TelegramBot(token, {polling: true});
bot.onText(/start/, (msg) => {
const opts = {
reply_markup: JSON.stringify({
keyboard: [
[{text: 'Location Request', request_location: true}],
],
resize_keyboard: true,
one_time_keyboard: true,
}),
};
bot.sendMessage(msg.chat.id, 'some message goes here', opts);
});
bot.on('location', (msg) => {
//console.log(msg.location.latitude);
//console.log(msg.location.longitude);
//do something with the lat long
)};
But I need the bot to capture live location from the users. There is a small reference to this question in StackOverflow here but that answer is for the bot sending its live location to the user. I need it to be the other way around.