diff options
author | bodqhrohro <bodqhrohro@gmail.com> | 2019-12-17 04:56:11 +0300 |
---|---|---|
committer | bodqhrohro <bodqhrohro@gmail.com> | 2019-12-17 04:56:11 +0300 |
commit | 05a9aca537a9420244860374da6b56731f483637 (patch) | |
tree | f64596f268223406810eebbd74d0789c9c1d4b3c /telegram/handlers.go | |
parent | 10aae376f7dae843a5472cfc5c7083b4c032021d (diff) |
Reconnect fix
Diffstat (limited to 'telegram/handlers.go')
-rw-r--r-- | telegram/handlers.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/telegram/handlers.go b/telegram/handlers.go index d6aba94..d6b945f 100644 --- a/telegram/handlers.go +++ b/telegram/handlers.go @@ -90,6 +90,12 @@ func (c *Client) updateHandler() { } c.updateFile(typedUpdate) log.Debugf("%#v", typedUpdate.File) + case client.TypeUpdateAuthorizationState: + typedUpdate, ok := update.(*client.UpdateAuthorizationState) + if !ok { + uhOh() + } + c.updateAuthorizationState(typedUpdate) default: // log only handled types continue @@ -242,3 +248,13 @@ func (c *Client) updateFile(update *client.UpdateFile) { log.Errorf("Error creating symlink: %v", err) } } + +func (c *Client) updateAuthorizationState(update *client.UpdateAuthorizationState) { + switch update.AuthorizationState.AuthorizationStateType() { + case client.TypeAuthorizationStateClosing: + log.Warn("Closing the updates listener") + case client.TypeAuthorizationStateClosed: + log.Warn("Closed the updates listener") + c.forceClose() + } +} |