I deployed a telegram bot on GAE but it seems something went wrong - I do 
not recive any updates from channel.
Is this a valid example, or there is an error?

import (
    "log"
    "net/http"

    tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api"
)

func main() {

    log.Printf("%s", 
"\n#============================================================#")
    apiToken := "sometokenhere"

    bot, err := tgbotapi.NewBotAPI(apiToken)
    if err != nil {
        log.Fatal(err)
    }

    bot.Debug = true

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

    _, err = bot.SetWebhook(tgbotapi.NewWebhookWithCert(
"https://patternbot.appspot.com:8443/"+bot.Token, "cert.pem"))
    if err != nil {
        log.Fatal(err)
    }

    info, err := bot.GetWebhookInfo()
    if err != nil {
        log.Fatal(err)
    }

    if info.LastErrorDate != 0 {
        log.Printf("Telegram callback failed: %s", info.LastErrorMessage)
    } else {
        log.Printf("Webhook info: %v", info)
    }

    updates := bot.ListenForWebhook("/" + bot.Token)
    go http.ListenAndServeTLS("91.108.4.0/22:8443", "cert.pem", "key.pem", 
nil)

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

A console output from GAE:

2019-09-16 05:21:48 default[20190916t082016]  
> #============================================================#
> 2019-09-16 05:21:49 default[20190916t082016]  2019/09/16 05:21:49 
> Authorized on account leonardo_da_vinchi_bot
> 2019-09-16 05:21:49 default[20190916t082016]  2019/09/16 05:21:49 
> {"ok":true,"result":true,"description":"Webhook was set"}
> 2019-09-16 05:21:49 default[20190916t082016]  2019/09/16 05:21:49 
> getWebhookInfo resp: 
> {"ok":true,"result":{"url":"https://patternbot.appspot.com:8443/sometokenhere","has_custom_certificate":true,"pending_update_count":9,"max_connections":40}}
> 2019-09-16 05:21:49 default[20190916t082016]  2019/09/16 05:21:49 Webhook 
> info: {https://patternbot.appspot.com:8443/sometokenhere true 9 0 }


There should be messages from the `updates` channel but they do not come. What 
is wrong with it?

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/6b876882-4beb-4349-8108-e2a67e663def%40googlegroups.com.

Reply via email to