chenhg5/cc-connect · warning
telegram: %s: bot not connected
Error message
telegram: %s: bot not connected
What it means
connectedBot(action) returns this error when a send-side operation (reactToMessage, handleCallbackQuery, Reply, Send, SendImage, SendFile) is attempted while p.bot is nil — i.e., the platform has not finished connecting or the connection was lost. The action name is interpolated to identify the failing call.
Source
Thrown at platform/telegram/telegram.go:728
notify := false
p.mu.Lock()
if p.bot == b && p.generation == gen {
p.bot = nil
p.selfUser = nil
notify = !p.stopping
}
p.mu.Unlock()
if notify {
p.notifyUnavailable(fmt.Errorf("telegram: connection lost"))
}
}
func (p *Platform) connectedBot(action string) (telegramBot, error) {
p.mu.RLock()
defer p.mu.RUnlock()
if p.bot == nil {
return nil, fmt.Errorf("telegram: %s: bot not connected", action)
}
return p.bot, nil
}
func (p *Platform) botUsername() string {
p.mu.RLock()
defer p.mu.RUnlock()
if p.selfUser == nil {
return ""
}
return p.selfUser.Username
}
func (p *Platform) hasEverConnected() bool {
p.mu.RLock()
defer p.mu.RUnlock()
return p.everConnected
}View on GitHub (pinned to 4000b2338a)
Solutions
- Wait for the platform to (re)connect before sending; check the availability/unavailable notification state
- Add caller-side retry with backoff for transient bot-not-connected windows
- Verify Start() was called and succeeded (no token/network errors earlier)
- Check network issues that caused the connection loss
Example fix
// before
if err := plat.Send(ctx, chatID, text); err != nil { return err }
// after
if err := plat.Send(ctx, chatID, text); err != nil {
if strings.Contains(err.Error(), "bot not connected") {
time.Sleep(backoff)
return plat.Send(ctx, chatID, text)
}
return err
} Defensive patterns
Strategy: retry
Try / catch
if err := plat.Send(ctx, chatID, text); err != nil {
if strings.Contains(err.Error(), "bot not connected") {
time.Sleep(2 * time.Second)
return plat.Send(ctx, chatID, text)
}
return err
} Prevention
- Don't send before Start() completes successfully
- Buffer/queue messages while the platform reports unavailable
- Retry with backoff on this transient error
- Watch for connection-loss notifications as a signal to pause sends
When it happens
Trigger: Calling Reply/Send/SendImage/SendFile (or reaction/callback handlers) before Start() completed the first connection, or after a connection loss cleared the bot but before reconnect succeeded.
Common situations: Messages queued by the engine during a network outage get rejected; a reply arrives for a session while the bot is reconnecting; platform started but still in backoff.
Related errors
- telegram: platform stopped
- telegram: connect failed: %w
- telegram: connection lost
- connect permission bridge: %w
- session process is not running
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/fd394f4be81c9f9c.
Report an issue: GitHub.