all repos — telegram-bot-api @ 5859ba397020f3651e609786fd1118fa55765434

Golang bindings for the Telegram Bot API

Small updates. Readme updated
Gleb Sinyavsky zhulik.gleb@gmail.com
Sat, 21 Nov 2015 17:31:59 +0300
commit

5859ba397020f3651e609786fd1118fa55765434

parent

2a5cf8652db7672f33d91dbb9b0906768b72b843

3 files changed, 19 insertions(+), 19 deletions(-)

jump to
M README.mdREADME.md

@@ -24,27 +24,27 @@ )

func main() { bot, err := tgbotapi.NewBotAPI("MyAwesomeBotToken") - if err != nil { - log.Panic(err) - } + if err != nil { + log.Panic(err) + } - bot.Debug = true + bot.Debug = true - log.Printf("Authorized on account %s", bot.Self.UserName) + log.Printf("Authorized on account %s", bot.Self.UserName) - u := tgbotapi.NewUpdate(0) - u.Timeout = 60 + u := tgbotapi.NewUpdate(0) + u.Timeout = 60 - err = bot.UpdatesChan(u) + updates, err := bot.GetUpdatesChan(u) - for update := range bot.Updates { - log.Printf("[%s] %s", update.Message.From.UserName, update.Message.Text) + for update := range updates { + log.Printf("[%s] %s", update.Message.From.UserName, update.Message.Text) - msg := tgbotapi.NewMessage(update.Message.Chat.ID, update.Message.Text) - msg.ReplyToMessageID = update.Message.MessageID + msg := tgbotapi.NewMessage(update.Message.Chat.ID, update.Message.Text) + msg.ReplyToMessageID = update.Message.MessageID - bot.Send(msg) - } + bot.Send(msg) + } } ```

@@ -74,10 +74,10 @@ if err != nil {

log.Fatal(err) } - bot.ListenForWebhook("/"+bot.Token) + updates, _ := bot.ListenForWebhook("/" + bot.Token) go http.ListenAndServeTLS("0.0.0.0:8443", "cert.pem", "key.pem", nil) - for update := range bot.Updates { + for update := range updates { log.Printf("%+v\n", update) } }
M bot.gobot.go

@@ -394,7 +394,7 @@ return apiResp, nil

} // UpdatesChan starts a channel for getting updates. -func (bot *BotAPI) UpdatesChan(config UpdateConfig) (<-chan Update, error) { +func (bot *BotAPI) GetUpdatesChan(config UpdateConfig) (<-chan Update, error) { updatesChan := make(chan Update, 100) go func() {
M bot_test.gobot_test.go

@@ -396,7 +396,7 @@ bot, _ := getBot(t)

var ucfg tgbotapi.UpdateConfig = tgbotapi.NewUpdate(0) ucfg.Timeout = 60 - _, err := bot.UpdatesChan(ucfg) + _, err := bot.GetUpdatesChan(ucfg) if err != nil { t.Fail()

@@ -416,7 +416,7 @@

u := tgbotapi.NewUpdate(0) u.Timeout = 60 - updates, err := bot.UpdatesChan(u) + updates, err := bot.GetUpdatesChan(u) for update := range updates { log.Printf("[%s] %s", update.Message.From.UserName, update.Message.Text)