Update objects to the bot’s internal channel. Telebot decouples update fetching from update processing, so you can swap pollers without touching your handlers.
The Poller interface
*Bot
The bot instance. Use it to call
b.getUpdates or other API methods.chan Update
Send each received
Update to this channel. The bot’s main loop reads from it.chan struct{}
Closed by the bot when
b.Stop() is called. Your Poll implementation must return when this channel is closed.LongPoller
The default and most common poller. It callsgetUpdates in a loop and pushes each update into the channel.
int
Maximum number of updates to fetch per request. Telegram accepts values from 1 to 100. Defaults to the server default (100) when set to 0.
time.Duration
Long-polling timeout. The server holds the connection open for up to this duration if no updates are available. A value of 0 triggers short polling (not recommended for production).
int
The offset used in the next
getUpdates call. Automatically advanced after each batch of updates. You can set this to resume from a known position.[]string
Filter which update types the server delivers. When empty, all update types are received. Uses the same string values as the Telegram Bot API (
"message", "callback_query", etc.).Example
AllowedUpdates reference
The following strings are defined inpoller.go:
MiddlewarePoller
A poller wrapper that filters updates before they reach your handlers. This is useful for blocking updates early — before a context and handler chain are even created.int
Buffer size of the internal relay channel. Defaults to 1. Increase for high-throughput scenarios where filtering is expensive.
Poller
The underlying poller to wrap.
func(*Update) bool
Return
true to pass the update through, false to drop it silently.Example — filter by chat type
MiddlewarePoller operates on raw *Update values — before any Context is created. For logic that needs a full context (sender info, c.Get/c.Set), use handler-level middleware instead.ProcessUpdate — manual update injection
When using webhooks or writing tests, you may want to inject updates directly without a polling loop:ProcessUpdate creates a new Context from the update and routes it through the same handler/middleware pipeline as the polling loop.
Implementing a custom Poller
1
Define a struct
2
Implement Poll
3
Pass to Settings