Telegram Bot Webhook Golang无法回答

时间:2018-07-30 08:38:40

标签: go telegram digital-ocean telegram-bot

我正在使用go-telegram-bot-api,并尝试使用webhook获取更新。 但是它返回一个空的更新通道。我做错了什么? Webhook已经安装在数字海洋小滴上。

代码如下:

package main

import (
        "github.com/go-telegram-bot-api/telegram-bot-api"
        "log"
        "net/http"
)

func main() {
        bot, err := tgbotapi.NewBotAPI("MyToken")
        if err != nil {
                log.Fatal(err)
        }

        bot.Debug = true

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

        info, err := bot.GetWebhookInfo()
        if err != nil {
                log.Fatal(err)
        }
        if info.LastErrorDate != 0 {
                log.Printf("[Telegram callback failed]%s", info.LastErrorMessage)
        }
        updates := bot.ListenForWebhook("/" + bot.Token)
        go http.ListenAndServeTLS("0.0.0.0:8443", "YOURPUBLIC.pem", "YOURPRIVATE.key", nil)

        for update := range updates {
                log.Printf("%+v\n", update)
        }
}

0 个答案:

没有答案
相关问题