You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
telegabber/telegram/commands.go

34 lines
767 B

package telegram
const notEnoughArguments string = "Not enough arguments"
const telegramNotInitialized string = "Telegram connection is not initialized yet"
// ProcessTransportCommand executes commands sent directly to the component
func (c *Client) ProcessTransportCommand(cmd string, args []string) string {
switch cmd {
case "login", "code", "password":
if cmd == "login" && c.Session.Login != "" {
return ""
}
if len(args) < 1 {
return notEnoughArguments
}
if c.authorizer == nil {
return telegramNotInitialized
}
switch cmd {
case "login":
c.authorizer.PhoneNumber <- args[0]
c.Session.Login = args[0]
case "code":
c.authorizer.Code <- args[0]
case "password":
c.authorizer.Password <- args[0]
}
}
return ""
}