diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..b1fef93 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2015 Syfaro + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index c476f16..af48acd 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,14 @@ # Golang Telegram bindings for the Bot API -[![GoDoc](https://godoc.org/src.foxpaw.in/Syfaro/telegram-bot-api?status.svg)](https://godoc.org/src.foxpaw.in/Syfaro/telegram-bot-api) +[![GoDoc](https://godoc.org/github.com/Syfaro/telegram-bot-api?status.svg)](http://godoc.org/github.com/Syfaro/telegram-bot-api) All methods have been added, and all features should be available. 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. +All methods are fairly self explanatory, and reading the godoc page should explain everything. If something isn't clear, open an issue or submit a pull request. + +The scope of this project is just to provide a wrapper around the API without any additional features. There are other projects (including one I am developing myself) for creating something with plugins and command handlers without having to design all that yourself. + ## Example This is a very simple bot that just displays any gotten updates, then replies it to that chat. @@ -14,7 +18,7 @@ package main import ( "log" - "src.foxpaw.in/Syfaro/telegram-bot-api" + "github.com/Syfaro/telegram-bot-api" ) func main() { diff --git a/updates.go b/updates.go index 7106201..72f518b 100644 --- a/updates.go +++ b/updates.go @@ -1,5 +1,10 @@ package tgbotapi +import ( + "log" + "time" +) + // UpdatesChan returns a chan that is called whenever a new message is gotten. func (bot *BotAPI) UpdatesChan(config UpdateConfig) (chan Update, error) { bot.Updates = make(chan Update, 100) @@ -8,7 +13,15 @@ func (bot *BotAPI) UpdatesChan(config UpdateConfig) (chan Update, error) { for { updates, err := bot.GetUpdates(config) if err != nil { - panic(err) + if bot.Debug { + panic(err) + } else { + log.Println(err) + log.Println("Failed to get updates, retrying in 3 seconds...") + time.Sleep(time.Second * 3) + } + + continue } for _, update := range updates {