talk: Don't reply on comments

This commit is contained in:
Hamcha 2017-05-09 15:59:42 +02:00
parent a69670a526
commit 8d5c554d8d

View file

@ -71,6 +71,7 @@ func talk(broker *tg.Broker, update tg.APIMessage) {
return return
} }
text := *(update.Text) text := *(update.Text)
quoted := false
// Make sure it's aimed at Clessy // Make sure it's aimed at Clessy
if strings.Index(text, "@"+*botname) >= 0 { if strings.Index(text, "@"+*botname) >= 0 {
@ -81,6 +82,7 @@ func talk(broker *tg.Broker, update tg.APIMessage) {
text = strings.TrimLeft(text[len("clessy"):], ":,") text = strings.TrimLeft(text[len("clessy"):], ":,")
} else if text[0] != '/' && update.ReplyTo != nil && update.ReplyTo.User.Username == *botname { } else if text[0] != '/' && update.ReplyTo != nil && update.ReplyTo.User.Username == *botname {
// Reply to Clessy (previous prompt?) which is not a command (such as unsplash), pass // Reply to Clessy (previous prompt?) which is not a command (such as unsplash), pass
quoted = true
} else if update.Chat.Username != nil { } else if update.Chat.Username != nil {
// Private chat, pass // Private chat, pass
} else { } else {
@ -191,7 +193,10 @@ func talk(broker *tg.Broker, update tg.APIMessage) {
reply += "\nAlternativamente:\n - " + strings.Join(result.Alternatives, "\n - ") reply += "\nAlternativamente:\n - " + strings.Join(result.Alternatives, "\n - ")
} }
case "input.unknown": case "input.unknown":
// NOOP // Don't reply if quoted (probably just a comment)
if quoted {
return
}
default: default:
log.Printf("[talk] Unknown action called:\n%s\n", record.Result.Action) log.Printf("[talk] Unknown action called:\n%s\n", record.Result.Action)
} }