refactor: make telegram config optional for non-telegram setups
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -163,6 +163,9 @@ const checkTelegram: Check = async (ctx) => {
|
||||
if (!ctx.config) {
|
||||
return { status: 'skip', label: 'Telegram bot configured', detail: '(config invalid)' };
|
||||
}
|
||||
if (!ctx.config.telegram) {
|
||||
return { status: 'skip', label: 'Telegram bot configured', detail: '(not configured)' };
|
||||
}
|
||||
if (!ctx.config.telegram.bot_token || ctx.config.telegram.bot_token.length < 10) {
|
||||
return { status: 'warn', label: 'Telegram bot configured', detail: 'token looks too short' };
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ models:
|
||||
const result = loadConfigSafe(configPath);
|
||||
expect(result.config).toBeDefined();
|
||||
expect(result.error).toBeUndefined();
|
||||
expect(result.config!.telegram.bot_token).toBe('test-token');
|
||||
expect(result.config!.telegram?.bot_token).toBe('test-token');
|
||||
});
|
||||
|
||||
it('returns error when file not found', () => {
|
||||
|
||||
+3
-1
@@ -29,7 +29,9 @@ export function registerStartCommand(program: Command): void {
|
||||
const { startDaemon } = await import('../daemon/index.js');
|
||||
const daemon = await startDaemon(config);
|
||||
|
||||
console.log(`Allowed Telegram chat IDs: ${config.telegram.allowed_chat_ids.join(', ')}`);
|
||||
if (config.telegram) {
|
||||
console.log(`Allowed Telegram chat IDs: ${config.telegram.allowed_chat_ids.join(', ')}`);
|
||||
}
|
||||
|
||||
// Keep process alive
|
||||
await new Promise<void>((resolve) => {
|
||||
|
||||
+7
-3
@@ -154,9 +154,13 @@ export function registerTuiCommand(program: Command): void {
|
||||
currentLocalProvider: config.models.local?.provider,
|
||||
onTransfer: (target) => {
|
||||
if (target === 'telegram') {
|
||||
const telegramUserId = String(config.telegram.allowed_chat_ids[0]);
|
||||
sessionManager.transferSession('tui', 'local', 'telegram', telegramUserId);
|
||||
console.log(`Session transferred to Telegram (${telegramUserId})\n`);
|
||||
if (config.telegram && config.telegram.allowed_chat_ids.length > 0) {
|
||||
const telegramUserId = String(config.telegram.allowed_chat_ids[0]);
|
||||
sessionManager.transferSession('tui', 'local', 'telegram', telegramUserId);
|
||||
console.log(`Session transferred to Telegram (${telegramUserId})\n`);
|
||||
} else {
|
||||
console.log('Telegram not configured\n');
|
||||
}
|
||||
} else {
|
||||
console.log(`Unknown transfer target: ${target}\n`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user