Skip to content

Commit 5859ba3

Browse files
committed
Small updates. Readme updated
1 parent 2a5cf86 commit 5859ba3

File tree

3 files changed

+19
-19
lines changed

3 files changed

+19
-19
lines changed

README.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,27 +24,27 @@ import (
2424

2525
func main() {
2626
bot, err := tgbotapi.NewBotAPI("MyAwesomeBotToken")
27-
if err != nil {
28-
log.Panic(err)
29-
}
27+
if err != nil {
28+
log.Panic(err)
29+
}
3030

31-
bot.Debug = true
31+
bot.Debug = true
3232

33-
log.Printf("Authorized on account %s", bot.Self.UserName)
33+
log.Printf("Authorized on account %s", bot.Self.UserName)
3434

35-
u := tgbotapi.NewUpdate(0)
36-
u.Timeout = 60
35+
u := tgbotapi.NewUpdate(0)
36+
u.Timeout = 60
3737

38-
err = bot.UpdatesChan(u)
38+
updates, err := bot.GetUpdatesChan(u)
3939

40-
for update := range bot.Updates {
41-
log.Printf("[%s] %s", update.Message.From.UserName, update.Message.Text)
40+
for update := range updates {
41+
log.Printf("[%s] %s", update.Message.From.UserName, update.Message.Text)
4242

43-
msg := tgbotapi.NewMessage(update.Message.Chat.ID, update.Message.Text)
44-
msg.ReplyToMessageID = update.Message.MessageID
43+
msg := tgbotapi.NewMessage(update.Message.Chat.ID, update.Message.Text)
44+
msg.ReplyToMessageID = update.Message.MessageID
4545

46-
bot.Send(msg)
47-
}
46+
bot.Send(msg)
47+
}
4848
}
4949
```
5050

@@ -74,10 +74,10 @@ func main() {
7474
log.Fatal(err)
7575
}
7676

77-
bot.ListenForWebhook("/"+bot.Token)
77+
updates, _ := bot.ListenForWebhook("/" + bot.Token)
7878
go http.ListenAndServeTLS("0.0.0.0:8443", "cert.pem", "key.pem", nil)
7979

80-
for update := range bot.Updates {
80+
for update := range updates {
8181
log.Printf("%+v\n", update)
8282
}
8383
}

bot.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ func (bot *BotAPI) SetWebhook(config WebhookConfig) (APIResponse, error) {
394394
}
395395

396396
// UpdatesChan starts a channel for getting updates.
397-
func (bot *BotAPI) UpdatesChan(config UpdateConfig) (<-chan Update, error) {
397+
func (bot *BotAPI) GetUpdatesChan(config UpdateConfig) (<-chan Update, error) {
398398
updatesChan := make(chan Update, 100)
399399

400400
go func() {

bot_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ func TestUpdatesChan(t *testing.T) {
396396

397397
var ucfg tgbotapi.UpdateConfig = tgbotapi.NewUpdate(0)
398398
ucfg.Timeout = 60
399-
_, err := bot.UpdatesChan(ucfg)
399+
_, err := bot.GetUpdatesChan(ucfg)
400400

401401
if err != nil {
402402
t.Fail()
@@ -416,7 +416,7 @@ func ExampleNewBotAPI() {
416416
u := tgbotapi.NewUpdate(0)
417417
u.Timeout = 60
418418

419-
updates, err := bot.UpdatesChan(u)
419+
updates, err := bot.GetUpdatesChan(u)
420420

421421
for update := range updates {
422422
log.Printf("[%s] %s", update.Message.From.UserName, update.Message.Text)

0 commit comments

Comments
 (0)