mirror of
https://github.com/YspCoder/clawgo.git
synced 2026-05-07 09:47:35 +08:00
fix: compatibility with telego v1.x (Context-based long polling)
This commit is contained in:
@@ -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
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user