diff options
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": |