diff --git a/bot.go b/bot.go index fb8f9b42..03717b24 100644 --- a/bot.go +++ b/bot.go @@ -79,6 +79,11 @@ func (bot *BotAPI) SetAPIEndpoint(apiEndpoint string) { bot.apiEndpoint = apiEndpoint } +// SetAPIEndpoint changes the Telegram Bot API update chan buffer used by the instance. +func (bot *BotAPI) SetUpdatesBuffer(capacity int) { + bot.Buffer = capacity +} + func buildParams(in Params) url.Values { if in == nil { return url.Values{} diff --git a/bot_test.go b/bot_test.go index eb52f450..0108c99d 100644 --- a/bot_test.go +++ b/bot_test.go @@ -50,6 +50,15 @@ func getBot(t *testing.T) (*BotAPI, error) { return bot, err } +func TestBotWithCustomBuffer(t *testing.T) { + bot, _ := getBot(t) + + customValue := 200 + bot.SetUpdatesBuffer(customValue) + + assertEq(t, bot.Buffer, customValue) +} + func TestNewBotAPI_notoken(t *testing.T) { _, err := NewBotAPI("")