GoLang Telegram-bot-api 如何查询位置?

GoLang Telegram-bot-api how to ask for location?

我正在使用 github.com/go-telegram-bot-api 创建我的机器人。我想问一下客户的位置。我该怎么做?到目前为止我这样做了:

updates, err := bot.GetUpdatesChan(u)

for update := range updates {
    if update.Message == nil {
        continue
    }

    switch update.Message.Text {
    case "/shop":   
        msg := tgbotapi.NewMessage(update.Message.Chat.ID,"Send me your location")
        //I need to make this message ask for the location
        msg.Text = tgbotapi.ChatFindLocation
        bot.Send(msg)
        continue
    }
}

不幸的是,他们的存储库中没有这方面的示例。我读了一些他们的代码来弄清楚如何去做。

这是一个示例机器人,它会请求它收到的每条消息的位置。我创建了一个单击时共享位置的一键式虚拟键盘。

package main

import (
    "gopkg.in/telegram-bot-api.v4"
    "log"
)

const botToken = "Put your bot token here!"

func main() {
    bot, err := tgbotapi.NewBotAPI(botToken)
    if err != nil {
        log.Panic(err)
    }

    bot.Debug = true
    log.Printf("Authorized on account %s", bot.Self.UserName)

    u := tgbotapi.NewUpdate(0)
    u.Timeout = 60
    updates, err := bot.GetUpdatesChan(u)

    for update := range updates {
        if update.Message == nil {
            continue
        }

        log.Printf("[%s] %s", update.Message.From.UserName, update.Message.Text)

        msg := tgbotapi.NewMessage(update.Message.Chat.ID, "Hi")
        //msg.ReplyToMessageID = update.Message.MessageID
        btn := tgbotapi.KeyboardButton{
            RequestLocation: true,
            Text: "Gimme where u live!!",
        }
        msg.ReplyMarkup = tgbotapi.NewReplyKeyboard([]tgbotapi.KeyboardButton{btn})
        bot.Send(msg)
    }
}