X-Git-Url: https://git.giacomolli.uk/onechat/blobdiff_plain/1e2df788bbb17653a6df44acd41da2edb109d403..d9fddc0f506eb4ead7049f5638674b2b8773fcaa:/telegram.go?ds=inline diff --git a/telegram.go b/telegram.go index 9d7600f..af1b91e 100644 --- a/telegram.go +++ b/telegram.go @@ -262,8 +262,8 @@ func (b *TelegramBot) poll(ctx context.Context, l *TurnLoop, whatsapp *WhatsApp) 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 @@ -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 { - 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 } @@ -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 { - 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 { - b.logger.Printf("a reply to Telegram is lost: %v", err) + b.logger.Printf("reply lost: %v", err) return } @@ -467,7 +467,7 @@ func (b *TelegramBot) deliverRich(ctx context.Context, markdown string) { } 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) } @@ -476,7 +476,7 @@ func (b *TelegramBot) deliverRich(ctx context.Context, markdown string) { } if !retry { - b.logger.Printf("a reply to Telegram is lost: %v", err) + b.logger.Printf("reply lost: %v", err) return } @@ -488,8 +488,8 @@ func (b *TelegramBot) deliverRich(ctx context.Context, markdown string) { 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.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. @@ -528,7 +528,7 @@ func (o *TelegramOutage) End() { 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{} }