]> git.giacomolli.uk - onechat/blobdiff - telegram.go
Rebuild agent memory in date order
[onechat] / telegram.go
index 9d7600fd44d89eef4f14340a5fc270208092ea77..af1b91e8a899aa8ef1f54f6344844574693eed91 100644 (file)
@@ -262,8 +262,8 @@ func (b *TelegramBot) poll(ctx context.Context, l *TurnLoop, whatsapp *WhatsApp)
 
        outage := &TelegramOutage{
                logger: b.logger,
 
        outage := &TelegramOutage{
                logger: b.logger,
-               loss:   "cannot get messages from Telegram",
-               back:   "messages from Telegram come again",
+               loss:   "receive failed",
+               back:   "receive back",
        }
 
        wait := b.minWait
        }
 
        wait := b.minWait
@@ -371,7 +371,7 @@ func (b *TelegramBot) pause(ctx context.Context, outage *TelegramOutage, err err
 func (b *TelegramBot) handle(ctx context.Context, l *TurnLoop, whatsapp *WhatsApp, update TelegramUpdate) error {
        message := update.Message
        if message == nil || message.Chat.Type != "private" || message.Chat.ID != b.owner || message.From == nil || message.From.ID != b.owner {
 func (b *TelegramBot) handle(ctx context.Context, l *TurnLoop, whatsapp *WhatsApp, update TelegramUpdate) error {
        message := update.Message
        if message == nil || message.Chat.Type != "private" || message.Chat.ID != b.owner || message.From == nil || message.From.ID != b.owner {
-               b.logger.Print("a Telegram message is ignored, because it is not from the owner in the private chat")
+               b.logger.Print("message ignored: not from the owner")
                return nil
        }
 
                return nil
        }
 
@@ -430,14 +430,14 @@ func (b *TelegramBot) deliver(ctx context.Context, part TelegramPart) {
 
                var answer *TelegramError
                if len(part.entities) > 0 && errors.As(err, &answer) && answer.Status == http.StatusBadRequest {
 
                var answer *TelegramError
                if len(part.entities) > 0 && errors.As(err, &answer) && answer.Status == http.StatusBadRequest {
-                       b.logger.Printf("a reply goes as plain text, because Telegram refused its formatting: %v", err)
+                       b.logger.Printf("reply sent as plain text: %v", err)
                        part.entities = nil
 
                        continue
                }
 
                if !retry {
                        part.entities = nil
 
                        continue
                }
 
                if !retry {
-                       b.logger.Printf("a reply to Telegram is lost: %v", err)
+                       b.logger.Printf("reply lost: %v", err)
                        return
                }
 
                        return
                }
 
@@ -467,7 +467,7 @@ func (b *TelegramBot) deliverRich(ctx context.Context, markdown string) {
                }
 
                if telegramRejected(err) {
                }
 
                if telegramRejected(err) {
-                       b.logger.Printf("a reply goes with simpler formatting, because Telegram refused its full formatting: %v", err)
+                       b.logger.Printf("reply sent with simple formatting: %v", err)
                        for _, part := range telegramReplyParts(telegramUnescapeTags(markdown)) {
                                b.deliver(ctx, part)
                        }
                        for _, part := range telegramReplyParts(telegramUnescapeTags(markdown)) {
                                b.deliver(ctx, part)
                        }
@@ -476,7 +476,7 @@ func (b *TelegramBot) deliverRich(ctx context.Context, markdown string) {
                }
 
                if !retry {
                }
 
                if !retry {
-                       b.logger.Printf("a reply to Telegram is lost: %v", err)
+                       b.logger.Printf("reply lost: %v", err)
                        return
                }
 
                        return
                }
 
@@ -488,8 +488,8 @@ func (b *TelegramBot) deliverRich(ctx context.Context, markdown string) {
 func (b *TelegramBot) sendOutage() *TelegramOutage {
        return &TelegramOutage{
                logger: b.logger,
 func (b *TelegramBot) sendOutage() *TelegramOutage {
        return &TelegramOutage{
                logger: b.logger,
-               loss:   "cannot send replies to Telegram",
-               back:   "replies go to Telegram again",
+               loss:   "send failed",
+               back:   "send back",
        }
 }
 
        }
 }
 
@@ -519,7 +519,7 @@ func (o *TelegramOutage) Fail(err error, delay time.Duration) {
        }
 
        o.start = time.Now()
        }
 
        o.start = time.Now()
-       o.logger.Printf("%s: %v (next try in %s)", o.loss, err, durationText(delay))
+       o.logger.Printf("%s: %v (retry in %s)", o.loss, err, durationText(delay))
 }
 
 // End logs the end of the outage that runs, with its length.
 }
 
 // End logs the end of the outage that runs, with its length.
@@ -528,7 +528,7 @@ func (o *TelegramOutage) End() {
                return
        }
 
                return
        }
 
-       o.logger.Printf("%s, after %s", o.back, durationText(time.Since(o.start)))
+       o.logger.Printf("%s after %s", o.back, durationText(time.Since(o.start)))
        o.start = time.Time{}
 }
 
        o.start = time.Time{}
 }