如何向用户发送输入请求并将答案存储在电报机器人中

时间:2019-11-02 23:20:45

标签: go telegram telegram-bot telegram-webhook

我正在使用github.com/Syfaro/telegram-bot-api在golang中编写电报机器人。我需要遵循以下条件:

  1. 用户发送命令
  2. 机器人问用户一个问题
  3. 用户回答
  4. 然后,机器人进行一些计算并发送答案

我找不到如何向用户发送输入请求。有人可以帮我吗?

updates := bot.ListenForWebhook("/" + bot.Token)

for update := range updates {
        chatID := update.Message.Chat.ID

        if update.Message.IsCommand() {
            msg := tgbotapi.NewMessage(chatID, "")
            switch update.Message.Command() {
            case "command":
                response := tgbotapi.inputRequest(chatId, "Enter some text:")  //pseudocode
                msg.Text = response.Text                                      //
                bot.Send(msg)                                                //
            }
        } else {
            bot.Send(tgbotapi.NewMessage(chatID, "I don't know what to say"))
        }
    }

0 个答案:

没有答案