Test example added
parent
018990922c
commit
b8bc7b9939
23
bot_test.go
23
bot_test.go
|
@ -545,3 +545,26 @@ func ExampleNewBotAPI() {
|
|||
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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue