Test example added
Gleb Sinyavsky zhulik.gleb@gmail.com
Sat, 21 Nov 2015 14:53:00 +0300
1 files changed,
23 insertions(+),
0 deletions(-)
jump to
M
bot_test.go
→
bot_test.go
@@ -545,3 +545,26 @@
bot.Send(msg) } } + +func ExampleNewWebhook() { + bot, err := tgbotapi.NewBotAPI("MyAwesomeBotToken") + if err != nil { + log.Fatal(err) + } + + bot.Debug = true + + log.Printf("Authorized on account %s", bot.Self.UserName) + + _, err = bot.SetWebhook(tgbotapi.NewWebhookWithCert("https://www.google.com:8443/"+bot.Token, "cert.pem")) + if err != nil { + log.Fatal(err) + } + + bot.ListenForWebhook("/" + bot.Token) + go http.ListenAndServeTLS("0.0.0.0:8443", "cert.pem", "key.pem", nil) + + for update := range bot.Updates { + log.Printf("%+v\n", update) + } +}