mirror of
https://github.com/tiennm99/goclaw.git
synced 2026-10-13 22:15:47 +00:00
Photo/video/audio/document uploads were hitting "context deadline exceeded" mid-flight on slow or mobile networks. Two layers capped the budget at 60s: - sendOverallTimeout (wraps the whole retry sequence) - http.Client.Timeout (caps a single HTTP request) Both are fine for text sends but too tight for multi-MB uploads (sketchnote images, PDFs, long voice clips). Split the retry budget by method: text sends keep 60s, media sends (sendPhoto/Video/Audio/Voice/Document) get a new sendMediaOverallTimeout of 3 min. Bump the shared http.Client.Timeout to 3 min so a single upload attempt can actually consume that budget — getUpdates long-poll is 25s, so the extra headroom doesn't affect polling. Closes #628
30 lines
1.1 KiB
Go
30 lines
1.1 KiB
Go
package telegram
|
||
|
||
import "time"
|
||
|
||
const (
|
||
// telegramMaxMessageLen is the safe limit for Telegram messages.
|
||
// Telegram's hard limit is 4096, but we use 4000 for safety (matching TS textChunkLimit).
|
||
telegramMaxMessageLen = 4000
|
||
|
||
// telegramCaptionMaxLen is the max length for media captions.
|
||
telegramCaptionMaxLen = 1024
|
||
|
||
// pairingReplyDebounce is the minimum interval between pairing replies to the same user.
|
||
pairingReplyDebounce = 60 * time.Second
|
||
|
||
// sendOverallTimeout is the maximum duration for a multi-retry text send
|
||
// sequence. Text rarely needs more than a couple of seconds per attempt.
|
||
sendOverallTimeout = 60 * time.Second
|
||
|
||
// sendMediaOverallTimeout covers photo/video/audio/document uploads, where
|
||
// a single attempt can take 30–90s on slow/mobile networks for larger
|
||
// files. 60s was triggering "context deadline exceeded" mid-upload (#628)
|
||
// for multi-MB sketchnote/PDF attachments. 3 min gives three realistic
|
||
// retry attempts even on poor links.
|
||
sendMediaOverallTimeout = 3 * time.Minute
|
||
|
||
// probeOverallTimeout is the maximum duration for initial bot status check and command sync.
|
||
probeOverallTimeout = 60 * time.Second
|
||
)
|