summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/go-telegram-bot-api/telegram-bot-api/bot.go
diff options
context:
space:
mode:
authorDuco van Amstel <helcaraxan@gmail.com>2018-11-18 17:55:05 +0000
committerWim <wim@42.be>2018-11-25 21:21:04 +0100
commit09875fe1603307080f3a4172985c5dca3bd9912d (patch)
treea23220772f6f6597d509ca71b2df3480a77b8076 /vendor/github.com/go-telegram-bot-api/telegram-bot-api/bot.go
parentf716b8fc0ff90f47b61e218ef34019b38bd70e0d (diff)
downloadmatterbridge-msglm-09875fe1603307080f3a4172985c5dca3bd9912d.tar.gz
matterbridge-msglm-09875fe1603307080f3a4172985c5dca3bd9912d.tar.bz2
matterbridge-msglm-09875fe1603307080f3a4172985c5dca3bd9912d.zip
Update direct dependencies where possible
Diffstat (limited to 'vendor/github.com/go-telegram-bot-api/telegram-bot-api/bot.go')
-rw-r--r--vendor/github.com/go-telegram-bot-api/telegram-bot-api/bot.go17
1 files changed, 16 insertions, 1 deletions
diff --git a/vendor/github.com/go-telegram-bot-api/telegram-bot-api/bot.go b/vendor/github.com/go-telegram-bot-api/telegram-bot-api/bot.go
index 8fb6200e..d56aaf82 100644
--- a/vendor/github.com/go-telegram-bot-api/telegram-bot-api/bot.go
+++ b/vendor/github.com/go-telegram-bot-api/telegram-bot-api/bot.go
@@ -9,7 +9,6 @@ import (
"fmt"
"io"
"io/ioutil"
- "log"
"net/http"
"net/url"
"os"
@@ -28,6 +27,7 @@ type BotAPI struct {
Self User `json:"-"`
Client *http.Client `json:"-"`
+ shutdownChannel chan interface{}
}
// NewBotAPI creates a new BotAPI instance.
@@ -46,6 +46,7 @@ func NewBotAPIWithClient(token string, client *http.Client) (*BotAPI, error) {
Token: token,
Client: client,
Buffer: 100,
+ shutdownChannel: make(chan interface{}),
}
self, err := bot.GetMe()
@@ -484,6 +485,12 @@ func (bot *BotAPI) GetUpdatesChan(config UpdateConfig) (UpdatesChannel, error) {
go func() {
for {
+ select {
+ case <-bot.shutdownChannel:
+ return
+ default:
+ }
+
updates, err := bot.GetUpdates(config)
if err != nil {
log.Println(err)
@@ -505,6 +512,14 @@ func (bot *BotAPI) GetUpdatesChan(config UpdateConfig) (UpdatesChannel, error) {
return ch, nil
}
+// StopReceivingUpdates stops the go routine which receives updates
+func (bot *BotAPI) StopReceivingUpdates() {
+ if bot.Debug {
+ log.Println("Stopping the update receiver routine...")
+ }
+ close(bot.shutdownChannel)
+}
+
// ListenForWebhook registers a http handler for a webhook.
func (bot *BotAPI) ListenForWebhook(pattern string) UpdatesChannel {
ch := make(chan Update, bot.Buffer)