Skip to content

Commit e3ae51d

Browse files
ernadoclaude
andcommitted
docs: note session storage is effectively mandatory (FLOOD_WAIT)
Without a persisted session every Run re-authorizes the bot and Telegram rate-limits repeated logins with a growing FLOOD_WAIT. Document this on Options.Storage, the package doc and CLAUDE.md. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent b44ae78 commit e3ae51d

3 files changed

Lines changed: 22 additions & 3 deletions

File tree

CLAUDE.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ can't back the `peers.Peer` that chat-management methods need.
8888
front end.
8989
- `storage/``BBoltStorage`, one bbolt file holding session + peer cache + update state. The
9090
composite `Storage` interface (in `options.go`) requires all of those; `Options.Storage` is
91-
optional and everything stays in memory when nil.
91+
optional and everything stays in memory when nil — but is effectively mandatory in production:
92+
without a persisted session every `Run` re-authorizes the bot and Telegram answers repeated
93+
logins with a growing `FLOOD_WAIT`.
9294
- `internal/botdoc/` + `cmd/botdoc/` — fetch/extract the published Bot API docs. Kept as a reference
9395
oracle and as a conformance check (`conformance_test.go`) that catches *unacknowledged* drift
9496
between the hand-written surface and the published API.

doc.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,16 @@
4949
// helpers Code, AsFloodWait and AsChatMigrated. Context cancellation passes
5050
// through unchanged so callers can errors.Is on ctx.Err().
5151
//
52+
// # Persistence
53+
//
54+
// With no Options.Storage everything is kept in memory and nothing survives a
55+
// restart. Providing a Storage (storage.BBoltStorage satisfies it) is strongly
56+
// recommended for any long-lived bot: without a persisted session every Run
57+
// re-authorizes the bot, and Telegram rate-limits repeated logins with
58+
// FLOOD_WAIT — which grows with each retry and can lock the bot out on restart
59+
// loops. Persisting the session lets the bot reuse its authorization instead of
60+
// logging in again.
61+
//
5262
// # Sealed unions
5363
//
5464
// Where the Bot API uses "one of" objects (ChatID, InputFile, ReplyMarkup,

options.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,15 @@ type Options struct {
3838
// Device describes the client to Telegram. Optional.
3939
Device telegram.DeviceConfig
4040

41-
// Storage persists session, peers and update state. Optional; in-memory if
42-
// nil (nothing survives a restart).
41+
// Storage persists session, peers and update state. In-memory if nil, in
42+
// which case nothing survives a restart.
43+
//
44+
// Providing a Storage is strongly recommended for any long-lived bot:
45+
// without a persisted session every Run starts a fresh one and re-authorizes
46+
// the bot, and Telegram rate-limits repeated logins with FLOOD_WAIT, which
47+
// grows with each retry and can lock the bot out on restart loops. With a
48+
// persisted session the bot reuses its authorization instead of logging in
49+
// again.
4350
Storage Storage
4451

4552
// OnStart is called once, after the bot is authorized and update gap

0 commit comments

Comments
 (0)