fix: panic stack without sender, log service error frames, refresh account on reconnect
- handler panic log includes the stack trace and no longer the sender number - error and exception frames from the service are logged at Warn level - Listen looks the account up again after a connection loss (re-link) - document that received but unhandled messages are lost at shutdown Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
788dd0b968
commit
b54aab1534
5 files changed
+162
-3
No files matched your search
@@ -57,7 +57,17 @@ err = client.Listen(ctx, func(ctx context.Context, m signalbot.Message) {
|
||||
`Listen` reconnects automatically (backoff 1s → 30s) and calls the handler
|
||||
for one message at a time, in arrival order. It ignores everything that is
|
||||
not a text message (receipts, typing, reactions, attachments, messages sent
|
||||
from the bot's own phone). A panic in the handler is recovered and logged.
|
||||
from the bot's own phone). A panic in the handler is recovered and logged
|
||||
with its stack trace; errors reported by the service (e.g. a message that
|
||||
could not be decrypted) are logged at Warn level.
|
||||
|
||||
Messages are acknowledged to Signal as soon as the service receives them:
|
||||
those already received but not yet handled when the context is cancelled
|
||||
are lost. Keep handlers short, or hand work off to your own queue.
|
||||
|
||||
The linked account is looked up once and cached. `Listen` looks it up again
|
||||
after each connection loss; for `Send` and `Groups`, create a new `Client`
|
||||
after linking a different account.
|
||||
|
||||
Options: `WithNumber` (choose an account when several are linked),
|
||||
`WithHTTPClient`, `WithLogger` (`*slog.Logger`, default `slog.Default()`).
|
||||
|
||||
Reference in new issue
Block a user