feat: make /transfer bidirectional across telegram and tui
This commit is contained in:
+17
-7
@@ -238,15 +238,25 @@ export function registerTuiCommand(program: Command): void {
|
||||
});
|
||||
|
||||
const transferSessionToTarget = (target: string): string => {
|
||||
if (target !== 'telegram') {
|
||||
return `Unknown transfer target: ${target}`;
|
||||
const normalizedTarget = target.trim().toLowerCase();
|
||||
if (!normalizedTarget) {
|
||||
return 'Usage: /transfer <tui|telegram>';
|
||||
}
|
||||
if (!config.telegram || config.telegram.allowed_chat_ids.length === 0) {
|
||||
return 'Telegram not configured';
|
||||
|
||||
if (normalizedTarget === 'tui') {
|
||||
return 'Session is already active on TUI (local)';
|
||||
}
|
||||
const telegramUserId = String(config.telegram.allowed_chat_ids[0]);
|
||||
sessionManager.transferSession('tui', 'local', 'telegram', telegramUserId);
|
||||
return `Session transferred to Telegram (${telegramUserId})`;
|
||||
|
||||
if (normalizedTarget === 'telegram') {
|
||||
if (!config.telegram || config.telegram.allowed_chat_ids.length === 0) {
|
||||
return 'Telegram not configured';
|
||||
}
|
||||
const telegramUserId = String(config.telegram.allowed_chat_ids[0]);
|
||||
sessionManager.transferSession('tui', 'local', 'telegram', telegramUserId);
|
||||
return `Session transferred to Telegram (${telegramUserId})`;
|
||||
}
|
||||
|
||||
return `Unknown transfer target: ${target}. Supported targets: tui, telegram`;
|
||||
};
|
||||
|
||||
if (opts.fullscreen) {
|
||||
|
||||
Reference in New Issue
Block a user