feat(tclient): add update handler option

This commit is contained in:
iyear 2023-12-11 15:46:47 +08:00
parent e58df34627
commit 753c9573df
3 changed files with 4 additions and 0 deletions

View File

@ -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

View File

@ -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...)

View File

@ -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,