コード例 #1
0
ファイル: slackscot.go プロジェクト: timoman/slackscot
func onAskedMessage(message *slack.Message) {
	log.Printf("%s-> %s", message.From, message.Text)

	matches := tellCommand.FindStringSubmatch(message.Text)
	if len(matches) > 0 {
		message.Tell(matches[3], matches[1]+": "+matches[4])
		return
	}

	handled := commands.handle(message, true)

	if !handled {
		var response string

		if defaultAction != nil {
			// if sentence not matched to a supported request then fallback to a default
			response = defaultAction(message)
		} else {
			response = "Je comprends pas.\n_Dis-moi_ `help` _pour avoir la liste des commandes_"
		}

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