summaryrefslogtreecommitdiffstats
path: root/internal/bot/bot.go
diff options
context:
space:
mode:
authorMurilo Ijanc <[email protected]>2026-07-27 21:12:05 -0300
committerMurilo Ijanc <[email protected]>2026-07-27 21:12:05 -0300
commit97b49ae7081b989274b313532ff17c71694097a9 (patch)
tree6595e0d5a39d04971a71e886bc3f8cc589741f5d /internal/bot/bot.go
parent83ce95cf10fd9e9d581362453c558239d37ae06e (diff)
downloadtelegram-main.tar.gz
Read the faixa from the client instead of fetching it againHEADv0.2.1main
cep.is/go v0.2.0 exposes the municipality as Error.Faixa, which is what internal/lookup existed to work around: v0.1.0 discarded the 404 body, so the bot re-issued the request just to read the block back. The extra GET on the 404 path is gone, and with it the second timeout, the body size cap and the "is it still a 404?" check that guarded it. The replies are byte for byte what they were -- the formatting tests did not change a single assertion, only the type they build.
Diffstat (limited to 'internal/bot/bot.go')
-rw-r--r--internal/bot/bot.go8
1 files changed, 3 insertions, 5 deletions
diff --git a/internal/bot/bot.go b/internal/bot/bot.go
index 4abf02c..b361841 100644
--- a/internal/bot/bot.go
+++ b/internal/bot/bot.go
@@ -13,15 +13,13 @@ import (
cepis "cep.is/go"
- "cep.is/telegrambot/internal/lookup"
"cep.is/telegrambot/internal/telegram"
)
// Lookups is the subset of the cep.is client this bot needs. Depending on the
// interface rather than the concrete client keeps the seam narrow and visible.
//
-// A failure may be a [*lookup.NotFoundError], which still matches
-// cepis.ErrCEPNotFound and additionally names the municipality the CEP would
+// A failure may be a [*cepis.Error] carrying the municipality the CEP would
// belong to; nothing here has to know that, because [ErrorMessage] reads it.
type Lookups interface {
Lookup(ctx context.Context, cep string) (*cepis.Address, error)
@@ -273,8 +271,8 @@ func inlineErrorTitle(err error) string {
// Titles and descriptions are plain text for Telegram, so nothing here is
// escaped: HTML applies to the message body alone.
func inlineErrorDescription(err error) string {
- if faixa := lookup.FaixaOf(err); faixa != nil {
- return "Cairia em " + faixa.Place() + " — toque para ver"
+ if faixa := faixaOf(err); faixa != nil {
+ return "Cairia em " + place(faixa) + " — toque para ver"
}
return "Toque para enviar o motivo"
}