Exemple #1
0
func (a actionList) handle(message *slack.Message, command bool) bool {
	handled := false

	var action Action
	for _, action = range a {
		matches := action.Regex.FindStringSubmatch(message.Text)

		if len(matches) > 0 {
			response := action.Answerer(message)

			if response != "" {
				handled = true
				log.Printf("me-> %s", response)
				if command {
					if err := message.Respond(response); err != nil {
						// gulp!
						log.Printf("Error responding to message: %s\nwith Message: '%s'", err, response)
					}
				} else {
					if err := message.Send(response); err != nil {
						// gulp!
						log.Printf("Error responding to message: %s\nwith Message: '%s'", err, response)
					}
				}

			}
		}
	}

	return handled
}