|
|
|
@ -97,8 +97,15 @@ func helpString(ht helpType) string {
|
|
|
|
|
return str.String()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ProcessTransportCommand executes commands sent directly to the component
|
|
|
|
|
func (c *Client) ProcessTransportCommand(cmd string, args []string) string {
|
|
|
|
|
func parseCommand(cmdline string) (string, []string) {
|
|
|
|
|
bodyFields := strings.Fields(cmdline)
|
|
|
|
|
return bodyFields[0][1:], bodyFields[1:]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ProcessTransportCommand executes a command sent directly to the component
|
|
|
|
|
// and returns a response
|
|
|
|
|
func (c *Client) ProcessTransportCommand(cmdline string) string {
|
|
|
|
|
cmd, args := parseCommand(cmdline)
|
|
|
|
|
switch cmd {
|
|
|
|
|
case "login", "code", "password":
|
|
|
|
|
if cmd == "login" && c.Session.Login != "" {
|
|
|
|
@ -127,3 +134,15 @@ func (c *Client) ProcessTransportCommand(cmd string, args []string) string {
|
|
|
|
|
|
|
|
|
|
return ""
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ProcessChatCommand executes a command sent in a mapped chat
|
|
|
|
|
// and returns a response and the status of command support
|
|
|
|
|
func (c *Client) ProcessChatCommand(cmdline string) (string, bool) {
|
|
|
|
|
cmd, _ := parseCommand(cmdline)
|
|
|
|
|
switch cmd {
|
|
|
|
|
case "help":
|
|
|
|
|
return helpString(helpTypeChat), false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return "", true
|
|
|
|
|
}
|
|
|
|
|