aboutsummaryrefslogtreecommitdiff
path: root/telegram/commands.go
diff options
context:
space:
mode:
authorBohdan Horbeshko <bodqhrohro@gmail.com>2023-06-16 07:34:49 +0300
committerBohdan Horbeshko <bodqhrohro@gmail.com>2023-06-16 07:34:49 +0300
commitfdd867cf7a435346a552a8da7f446b59b5e1213e (patch)
tree2bab821cf7419a5b9f16c43cab137a13fb4490ad /telegram/commands.go
parentedf2c08a5b46e48277a5173653cfe8b156a412e5 (diff)
Add /cancelauth command
Diffstat (limited to 'telegram/commands.go')
-rw-r--r--telegram/commands.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/telegram/commands.go b/telegram/commands.go
index 5e16a6a..cafeb0a 100644
--- a/telegram/commands.go
+++ b/telegram/commands.go
@@ -44,6 +44,7 @@ var permissionsReadonly = client.ChatPermissions{}
var transportCommands = map[string]command{
"login": command{"phone", "sign in"},
"logout": command{"", "sign out"},
+ "cancelauth": command{"", "quit the signin wizard"},
"code": command{"", "check one-time code"},
"password": command{"", "check 2fa password"},
"setusername": command{"", "update @username"},
@@ -230,7 +231,7 @@ func (c *Client) ProcessTransportCommand(cmdline string, resource string) string
switch cmd {
case "login", "code", "password":
if cmd == "login" && c.Session.Login != "" {
- return ""
+ return "Phone number already provided, use /cancelauth to start over"
}
if len(args) < 1 {
@@ -286,6 +287,13 @@ func (c *Client) ProcessTransportCommand(cmdline string, resource string) string
}
c.Session.Login = ""
+ // cancel auth
+ case "cancelauth":
+ if c.Online() {
+ return "Not allowed when online"
+ }
+ c.cancelAuth()
+ return "Cancelled"
// set @username
case "setusername":
if !c.Online() {