Documentation
¶
Overview ¶
Package writes implements the shared safety pipeline every Telegram-side write command goes through, mirroring the Python flow in tgcli.commands.messages._run_write_command and the gates in tgcli.safety.
The pipeline order is fixed (changing it changes the contract):
- Write gate (--allow-write or TG_ALLOW_WRITE=1, --read-only blocks even with allow)
- Idempotency lookup (cached envelope replay short-circuits before resolve)
- Fuzzy gate (--fuzzy required for non-int / non-@username selectors)
- Resolver (DB-only int / @username / fuzzy title)
- Dry-run (returns payload preview before any client call or rate limiter)
- Local rate limiter (sliding 20 / 60s)
- Audit pre (NDJSON line, shared request_id)
- Telegram call
- Idempotency record (so a replay returns the same envelope data)
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type PipelineInput ¶
type PipelineInput struct {
Cmd string
RawSelector string
Args Args
DBPath string
AuditPath string
TelethonMethod string
// PayloadPreview is what the dry-run envelope returns and what shows up in audit_pre.
PayloadPreview map[string]any
// Run is the Telegram-side action. It receives the resolved chat id/title
// and returns the success-envelope `data` map.
Run func(ctx context.Context, chatID int64, chatTitle string) (map[string]any, error)
}
PipelineInput is what the caller hands the pipeline.
Click to show internal directories.
Click to hide internal directories.