chore: rename project to clawdbot
This commit is contained in:
@@ -89,7 +89,7 @@ describe("telegram inbound media", () => {
|
||||
photo: [{ file_id: "fid" }],
|
||||
date: 1736380800, // 2025-01-09T00:00:00Z
|
||||
},
|
||||
me: { username: "clawdis_bot" },
|
||||
me: { username: "clawdbot_bot" },
|
||||
getFile: async () => ({ file_path: "photos/1.jpg" }),
|
||||
});
|
||||
|
||||
@@ -145,7 +145,7 @@ describe("telegram inbound media", () => {
|
||||
chat: { id: 1234, type: "private" },
|
||||
photo: [{ file_id: "fid" }],
|
||||
},
|
||||
me: { username: "clawdis_bot" },
|
||||
me: { username: "clawdbot_bot" },
|
||||
getFile: async () => ({ file_path: "photos/2.jpg" }),
|
||||
});
|
||||
|
||||
@@ -191,7 +191,7 @@ describe("telegram inbound media", () => {
|
||||
chat: { id: 1234, type: "private" },
|
||||
photo: [{ file_id: "fid" }],
|
||||
},
|
||||
me: { username: "clawdis_bot" },
|
||||
me: { username: "clawdbot_bot" },
|
||||
getFile: async () => ({}),
|
||||
});
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ describe("createTelegramBot", () => {
|
||||
};
|
||||
await handler({
|
||||
message,
|
||||
me: { username: "clawdis_bot" },
|
||||
me: { username: "clawdbot_bot" },
|
||||
getFile: async () => ({ download: async () => new Uint8Array() }),
|
||||
});
|
||||
|
||||
@@ -115,7 +115,7 @@ describe("createTelegramBot", () => {
|
||||
) => Promise<void>;
|
||||
await handler({
|
||||
message: { chat: { id: 42, type: "private" }, text: "hi" },
|
||||
me: { username: "clawdis_bot" },
|
||||
me: { username: "clawdbot_bot" },
|
||||
getFile: async () => ({ download: async () => new Uint8Array() }),
|
||||
});
|
||||
|
||||
@@ -146,7 +146,7 @@ describe("createTelegramBot", () => {
|
||||
from: { first_name: "Ada" },
|
||||
},
|
||||
},
|
||||
me: { username: "clawdis_bot" },
|
||||
me: { username: "clawdbot_bot" },
|
||||
getFile: async () => ({ download: async () => new Uint8Array() }),
|
||||
});
|
||||
|
||||
@@ -179,7 +179,7 @@ describe("createTelegramBot", () => {
|
||||
date: 1736380800,
|
||||
message_id: 101,
|
||||
},
|
||||
me: { username: "clawdis_bot" },
|
||||
me: { username: "clawdbot_bot" },
|
||||
getFile: async () => ({ download: async () => new Uint8Array() }),
|
||||
});
|
||||
|
||||
@@ -212,7 +212,7 @@ describe("createTelegramBot", () => {
|
||||
date: 1736380800,
|
||||
message_id: 101,
|
||||
},
|
||||
me: { username: "clawdis_bot" },
|
||||
me: { username: "clawdbot_bot" },
|
||||
getFile: async () => ({ download: async () => new Uint8Array() }),
|
||||
});
|
||||
|
||||
@@ -247,7 +247,7 @@ describe("createTelegramBot", () => {
|
||||
date: 1736380800,
|
||||
message_id: 101,
|
||||
},
|
||||
me: { username: "clawdis_bot" },
|
||||
me: { username: "clawdbot_bot" },
|
||||
getFile: async () => ({ download: async () => new Uint8Array() }),
|
||||
});
|
||||
|
||||
@@ -278,7 +278,7 @@ describe("createTelegramBot", () => {
|
||||
text: "hello",
|
||||
date: 1736380800,
|
||||
},
|
||||
me: { username: "clawdis_bot" },
|
||||
me: { username: "clawdbot_bot" },
|
||||
getFile: async () => ({ download: async () => new Uint8Array() }),
|
||||
});
|
||||
|
||||
@@ -311,7 +311,7 @@ describe("createTelegramBot", () => {
|
||||
text: "hello",
|
||||
date: 1736380800,
|
||||
},
|
||||
me: { username: "clawdis_bot" },
|
||||
me: { username: "clawdbot_bot" },
|
||||
getFile: async () => ({ download: async () => new Uint8Array() }),
|
||||
});
|
||||
|
||||
@@ -341,7 +341,7 @@ describe("createTelegramBot", () => {
|
||||
text: "hello",
|
||||
date: 1736380800,
|
||||
},
|
||||
me: { username: "clawdis_bot" },
|
||||
me: { username: "clawdbot_bot" },
|
||||
getFile: async () => ({ download: async () => new Uint8Array() }),
|
||||
});
|
||||
|
||||
|
||||
@@ -4,11 +4,11 @@ import path from "node:path";
|
||||
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
import type { ClawdisConfig } from "../config/config.js";
|
||||
import type { ClawdbotConfig } from "../config/config.js";
|
||||
import { resolveTelegramToken } from "./token.js";
|
||||
|
||||
function withTempDir(): string {
|
||||
return fs.mkdtempSync(path.join(os.tmpdir(), "clawdis-telegram-token-"));
|
||||
return fs.mkdtempSync(path.join(os.tmpdir(), "clawdbot-telegram-token-"));
|
||||
}
|
||||
|
||||
describe("resolveTelegramToken", () => {
|
||||
@@ -18,7 +18,7 @@ describe("resolveTelegramToken", () => {
|
||||
|
||||
it("prefers env token over config", () => {
|
||||
vi.stubEnv("TELEGRAM_BOT_TOKEN", "env-token");
|
||||
const cfg = { telegram: { botToken: "cfg-token" } } as ClawdisConfig;
|
||||
const cfg = { telegram: { botToken: "cfg-token" } } as ClawdbotConfig;
|
||||
const res = resolveTelegramToken(cfg);
|
||||
expect(res.token).toBe("env-token");
|
||||
expect(res.source).toBe("env");
|
||||
@@ -29,7 +29,7 @@ describe("resolveTelegramToken", () => {
|
||||
const dir = withTempDir();
|
||||
const tokenFile = path.join(dir, "token.txt");
|
||||
fs.writeFileSync(tokenFile, "file-token\n", "utf-8");
|
||||
const cfg = { telegram: { tokenFile } } as ClawdisConfig;
|
||||
const cfg = { telegram: { tokenFile } } as ClawdbotConfig;
|
||||
const res = resolveTelegramToken(cfg);
|
||||
expect(res.token).toBe("file-token");
|
||||
expect(res.source).toBe("tokenFile");
|
||||
@@ -38,7 +38,7 @@ describe("resolveTelegramToken", () => {
|
||||
|
||||
it("falls back to config token when no env or tokenFile", () => {
|
||||
vi.stubEnv("TELEGRAM_BOT_TOKEN", "");
|
||||
const cfg = { telegram: { botToken: "cfg-token" } } as ClawdisConfig;
|
||||
const cfg = { telegram: { botToken: "cfg-token" } } as ClawdbotConfig;
|
||||
const res = resolveTelegramToken(cfg);
|
||||
expect(res.token).toBe("cfg-token");
|
||||
expect(res.source).toBe("config");
|
||||
@@ -50,7 +50,7 @@ describe("resolveTelegramToken", () => {
|
||||
const tokenFile = path.join(dir, "missing-token.txt");
|
||||
const cfg = {
|
||||
telegram: { tokenFile, botToken: "cfg-token" },
|
||||
} as ClawdisConfig;
|
||||
} as ClawdbotConfig;
|
||||
const res = resolveTelegramToken(cfg);
|
||||
expect(res.token).toBe("");
|
||||
expect(res.source).toBe("none");
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import fs from "node:fs";
|
||||
|
||||
import type { ClawdisConfig } from "../config/config.js";
|
||||
import type { ClawdbotConfig } from "../config/config.js";
|
||||
|
||||
export type TelegramTokenSource = "env" | "tokenFile" | "config" | "none";
|
||||
|
||||
@@ -15,7 +15,7 @@ type ResolveTelegramTokenOpts = {
|
||||
};
|
||||
|
||||
export function resolveTelegramToken(
|
||||
cfg?: ClawdisConfig,
|
||||
cfg?: ClawdbotConfig,
|
||||
opts: ResolveTelegramTokenOpts = {},
|
||||
): TelegramTokenResolution {
|
||||
const envToken = (opts.envToken ?? process.env.TELEGRAM_BOT_TOKEN)?.trim();
|
||||
|
||||
Reference in New Issue
Block a user