mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-30 03:11:10 +00:00
fix(regression): preserve Telegram status fallback without runtime
This commit is contained in:
@@ -8,7 +8,7 @@ import * as auditModule from "./audit.js";
|
||||
import { telegramPlugin } from "./channel.js";
|
||||
import * as monitorModule from "./monitor.js";
|
||||
import * as probeModule from "./probe.js";
|
||||
import { setTelegramRuntime } from "./runtime.js";
|
||||
import { clearTelegramRuntime, setTelegramRuntime } from "./runtime.js";
|
||||
|
||||
const probeTelegramMock = vi.hoisted(() => vi.fn());
|
||||
const collectTelegramUnmentionedGroupIdsMock = vi.hoisted(() => vi.fn());
|
||||
@@ -292,6 +292,29 @@ describe("telegramPlugin duplicate token guard", () => {
|
||||
expect(monitorTelegramProvider).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("falls back to direct probe helpers when Telegram runtime is uninitialized", async () => {
|
||||
try {
|
||||
clearTelegramRuntime();
|
||||
const cfg = createCfg();
|
||||
const account = resolveAccount(cfg, "ops");
|
||||
|
||||
await expect(
|
||||
telegramPlugin.status!.probeAccount!({
|
||||
account,
|
||||
timeoutMs: 1234,
|
||||
cfg,
|
||||
}),
|
||||
).resolves.toEqual(
|
||||
expect.objectContaining({
|
||||
ok: expect.any(Boolean),
|
||||
elapsedMs: expect.any(Number),
|
||||
}),
|
||||
);
|
||||
} finally {
|
||||
installTelegramRuntime();
|
||||
}
|
||||
});
|
||||
|
||||
it("passes account proxy and network settings into Telegram probes", async () => {
|
||||
installGatewayRuntime();
|
||||
probeTelegramMock.mockResolvedValue({
|
||||
|
||||
@@ -92,7 +92,14 @@ type TelegramStatusRuntimeHelpers = {
|
||||
};
|
||||
|
||||
function getTelegramStatusRuntimeHelpers(): TelegramStatusRuntimeHelpers {
|
||||
return (getTelegramRuntime().channel?.telegram ?? {}) as TelegramStatusRuntimeHelpers;
|
||||
try {
|
||||
return (getTelegramRuntime().channel?.telegram ?? {}) as TelegramStatusRuntimeHelpers;
|
||||
} catch (error) {
|
||||
if (error instanceof Error && error.message === "Telegram runtime not initialized") {
|
||||
return {};
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
function resolveTelegramProbe() {
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import type { PluginRuntime } from "openclaw/plugin-sdk/core";
|
||||
import { createPluginRuntimeStore } from "openclaw/plugin-sdk/runtime-store";
|
||||
|
||||
const { setRuntime: setTelegramRuntime, getRuntime: getTelegramRuntime } =
|
||||
createPluginRuntimeStore<PluginRuntime>("Telegram runtime not initialized");
|
||||
export { getTelegramRuntime, setTelegramRuntime };
|
||||
const {
|
||||
setRuntime: setTelegramRuntime,
|
||||
clearRuntime: clearTelegramRuntime,
|
||||
getRuntime: getTelegramRuntime,
|
||||
} = createPluginRuntimeStore<PluginRuntime>("Telegram runtime not initialized");
|
||||
export { clearTelegramRuntime, getTelegramRuntime, setTelegramRuntime };
|
||||
|
||||
Reference in New Issue
Block a user