all repos — telegram-bot-api @ 290b9363d44f83c188b2d15e00c509ffdfdada82

Golang bindings for the Telegram Bot API

Fix bot_test.go, update README.
Syfaro syfaro@huefox.com
Tue, 09 Oct 2018 01:45:18 -0500
commit

290b9363d44f83c188b2d15e00c509ffdfdada82

parent

afda722fc3cf4eb4cb59c1652c28b7a57210f4a7

2 files changed, 3 insertions(+), 73 deletions(-)

jump to
M README.mdREADME.md

@@ -62,64 +62,7 @@ }

} ``` -There are more examples on the [wiki](https://github.com/go-telegram-bot-api/telegram-bot-api/wiki) +There are more examples on the [site](https://go-telegram-bot-api.github.io/) with detailed information on how to do many different kinds of things. It's a great place to get started on using keyboards, commands, or other kinds of reply markup. - -If you need to use webhooks (if you wish to run on Google App Engine), -you may use a slightly different method. - -```go -package main - -import ( - "log" - "net/http" - - "github.com/go-telegram-bot-api/telegram-bot-api" -) - -func main() { - 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.Request(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) - - for update := range updates { - log.Printf("%+v\n", update) - } -} -``` - -If you need, you may generate a self signed certficate, as this requires -HTTPS / TLS. The above example tells Telegram that this is your -certificate and that it should be trusted, even though it is not -properly signed. - - openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 3560 -subj "//O=Org\CN=Test" -nodes - -Now that [Let's Encrypt](https://letsencrypt.org) is available, you may -wish to generate your free TLS certificate there.
M bot_test.gobot_test.go

@@ -509,19 +509,6 @@

bot.Request(RemoveWebhookConfig{}) } -func TestUpdatesChan(t *testing.T) { - bot, _ := getBot(t) - - var ucfg = NewUpdate(0) - ucfg.Timeout = 60 - _, err := bot.GetUpdatesChan(ucfg) - - if err != nil { - t.Error(err) - t.Fail() - } -} - func TestSendWithMediaGroup(t *testing.T) { bot, _ := getBot(t)

@@ -549,7 +536,7 @@

u := NewUpdate(0) u.Timeout = 60 - updates, err := bot.GetUpdatesChan(u) + updates := bot.GetUpdatesChan(u) // Optional: wait for updates and clear them if you don't want to handle // a large backlog of old messages

@@ -614,7 +601,7 @@

u := NewUpdate(0) u.Timeout = 60 - updates, err := bot.GetUpdatesChan(u) + updates := bot.GetUpdatesChan(u) for update := range updates { if update.InlineQuery == nil { // if no inline query, ignore it