Skip to content

Commit b034326

Browse files
author
Syfaro
committed
Merge pull request #29 from zhulik/master
Major overhaul to make everything easier to use
2 parents a1207f6 + 667b68e commit b034326

File tree

19 files changed

+1469
-1355
lines changed

19 files changed

+1469
-1355
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.idea/
2+
coverage.out

.travis.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
language: go
2+
3+
go:
4+
- 1.4
5+
- tip

README.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Golang bindings for the Telegram Bot API
22

33
[![GoDoc](https://godoc.org/github.com/Syfaro/telegram-bot-api?status.svg)](http://godoc.org/github.com/Syfaro/telegram-bot-api)
4+
[![Travis](https://travis-ci.org/Syfaro/telegram-bot-api.svg)](https://travis-ci.org/Syfaro/telegram-bot-api)
45

56
All methods have been added, and all features should be available.
67
If you want a feature that hasn't been added yet or something is broken, open an issue and I'll see what I can do.
@@ -34,18 +35,15 @@ func main() {
3435
u := tgbotapi.NewUpdate(0)
3536
u.Timeout = 60
3637

37-
err = bot.UpdatesChan(u)
38-
if err != nil {
39-
log.Panic(err)
40-
}
38+
updates, err := bot.GetUpdatesChan(u)
4139

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

4543
msg := tgbotapi.NewMessage(update.Message.Chat.ID, update.Message.Text)
4644
msg.ReplyToMessageID = update.Message.MessageID
4745

48-
bot.SendMessage(msg)
46+
bot.Send(msg)
4947
}
5048
}
5149
```
@@ -76,15 +74,15 @@ func main() {
7674
log.Fatal(err)
7775
}
7876

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

82-
for update := range bot.Updates {
80+
for update := range updates {
8381
log.Printf("%+v\n", update)
8482
}
8583
}
8684
```
8785

8886
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.
8987

90-
openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 3560 -subj -nodes
88+
openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 3560 -subj "//O=Org\CN=Test" -nodes

0 commit comments

Comments
 (0)