Skip to content

Commit

Permalink
Add an optional field to specify custom Context (#44)
Browse files Browse the repository at this point in the history
* fix non wrapped session data in Export

* Added ability to use proxies

* to my

* Added ability to use custom context

* Added ability to use custom context

* e

* e

* e

* e

* added ReplaceData

* Revert "Added ability to use custom context"

This reverts commit 07c0302.

* Revert "Added ability to use custom context"

This reverts commit 01ca320.

* Revert "e"

This reverts commit ddd65ef

* added custom run middleware functionality

* fff

* fix names

* fix import

* fix import

* fix import

* fix shit session export

* fix review

* fix review

* Revert "fix review"

This reverts commit 8b597aa.

* fix review
  • Loading branch information
KoNekoD authored Jan 10, 2024
1 parent 5c67391 commit d94fd8f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ type ClientOpts struct {
ctx context.Context,
f func(ctx context.Context) (err error),
) (err error)

// Custom context
Context context.Context
}

// NewClient creates a new gotgproto client and logs in to telegram.
Expand All @@ -143,7 +146,10 @@ func NewClient(appId int, apiHash string, cType ClientType, opts *ClientOpts) (*
}
}

ctx, cancel := context.WithCancel(context.Background())
if opts.Context == nil {
opts.Context = context.Background()
}
ctx, cancel := context.WithCancel(opts.Context)

peerStorage, sessionStorage, err := sessionMaker.NewSessionStorage(ctx, opts.Session, opts.InMemory)
if err != nil {
Expand Down

0 comments on commit d94fd8f

Please sign in to comment.