]> git.giacomolli.uk - onechat/blobdiff - whatsapp.go
Log the start and the length of each subagent run
[onechat] / whatsapp.go
index 2c1b6cb9aaa70e327fd4a342d282fb97ecd4a247..40729d83b044e8ca1303c2a1b08a10786d587e40 100644 (file)
@@ -405,7 +405,7 @@ func (w *WhatsApp) connect(ctx context.Context) {
 
        err := client.ConnectContext(ctx)
        if err != nil {
 
        err := client.ConnectContext(ctx)
        if err != nil {
-               w.logger.Printf("WhatsApp messages do not come, because the connection failed, and it is tried again only at a restart of the daemon: %s", w.redact(err.Error()))
+               w.logger.Printf("connect failed, restart to retry: %s", w.redact(err.Error()))
        }
 }
 
        }
 }
 
@@ -435,7 +435,7 @@ func (w *WhatsApp) loggedOut(ctx context.Context, l *TurnLoop) error {
                return nil
        }
 
                return nil
        }
 
-       w.logger.Print("WhatsApp messages stop, because the phone logged out this device (run /whatsapp pair PHONE to link it again)")
+       w.logger.Print("logged out by the phone, run /whatsapp pair PHONE")
        err := w.inbox.deliver(ctx, l, w.link(), true)
        if err != nil {
                return err
        err := w.inbox.deliver(ctx, l, w.link(), true)
        if err != nil {
                return err
@@ -443,12 +443,12 @@ func (w *WhatsApp) loggedOut(ctx context.Context, l *TurnLoop) error {
 
        err = w.removeSession()
        if err != nil {
 
        err = w.removeSession()
        if err != nil {
-               w.logger.Printf("the session of the logged out device stays on the disk, because its delete failed: %v", err)
+               w.logger.Printf("session delete failed: %v", err)
        }
 
        err = l.note("WhatsApp was unlinked from the phone.")
        if err != nil {
        }
 
        err = l.note("WhatsApp was unlinked from the phone.")
        if err != nil {
-               w.logger.Printf("the chat has no note of the logout, because its write failed: %v", err)
+               w.logger.Printf("chat note failed: %v", err)
        }
 
        w.broadcast("WhatsApp was unlinked from the phone. Run /whatsapp pair PHONE to link it again.")
        }
 
        w.broadcast("WhatsApp was unlinked from the phone. Run /whatsapp pair PHONE to link it again.")
@@ -491,10 +491,10 @@ func (w *WhatsApp) unlink(ctx context.Context, l *TurnLoop, answer func(text str
                return nil
        }
 
                return nil
        }
 
-       w.logger.Print("WhatsApp messages stop, because the user unlinked WhatsApp")
+       w.logger.Print("unlinked")
        err = l.note("WhatsApp is unlinked.")
        if err != nil {
        err = l.note("WhatsApp is unlinked.")
        if err != nil {
-               w.logger.Printf("the chat has no note of the unlink, because its write failed: %v", err)
+               w.logger.Printf("chat note failed: %v", err)
        }
 
        if client == nil || logoutErr != nil {
        }
 
        if client == nil || logoutErr != nil {
@@ -631,11 +631,11 @@ func (w *WhatsApp) pair(ctx, runCtx context.Context, l *TurnLoop, phone string,
                case item.Event == whatsmeow.QRChannelSuccess.Event:
                        linked = true
                        w.linkedBy(client)
                case item.Event == whatsmeow.QRChannelSuccess.Event:
                        linked = true
                        w.linkedBy(client)
-                       w.logger.Print("WhatsApp is linked")
+                       w.logger.Print("linked")
 
                        err = l.note("WhatsApp is linked.")
                        if err != nil {
 
                        err = l.note("WhatsApp is linked.")
                        if err != nil {
-                               w.logger.Printf("the chat has no note of the link, because its write failed: %v", err)
+                               w.logger.Printf("chat note failed: %v", err)
                        }
 
                        answer("WhatsApp is linked to +" + phone + ".")
                        }
 
                        answer("WhatsApp is linked to +" + phone + ".")
@@ -732,9 +732,9 @@ func (w *WhatsApp) handle(event any) bool {
                switch {
                case !w.linked || w.connected:
                case w.disconnectedAt.IsZero():
                switch {
                case !w.linked || w.connected:
                case w.disconnectedAt.IsZero():
-                       line = "WhatsApp is connected, and new messages come in"
+                       line = "connected"
                default:
                default:
-                       line = "WhatsApp is connected again, after " + durationText(w.clock().Sub(w.disconnectedAt))
+                       line = "connected again after " + durationText(w.clock().Sub(w.disconnectedAt))
                }
 
                w.connected = true
                }
 
                w.connected = true
@@ -749,9 +749,9 @@ func (w *WhatsApp) handle(event any) bool {
                }
        case *events.Disconnected:
                if w.linked && (w.connected || w.disconnectedAt.IsZero()) {
                }
        case *events.Disconnected:
                if w.linked && (w.connected || w.disconnectedAt.IsZero()) {
-                       line = "new WhatsApp messages wait, because the connection is lost (the next try is automatic)"
+                       line = "disconnected, retrying"
                        if !w.connected {
                        if !w.connected {
-                               line = "new WhatsApp messages wait, because the first connection failed (the next try is automatic)"
+                               line = "first connect failed, retrying"
                        }
 
                        w.disconnectedAt = w.clock()
                        }
 
                        w.disconnectedAt = w.clock()
@@ -773,7 +773,7 @@ func (w *WhatsApp) handle(event any) bool {
                        w.connected = false
                        w.noticed = true
                        notice = "WhatsApp is disconnected and does not connect again by itself: " + event.PermanentDisconnectDescription() + ". Restart the daemon to try again."
                        w.connected = false
                        w.noticed = true
                        notice = "WhatsApp is disconnected and does not connect again by itself: " + event.PermanentDisconnectDescription() + ". Restart the daemon to try again."
-                       line = "WhatsApp messages do not come, because the connection is lost and it is tried again only at a restart of the daemon: " + whatsappRedact(w.own, event.PermanentDisconnectDescription())
+                       line = "disconnected for good, restart to retry: " + whatsappRedact(w.own, event.PermanentDisconnectDescription())
                }
        }
 
                }
        }