Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ext/updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,10 @@ func (u *Updater) Idle() {
//
// When using long polling, Stop() will wait for the getUpdates call to return, which may cause a delay due to the
// request timeout.
func (u *Updater) Stop() error {
func (u *Updater) Stop(ctx context.Context) error {
// Stop any running servers.
if u.webhookServer != nil {
err := u.webhookServer.Shutdown(context.Background())
err := u.webhookServer.Shutdown(ctx)
if err != nil {
return fmt.Errorf("failed to shutdown server: %w", err)
}
Expand Down
8 changes: 4 additions & 4 deletions ext/updater_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ func TestUpdaterAllowsWebhookDeletion(t *testing.T) {
return
}

err = u.Stop()
err = u.Stop(context.Background())
if err != nil {
t.Errorf("failed to stop updater: %v", err)
return
Expand Down Expand Up @@ -430,7 +430,7 @@ func TestUpdaterSupportsTwoPollingBots(t *testing.T) {
return
}

err = u.Stop()
err = u.Stop(context.Background())
if err != nil {
t.Errorf("failed to stop updater: %v", err)
return
Expand Down Expand Up @@ -478,7 +478,7 @@ func TestUpdaterThrowsErrorWhenSameLongPollAddedTwice(t *testing.T) {
return
}

err = u.Stop()
err = u.Stop(context.Background())
if err != nil {
t.Errorf("failed to stop updater: %v", err)
return
Expand Down Expand Up @@ -529,7 +529,7 @@ func TestUpdaterSupportsLongPollReAdding(t *testing.T) {
return
}

err = u.Stop()
err = u.Stop(context.Background())
if err != nil {
t.Errorf("failed to stop updater: %v", err)
return
Expand Down
3 changes: 2 additions & 1 deletion samples/echoMultiBot/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"context"
"fmt"
"log"
"log/slog"
Expand Down Expand Up @@ -186,7 +187,7 @@ func stopAll(b *gotgbot.Bot, ctx *ext.Context, updater *ext.Updater) error {

// We stop the updater in a separate goroutine, otherwise it would be stuck waiting for itself.
go func() {
err = updater.Stop()
err = updater.Stop(context.Background())
if err != nil {
ctx.EffectiveMessage.Reply(b, fmt.Sprintf("Failed to stop updater: %s", err.Error()), nil)
return
Expand Down