func (b *Bot) StartMonitoringUpdates(updateOffset int64, interval int, updateHandler func(b *Bot, update Update, err error)) {
	b.verbose("starting monitoring updates (interval seconds: %d) ...", interval)

	// https://core.telegram.org/bots/api#getupdates
	options := OptionsGetUpdates{}.
		SetOffset(updateOffset).
		SetLimit(100). // default: 100
		SetTimeout(1)  // default: 0 for testing

	// set update handler
	if updateHandler == nil {
		b.error("given update handler is nil")
		return
	}
	b.updateHandler = updateHandler

	var updates APIResponseUpdates
loop:
	for {
		select {
		case <-b.quitLoop:
			break loop
		default:
			if updates = b.GetUpdates(options); updates.Ok {
				for _, update := range updates.Result {
					// update offset (max + 1)
					if options["offset"].(int64) <= update.UpdateID {
						options["offset"] = update.UpdateID + 1
					}

					go b.updateHandler(b, update, nil)
				}
			} else {
				go b.updateHandler(b, Update{}, fmt.Errorf("%s", *updates.Description))
			}

			time.Sleep(time.Duration(interval) * time.Second)
		}
	}

	b.verbose("stopped monitoring updates")
}
// StartMonitoringUpdates retrieves updates from API server constantly.
//
// If webhook is registered, it may not work properly. So make sure webhook is deleted, or not registered.
StartMonitoringUpdates retrieves updates from API server constantly.

If webhook is registered, it may not work properly. So make sure webhook is deleted, or not registered.
// StartMonitoringUpdates retrieves updates from API server constantly . // // If webhook is registered it may not work properly . So make sure webhook is deleted or not registered .
func (b *Bot) StartMonitoringUpdates(updateOffset int64, interval int, updateHandler func(b *Bot, update Update, err error)) {
	b.verbose("starting monitoring updates (interval seconds: %d) ...", interval)
	options := OptionsGetUpdates{}.
		SetOffset(updateOffset).
		SetLimit(100). 
		SetTimeout(1)  
	if updateHandler == nil {
		b.error("given update handler is nil")
		return
	}
	b.updateHandler = updateHandler
	var updates APIResponseUpdates
loop:
	for {
		select {
		case <-b.quitLoop:
			break loop
		default:
			if updates = b.GetUpdates(options); updates.Ok {
				for _, update := range updates.Result {
					if options["offset"].(int64) <= update.UpdateID {
						options["offset"] = update.UpdateID + 1
					}
					go b.updateHandler(b, update, nil)
				}
			} else {
				go b.updateHandler(b, Update{}, fmt.Errorf("%s", *updates.Description))
			}
			time.Sleep(time.Duration(interval) * time.Second)
		}
	}
	b.verbose("stopped monitoring updates")
}
func ( b * Bot ) StartMonitoringUpdates ( updateOffset int64 , interval int , updateHandler func ( b * Bot , update Update , err error ) ) { b . verbose ( " " , interval ) options := OptionsGetUpdates { } . SetOffset ( updateOffset ) . SetLimit ( 100 ) . SetTimeout ( 1 ) if updateHandler == nil { b . error ( " " ) return } b . updateHandler = updateHandler var updates APIResponseUpdates loop : for { select { case <- b . quitLoop : break loop default : if updates = b . GetUpdates ( options ) ; updates . Ok { for _ , update := range updates . Result { if options [ " " ] . ( int64 ) <= update . UpdateID { options [ " " ] = update . UpdateID + 1 } go b . updateHandler ( b , update , nil ) } } else { go b . updateHandler ( b , Update { } , fmt . Errorf ( " " , * updates . Description ) ) } time . Sleep ( time . Duration ( interval ) * time . Second ) } } b . verbose ( " " ) }
StartMonitoringUpdates retrieves updates from API server constantly.
StartMonitoringUpdates retrieves updates from API server constantly .
// https://core.telegram.org/bots/api#getupdates // default: 100 // default: 0 for testing // set update handler // update offset (max + 1)