From e94d4b60400463054d77dbf527d9370d909835cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=80=20?= =?UTF-8?q?=D0=A1=D0=BE=D0=BB=D0=BE=D0=BF=D0=BE=D0=B2?= Date: Tue, 15 Oct 2024 01:04:00 +0300 Subject: [PATCH] feat: add PollTime to options --- bot.go | 5 ++++- options.go | 10 ++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/bot.go b/bot.go index b186d19..0234fce 100644 --- a/bot.go +++ b/bot.go @@ -263,6 +263,7 @@ func NewBot(token string, opts ...BotOption) (*Bot, error) { debug := defaultDebug client := *http.DefaultClient lastEventID := 0 + pollTime := 0 for _, option := range opts { switch option.Type() { case "api_url": @@ -273,6 +274,8 @@ func NewBot(token string, opts ...BotOption) (*Bot, error) { client = option.Value().(http.Client) case "last_event_id": lastEventID = option.Value().(int) + case "poll_time": + pollTime = option.Value().(int) } } @@ -281,7 +284,7 @@ func NewBot(token string, opts ...BotOption) (*Bot, error) { } tgClient := NewCustomClient(&client, apiURL, token, logger) - updater := NewUpdater(tgClient, 0, logger) + updater := NewUpdater(tgClient, pollTime, logger) updater.lastEventID = lastEventID info, err := tgClient.GetInfo() diff --git a/options.go b/options.go index 7beb931..1bf80b8 100644 --- a/options.go +++ b/options.go @@ -46,3 +46,13 @@ func (o BotLastEventID) Type() string { func (o BotLastEventID) Value() interface{} { return int(o) } + +type BotPollTime int + +func (o BotPollTime) Type() string { + return "poll_time" +} + +func (o BotPollTime) Value() interface{} { + return int(o) +}