fix: compatibility with telego v1.x (Context-based long polling)

This commit is contained in:
DBT
2026-02-12 03:26:49 +00:00
parent cad0a4de5b
commit 08c5e85a9c
2 changed files with 4 additions and 4 deletions

BIN
clawgo Executable file

Binary file not shown.

View File

@@ -58,7 +58,7 @@ func (c *TelegramChannel) SetTranscriber(transcriber *voice.GroqTranscriber) {
func (c *TelegramChannel) Start(ctx context.Context) error { func (c *TelegramChannel) Start(ctx context.Context) error {
log.Printf("Starting Telegram bot (polling mode)...") log.Printf("Starting Telegram bot (polling mode)...")
updates, err := c.bot.UpdatesViaLongPolling(nil) updates, err := c.bot.UpdatesViaLongPolling(ctx, nil)
if err != nil { if err != nil {
return fmt.Errorf("failed to start updates polling: %w", err) return fmt.Errorf("failed to start updates polling: %w", err)
} }
@@ -96,9 +96,9 @@ func (c *TelegramChannel) Stop(ctx context.Context) error {
log.Println("Stopping Telegram bot...") log.Println("Stopping Telegram bot...")
c.setRunning(false) c.setRunning(false)
if c.updates != nil { // In telego v1.x, the long polling is stopped by canceling the context
c.bot.StopLongPolling() // passed to UpdatesViaLongPolling. We don't need a separate Stop call
} // if we use the parent context correctly.
return nil return nil
} }