all repos — telegram-bot-api @ 102c3104f489ae065a67884747d2d7fedf790e42

Golang bindings for the Telegram Bot API

Merge pull request #141 from scbizu/master

[proposal]check telegram webhook tls handshake
Syfaro syfaro@huefox.com
Mon, 26 Mar 2018 11:24:12 -0500
commit

102c3104f489ae065a67884747d2d7fedf790e42

parent

38681a48d156eba3e543508a327e4a0039df5537

2 files changed, 28 insertions(+), 4 deletions(-)

jump to
M README.mdREADME.md

@@ -91,7 +91,13 @@ _, err = bot.SetWebhook(tgbotapi.NewWebhookWithCert("https://www.google.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) + } updates := bot.ListenForWebhook("/" + bot.Token) go http.ListenAndServeTLS("0.0.0.0:8443", "cert.pem", "key.pem", nil)
M bot_test.gobot_test.go

@@ -467,7 +467,13 @@ if err != nil {

t.Error(err) t.Fail() } - + info, err := bot.GetWebhookInfo() + if err != nil { + t.Error(err) + } + if info.LastErrorDate != 0 { + t.Errorf("[Telegram callback failed]%s", info.LastErrorMessage) + } bot.RemoveWebhook() }

@@ -484,7 +490,13 @@ if err != nil {

t.Error(err) t.Fail() } - + info, err := bot.GetWebhookInfo() + if err != nil { + t.Error(err) + } + if info.LastErrorDate != 0 { + t.Errorf("[Telegram callback failed]%s", info.LastErrorMessage) + } bot.RemoveWebhook() }

@@ -549,7 +561,13 @@ _, err = bot.SetWebhook(tgbotapi.NewWebhookWithCert("https://www.google.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) + } updates := bot.ListenForWebhook("/" + bot.Token) go http.ListenAndServeTLS("0.0.0.0:8443", "cert.pem", "key.pem", nil)