check telegram webhook tls handshake

bot-api-6.1
scnace 2018-01-08 02:10:50 +08:00
parent 2022d04b94
commit 9b7184fa79
2 changed files with 28 additions and 4 deletions

View File

@ -91,7 +91,13 @@ func main() {
if err != nil { if err != nil {
log.Fatal(err) 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) updates := bot.ListenForWebhook("/" + bot.Token)
go http.ListenAndServeTLS("0.0.0.0:8443", "cert.pem", "key.pem", nil) go http.ListenAndServeTLS("0.0.0.0:8443", "cert.pem", "key.pem", nil)

View File

@ -467,7 +467,13 @@ func TestSetWebhookWithCert(t *testing.T) {
t.Error(err) t.Error(err)
t.Fail() 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() bot.RemoveWebhook()
} }
@ -484,7 +490,13 @@ func TestSetWebhookWithoutCert(t *testing.T) {
t.Error(err) t.Error(err)
t.Fail() 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() bot.RemoveWebhook()
} }
@ -549,7 +561,13 @@ func ExampleNewWebhook() {
if err != nil { if err != nil {
log.Fatal(err) 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) updates := bot.ListenForWebhook("/" + bot.Token)
go http.ListenAndServeTLS("0.0.0.0:8443", "cert.pem", "key.pem", nil) go http.ListenAndServeTLS("0.0.0.0:8443", "cert.pem", "key.pem", nil)