Added Clear() to examples and code simplification
This commit is contained in:
parent
0a95dda18a
commit
c034de512a
2 changed files with 10 additions and 5 deletions
6
bot.go
6
bot.go
|
@ -451,7 +451,6 @@ func (bot *BotAPI) GetWebhookInfo() (WebhookInfo, error) {
|
|||
// GetUpdatesChan starts and returns a channel for getting updates.
|
||||
func (bot *BotAPI) GetUpdatesChan(config UpdateConfig) (updatesChannel, error) {
|
||||
ch := make(chan Update, 100)
|
||||
var updatesCh updatesChannel = ch
|
||||
|
||||
go func() {
|
||||
for {
|
||||
|
@ -473,13 +472,12 @@ func (bot *BotAPI) GetUpdatesChan(config UpdateConfig) (updatesChannel, error) {
|
|||
}
|
||||
}()
|
||||
|
||||
return updatesCh, nil
|
||||
return ch, nil
|
||||
}
|
||||
|
||||
// ListenForWebhook registers a http handler for a webhook.
|
||||
func (bot *BotAPI) ListenForWebhook(pattern string) updatesChannel {
|
||||
ch := make(chan Update, 100)
|
||||
var updatesCh updatesChannel = ch
|
||||
|
||||
http.HandleFunc(pattern, func(w http.ResponseWriter, r *http.Request) {
|
||||
bytes, _ := ioutil.ReadAll(r.Body)
|
||||
|
@ -490,7 +488,7 @@ func (bot *BotAPI) ListenForWebhook(pattern string) updatesChannel {
|
|||
ch <- update
|
||||
})
|
||||
|
||||
return updatesCh
|
||||
return ch
|
||||
}
|
||||
|
||||
// AnswerInlineQuery sends a response to an inline query.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue