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
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
}
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
}
}
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)
}
}
if !retry {
- b.logger.Printf("a reply to Telegram is lost: %v", err)
+ b.logger.Printf("reply lost: %v", err)
return
}
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",
}
}
}
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.
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{}
}