aboutsummaryrefslogtreecommitdiff
path: root/telegram/commands.go
diff options
context:
space:
mode:
authorbodqhrohro <bodqhrohro@gmail.com>2019-12-19 00:00:23 +0300
committerbodqhrohro <bodqhrohro@gmail.com>2019-12-19 00:00:23 +0300
commit18b5bc09356dd80024ecfd411145b3312b3fa7a1 (patch)
tree3f9c8be21d21eee61be6a00d62bbc77dd514fbd3 /telegram/commands.go
parent05a9aca537a9420244860374da6b56731f483637 (diff)
Relogin fix
Diffstat (limited to 'telegram/commands.go')
-rw-r--r--telegram/commands.go17
1 files changed, 11 insertions, 6 deletions
diff --git a/telegram/commands.go b/telegram/commands.go
index 04c6e3a..82e6d38 100644
--- a/telegram/commands.go
+++ b/telegram/commands.go
@@ -159,8 +159,12 @@ func (c *Client) ProcessTransportCommand(cmdline string) string {
cmd, args := parseCommand(cmdline)
switch cmd {
case "login", "code", "password":
- if cmd == "login" && c.Session.Login != "" {
- return ""
+ if cmd == "login" {
+ if c.Session.Login != "" {
+ return ""
+ } else if !c.Online() {
+ c.Connect()
+ }
}
if len(args) < 1 {
@@ -184,15 +188,16 @@ func (c *Client) ProcessTransportCommand(cmdline string) string {
}
// sign out
case "logout":
+ for id := range c.cache.chats {
+ c.unsubscribe(id)
+ }
+
_, err := c.client.LogOut()
if err != nil {
+ c.forceClose()
return errors.Wrap(err, "Logout error").Error()
}
- for id := range c.cache.chats {
- c.unsubscribe(id)
- }
-
c.Session.Login = ""
// set @username
case "setusername":