]> git.giacomolli.uk - onechat/blobdiff - whatsapp_batch.go
Sync agent queue replacements before success
[onechat] / whatsapp_batch.go
index 7f43a3cfcbd8922a7fc7108000f6b4697a178400..16b4b2c3953ec1fde980c08b104867e3fb16cde7 100644 (file)
@@ -27,13 +27,25 @@ type WhatsAppBatch struct {
        Messages []WhatsAppMessage `json:"messages"`
 }
 
-// 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)
-       })
+// WhatsAppChat is a chat: its ID, its name, and whether it is a group.
+type WhatsAppChat struct {
+       ID    string `json:"id"`
+       Name  string `json:"name"`
+       Group bool   `json:"group,omitempty"`
+}
+
+// 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"`
+       Time    time.Time `json:"time"`
+       Text    string    `json:"text"`
+       Mine    bool      `json:"mine,omitempty"`
+       Mention bool      `json:"mention,omitempty"`
+       Reply   bool      `json:"reply,omitempty"`
 }
 
 // Text returns the text of the batch for the log, with the times in location.
@@ -75,23 +87,11 @@ func (b WhatsAppBatch) Text(location *time.Location) string {
        return strings.Join(lines, "\n")
 }
 
-// WhatsAppChat is a chat: its ID, its name, and whether it is a group.
-type WhatsAppChat struct {
-       ID    string `json:"id"`
-       Name  string `json:"name"`
-       Group bool   `json:"group,omitempty"`
-}
-
-// 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"`
-       Time    time.Time `json:"time"`
-       Text    string    `json:"text"`
-       Mine    bool      `json:"mine,omitempty"`
-       Mention bool      `json:"mention,omitempty"`
-       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)
+       })
 }