diff --git a/NTFServer.go b/NTFServer.go index 1edc1ec..6c538ce 100644 --- a/NTFServer.go +++ b/NTFServer.go @@ -479,22 +479,25 @@ func (this *NTFServer) HandleGroupMessage(update telegram.Update) error { sendMsg := update.Message.Text // Was it a reply to another message? If so, format it as " OrigMessage // update text" + // That includes collapsing the original message onto a single line if update.Message.ReplyToMessage != nil && len(update.Message.ReplyToMessage.Text) > 0 && update.Message.ReplyToMessage.From != nil { origSenderId := int64(update.Message.ReplyToMessage.From.ID) + flatten := func(s string) string { return strings.Replace(s, "\n", " ", -1) } + if origSenderNick, ok := this.config.KnownUsers[origSenderId]; ok { // Quoted messages from another hub user - sendMsg = fmt.Sprintf(`"<%s> %s" // %s`, origSenderNick, update.Message.ReplyToMessage.Text, sendMsg) + sendMsg = fmt.Sprintf(`"<%s> %s" // %s`, origSenderNick, flatten(update.Message.ReplyToMessage.Text), sendMsg) } else if origSenderId == int64(this.bot.Self.ID) { // Quoted messages from the hublink bot - sendMsg = fmt.Sprintf(`"%s" // %s`, update.Message.ReplyToMessage.Text, sendMsg) // the username is already present in the plaintext + sendMsg = fmt.Sprintf(`"%s" // %s`, flatten(update.Message.ReplyToMessage.Text), sendMsg) // the username is already present in the plaintext } else { // No idea what was quoted. But it really was quoting something // Paste it as-is but with some info in the logs for future cleanup log.Printf("Quoting message '%#v' with unknown source", update.Message.ReplyToMessage) - sendMsg = fmt.Sprintf(`"%s" // %s`, update.Message.ReplyToMessage.Text, sendMsg) + sendMsg = fmt.Sprintf(`"%s" // %s`, flatten(update.Message.ReplyToMessage.Text), sendMsg) } }