Skip to content

Commit

Permalink
Merge pull request #3 from slpv/feat-last-updates
Browse files Browse the repository at this point in the history
feat: method GetUpdatesChannelWithLastID
  • Loading branch information
gldmtr authored Aug 5, 2024
2 parents 3128763 + af3b3c1 commit b6b80a4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ func NewBot(token string, opts ...BotOption) (*Bot, error) {
apiURL := defaultAPIURL
debug := defaultDebug
client := *http.DefaultClient
lastEventID := 0
for _, option := range opts {
switch option.Type() {
case "api_url":
Expand All @@ -270,6 +271,8 @@ func NewBot(token string, opts ...BotOption) (*Bot, error) {
debug = option.Value().(bool)
case "http_client":
client = option.Value().(http.Client)
case "last_event_id":
lastEventID = option.Value().(int)
}
}

Expand All @@ -279,6 +282,7 @@ func NewBot(token string, opts ...BotOption) (*Bot, error) {

tgClient := NewCustomClient(&client, apiURL, token, logger)
updater := NewUpdater(tgClient, 0, logger)
updater.lastEventID = lastEventID

info, err := tgClient.GetInfo()
if err != nil {
Expand Down
10 changes: 10 additions & 0 deletions options.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,13 @@ func (o BotHTTPClient) Type() string {
func (o BotHTTPClient) Value() interface{} {
return http.Client(o)
}

type BotLastEventID int

func (o BotLastEventID) Type() string {
return "last_event_id"
}

func (o BotLastEventID) Value() interface{} {
return int(o)
}

0 comments on commit b6b80a4

Please sign in to comment.