Пример #1
0
func processIncomingSlack(ctx context.Context, commandrouter *commandrouter.Router,
	command string, user string, inChannel string, toBot bool, responseChan chan string) {

	msg := model.ChatMessage{
		FromUser: user,
		Channel:  inChannel,
		Text:     strings.TrimSpace(command),
		ToBot:    toBot,
	}

	handled, err := commandrouter.Route(ctx, &msg, responseChan)
	if err != nil {
		logIn.Errorf("commandrouter: %s", err.Error())
		// TODO Make this message configurable?
		select {
		case responseChan <- "Internal error, please see bot logs":
		default:
		}
	} else if !handled {
		responseChan <- "I didn't recognize that command"
	}
}