diff options
Diffstat (limited to 'telegram')
-rw-r--r-- | telegram/commands.go | 9 | ||||
-rw-r--r-- | telegram/connect.go | 5 |
2 files changed, 9 insertions, 5 deletions
diff --git a/telegram/commands.go b/telegram/commands.go index b729973..87fff72 100644 --- a/telegram/commands.go +++ b/telegram/commands.go @@ -244,17 +244,20 @@ func (c *Client) ProcessTransportCommand(cmdline string, resource string) string return notEnoughArguments } - c.locks.authorizerWriteLock.Lock() - defer c.locks.authorizerWriteLock.Unlock() - if cmd == "login" { err := c.TryLogin(resource, args[0]) if err != nil { return err.Error() } + c.locks.authorizerWriteLock.Lock() + defer c.locks.authorizerWriteLock.Unlock() + c.authorizer.PhoneNumber <- args[0] } else { + c.locks.authorizerWriteLock.Lock() + defer c.locks.authorizerWriteLock.Unlock() + if c.authorizer == nil { return TelegramNotInitialized } diff --git a/telegram/connect.go b/telegram/connect.go index 6c49aa9..b1b8b10 100644 --- a/telegram/connect.go +++ b/telegram/connect.go @@ -122,6 +122,7 @@ func (c *Client) Connect(resource string) error { } go c.interactor() + log.Warn("Interactor launched") c.authorizer.TdlibParameters <- c.parameters c.locks.authorizerWriteLock.Unlock() @@ -180,8 +181,8 @@ func (c *Client) TryLogin(resource string, login string) error { time.Sleep(1e5) } - c.locks.authorizerReadLock.Lock() - defer c.locks.authorizerReadLock.Unlock() + c.locks.authorizerWriteLock.Lock() + defer c.locks.authorizerWriteLock.Unlock() if c.authorizer == nil { return errors.New(TelegramNotInitialized) |