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
|
@ -1,13 +1,14 @@
|
|||
package tgbotapi_test
|
||||
|
||||
import (
|
||||
"github.com/go-telegram-bot-api/telegram-bot-api"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/go-telegram-bot-api/telegram-bot-api"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -484,6 +485,12 @@ func ExampleNewBotAPI() {
|
|||
|
||||
updates, err := bot.GetUpdatesChan(u)
|
||||
|
||||
//If you need to clear all the updates when bot just started:
|
||||
//Wait to gather all the new updates (choose the time conveniently)
|
||||
time.Sleep(time.Millisecond * 500)
|
||||
//discard all the updates preventing the spam after your server has been down
|
||||
updates.Clear()
|
||||
|
||||
for update := range updates {
|
||||
if update.Message == nil {
|
||||
continue
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue