X-Git-Url: https://git.giacomolli.uk/onechat/blobdiff_plain/d28e3b2858db322899a81b59a30400c1acad2b42..0da50dc187c8b4aa23ac1ddd0418c0da779389d9:/whatsapp_batch.go diff --git a/whatsapp_batch.go b/whatsapp_batch.go index 08dfb6a..7f43a3c 100644 --- a/whatsapp_batch.go +++ b/whatsapp_batch.go @@ -40,7 +40,8 @@ func (b WhatsAppBatch) Turn() bool { // The first line starts with [WhatsApp] and names the chat, its ID, and the day // of the first message. Each message has a line with its time and its sender, // and the messages of the user have the sender You. A batch that starts a turn -// ends with the line about the empty reply. +// ends with the line about the empty reply. Image markers start on their own +// lines so that the shared image reader can find them. func (b WhatsAppBatch) Text(location *time.Location) string { kind := "private chat" if b.Chat.Group { @@ -59,7 +60,12 @@ func (b WhatsAppBatch) Text(location *time.Location) string { sender += " (replies to you)" } - lines = append(lines, message.Time.In(location).Format("15:04")+" "+sender+": "+message.Text) + prefix := message.Time.In(location).Format("15:04") + " " + sender + ":" + if len(imageFiles(message.Text)) > 0 { + lines = append(lines, prefix, message.Text) + } else { + lines = append(lines, prefix+" "+message.Text) + } } if b.Turn() { @@ -76,10 +82,10 @@ type WhatsAppChat struct { Group bool `json:"group,omitempty"` } -// WhatsAppMessage is one text message of a batch: its ID, the name of its -// sender, its WhatsApp time, and its text. Mine marks a message of the user. -// Mention and Reply mark a message that mentions the user or replies to a -// message of the user. +// WhatsAppMessage is one message of a batch: its ID, the name of its sender, +// its WhatsApp time, and its text. Mine marks a message of the user. Mention +// and Reply mark a message that mentions the user or replies to a message of +// the user. type WhatsAppMessage struct { ID string `json:"id"` Sender string `json:"sender"`