diff options
author | Bohdan Horbeshko <bodqhrohro@gmail.com> | 2022-08-15 13:10:29 +0300 |
---|---|---|
committer | Bohdan Horbeshko <bodqhrohro@gmail.com> | 2022-08-15 13:10:29 +0300 |
commit | e9e65b6778d52cf140247bf2f548c5e698183c1d (patch) | |
tree | e28aa1f9774d3281fbcdcbe1022458678afecf50 /telegram/commands.go | |
parent | 0c71036148b0327db6f05f5d1a8d878be86f72c9 (diff) |
Registration support
Diffstat (limited to 'telegram/commands.go')
-rw-r--r-- | telegram/commands.go | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/telegram/commands.go b/telegram/commands.go index bd9f0f8..55267ab 100644 --- a/telegram/commands.go +++ b/telegram/commands.go @@ -290,25 +290,33 @@ func (c *Client) ProcessTransportCommand(cmdline string, resource string) string } // set My Name case "setname": - if !c.Online() { - return notOnline - } - var firstname string var lastname string if len(args) > 0 { firstname = args[0] } + if firstname == "" { + return "The name should contain at least one character" + } if len(args) > 1 { - lastname = args[1] + lastname = rawCmdArguments(cmdline, 1) } - _, err := c.client.SetName(&client.SetNameRequest{ - FirstName: firstname, - LastName: lastname, - }) - if err != nil { - return errors.Wrap(err, "Couldn't set name").Error() + if c.authorizer != nil && !c.authorizer.isClosed { + c.authorizer.FirstName <- firstname + c.authorizer.LastName <- lastname + } else { + if !c.Online() { + return notOnline + } + + _, err := c.client.SetName(&client.SetNameRequest{ + FirstName: firstname, + LastName: lastname, + }) + if err != nil { + return errors.Wrap(err, "Couldn't set name").Error() + } } // set About case "setbio": |