X-Git-Url: https://git.giacomolli.uk/onechat/blobdiff_plain/80e348724041a694002fc38f57e8868b9b9a2be9..f4509310b5abe5012cb83bed3960404e8fa92217:/whatsapp_batch.go?ds=sidebyside diff --git a/whatsapp_batch.go b/whatsapp_batch.go index dcdd712..16b4b2c 100644 --- a/whatsapp_batch.go +++ b/whatsapp_batch.go @@ -48,15 +48,6 @@ type WhatsAppMessage struct { Reply bool `json:"reply,omitempty"` } -// Turn tells if the batch starts a turn: a private batch with a message of -// another person, or a group batch with a message of another person that -// mentions the user or replies to a message of the user. -func (b WhatsAppBatch) Turn() bool { - return slices.ContainsFunc(b.Messages, func(message WhatsAppMessage) bool { - return !message.Mine && (!b.Chat.Group || message.Mention || message.Reply) - }) -} - // Text returns the text of the batch for the log, with the times in location. // 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, @@ -95,3 +86,12 @@ func (b WhatsAppBatch) Text(location *time.Location) string { return strings.Join(lines, "\n") } + +// Turn tells if the batch starts a turn: a private batch with a message of +// another person, or a group batch with a message of another person that +// mentions the user or replies to a message of the user. +func (b WhatsAppBatch) Turn() bool { + return slices.ContainsFunc(b.Messages, func(message WhatsAppMessage) bool { + return !message.Mine && (!b.Chat.Group || message.Mention || message.Reply) + }) +}