Fix bot_test.go, update README.

bot-api-6.1
Syfaro 2018-10-09 01:45:18 -05:00
parent afda722fc3
commit 290b9363d4
2 changed files with 3 additions and 73 deletions

View File

@ -62,64 +62,7 @@ func main() {
}
```
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.

View File

@ -509,19 +509,6 @@ func TestSetWebhookWithoutCert(t *testing.T) {
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 @@ func ExampleNewBotAPI() {
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 @@ func ExampleInlineConfig() {
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