feat: login
This commit is contained in:
@@ -30,9 +30,10 @@ type TClient struct {
|
||||
// t.block <- struct{}{}
|
||||
// }
|
||||
|
||||
func NewClient(config *config.Config) *TClient {
|
||||
func NewClient(logger *zap.Logger, config *config.Config) *TClient {
|
||||
c := &TClient{
|
||||
Config: config,
|
||||
logger: logger,
|
||||
Client: telegram.NewClient(config.AppID, config.AppHash, telegram.Options{
|
||||
Logger: logger,
|
||||
UpdateHandler: nil,
|
||||
@@ -50,28 +51,8 @@ func (t *TClient) WithMedia() *TClient {
|
||||
return t
|
||||
}
|
||||
|
||||
// func (t *TClient) Run(ctx context.Context) {
|
||||
// err := t.Client.Run(ctx, func(ctx context.Context) error {
|
||||
// flow := auth.NewFlow(Terminal{PhoneNumber: t.Config.Phone}, auth.SendCodeOptions{})
|
||||
// if err := t.Client.Auth().IfNecessary(ctx, flow); err != nil {
|
||||
// return errors.Wrap(err, "auth")
|
||||
// }
|
||||
// t.api = t.Client.API()
|
||||
|
||||
// t.waitLogin <- nil
|
||||
// <-t.block
|
||||
// return nil
|
||||
// })
|
||||
// if err != nil {
|
||||
// t.waitLogin <- err
|
||||
// }
|
||||
// }
|
||||
|
||||
// func (t *TClient) Wait() <-chan error {
|
||||
// return t.waitLogin
|
||||
// }
|
||||
|
||||
func (t *TClient) Login(ctx context.Context) error {
|
||||
t.logger.Info("login phone", zap.String("phone", t.Config.Phone))
|
||||
flow := auth.NewFlow(Terminal{PhoneNumber: client.Config.Phone}, auth.SendCodeOptions{})
|
||||
if err := t.Client.Auth().IfNecessary(context.Background(), flow); err != nil {
|
||||
return errors.Wrap(err, "auth")
|
||||
|
||||
Reference in New Issue
Block a user