mirror of
https://github.com/iyear/tdl
synced 2025-01-08 11:57:55 +08:00
feat(tclient): add update handler option
This commit is contained in:
parent
e58df34627
commit
753c9573df
@ -29,6 +29,7 @@ func Code(ctx context.Context) error {
|
||||
NTP: viper.GetString(consts.FlagNTP),
|
||||
ReconnectTimeout: viper.GetDuration(consts.FlagReconnectTimeout),
|
||||
Test: viper.GetString(consts.FlagTest) != "",
|
||||
UpdateHandler: nil,
|
||||
}, true)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -142,6 +142,7 @@ func tRun(ctx context.Context, f func(ctx context.Context, c *telegram.Client, k
|
||||
NTP: viper.GetString(consts.FlagNTP),
|
||||
ReconnectTimeout: viper.GetDuration(consts.FlagReconnectTimeout),
|
||||
Test: viper.GetString(consts.FlagTest) != "",
|
||||
UpdateHandler: nil,
|
||||
}
|
||||
|
||||
client, err := tclient.New(ctx, o, false, middlewares...)
|
||||
|
@ -31,6 +31,7 @@ type Options struct {
|
||||
NTP string
|
||||
ReconnectTimeout time.Duration
|
||||
Test bool
|
||||
UpdateHandler telegram.UpdateHandler
|
||||
}
|
||||
|
||||
func New(ctx context.Context, o Options, login bool, middlewares ...telegram.Middleware) (*telegram.Client, error) {
|
||||
@ -70,6 +71,7 @@ func New(ctx context.Context, o Options, login bool, middlewares ...telegram.Mid
|
||||
ReconnectionBackoff: func() backoff.BackOff {
|
||||
return newBackoff(o.ReconnectTimeout)
|
||||
},
|
||||
UpdateHandler: o.UpdateHandler,
|
||||
Device: Device,
|
||||
SessionStorage: storage.NewSession(o.KV, login),
|
||||
RetryInterval: 5 * time.Second,
|
||||
|
Loading…
Reference in New Issue
Block a user