【问题标题】:Get user location latitude and longitude via telegram bot通过电报机器人获取用户位置经纬度
【发布时间】:2018-07-17 00:29:49
【问题描述】:

如何通过电报机器人获取用户位置经纬度?

模块:Link

代码:

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);
});

【问题讨论】:

    标签: javascript node.js telegram-bot node-telegram-bot-api


    【解决方案1】:

    解决了✔️

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

    【讨论】:

      【解决方案2】:
      bot.on('location', (msg) => {
        console.log(msg.message.location.latitude);
        console.log(msg.message.location.longitude);
      });
          
      

      【讨论】:

        猜你喜欢
        • 2012-07-02
        • 2020-08-01
        • 2022-06-10
        • 1970-01-01
        • 1970-01-01
        • 2017-04-10
        • 2012-11-08
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多