/*
Package bob is for teenager handling
*/
package bob
import (
"strings"
)
// Remark types Bob recognizes
const (
bobQuestion int = iota
bobYell
bobQuestionYell
bobEmpty
bobDefault
)
// bobAnswer is bob's answer for various remark types
var bobAnswer = map[int]string{
bobQuestion: "Sure.",
bobYell: "Whoa, chill out!",
bobQuestionYell: "Calm down, I know what I'm doing!",
bobEmpty: "Fine. Be that way!",
bobDefault: "Whatever.",
}
// Hey outputs Bob's answer to various remarks.
func Hey(remark string) string {
remark = strings.TrimSpace(remark)
if len(remark) == 0 {
return bobAnswer[bobEmpty]
}
if strings.ToUpper(remark) == remark && strings.ContainsAny(remark, "yxcvbnmasdfghjklqwertzuiopYXCVBNMASDFGHJKLQWERTZUIOP") {
// Yelling, not just numbers
if strings.HasSuffix(remark, "?") {
return bobAnswer[bobQuestionYell]
}
return bobAnswer[bobYell]
}
if strings.HasSuffix(remark, "?") {
return bobAnswer[bobQuestion]
}
return bobAnswer[bobDefault]
}