Telegram: stop bot on polling teardown

This commit is contained in:
liuxiaopai-ai
2026-03-02 09:30:26 +08:00
committed by Peter Steinberger
parent 666a4763ee
commit 042d06a19b
3 changed files with 33 additions and 1 deletions

View File

@@ -270,6 +270,13 @@ export async function monitorTelegramProvider(opts: MonitorTelegramOpts = {}) {
});
return stopPromise;
};
const stopBot = () => {
return Promise.resolve(bot.stop())
.then(() => undefined)
.catch(() => {
// Bot may already be stopped by runner stop/abort paths.
});
};
const stopOnAbort = () => {
if (opts.abortSignal?.aborted) {
void stopRunner();
@@ -309,6 +316,7 @@ export async function monitorTelegramProvider(opts: MonitorTelegramOpts = {}) {
} finally {
opts.abortSignal?.removeEventListener("abort", stopOnAbort);
await stopRunner();
await stopBot();
}
};