Add send-file directive and Discord/CLI file support (#319)

Co-authored-by: Jason Carreira <jason@visotrust.com>
Co-authored-by: Cameron <cameron@pfiffer.org>
Co-authored-by: Charles Packer <packercharles@gmail.com>
Co-authored-by: Sarah Wooders <sarahwooders@gmail.com>
Co-authored-by: Letta <noreply@letta.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Jason Carreira
2026-02-23 18:44:34 -05:00
committed by GitHub
parent ad4c22ba54
commit 1fbd6d5a2e
14 changed files with 364 additions and 22 deletions

View File

@@ -252,6 +252,7 @@ async function sendCommand(args: string[]): Promise<void> {
let kind: 'image' | 'file' | undefined = undefined;
let channel = '';
let chatId = '';
const fileCapableChannels = new Set(['telegram', 'slack', 'discord', 'whatsapp']);
// Parse args
for (let i = 0; i < args.length; i++) {
@@ -304,16 +305,16 @@ async function sendCommand(args: string[]): Promise<void> {
}
try {
// Use API for WhatsApp (unified multipart endpoint)
if (channel === 'whatsapp') {
if (filePath) {
if (!fileCapableChannels.has(channel)) {
throw new Error(`File sending not supported for ${channel}. Supported: telegram, slack, discord, whatsapp`);
}
await sendViaApi(channel, chatId, { text, filePath, kind });
} else if (filePath) {
// Other channels with files - not yet implemented via API
throw new Error(`File sending for ${channel} requires API (currently only WhatsApp supported via API)`);
} else {
// Other channels with text only - direct API calls
await sendToChannel(channel, chatId, text);
return;
}
// Text-only: direct platform APIs (WhatsApp uses API internally)
await sendToChannel(channel, chatId, text);
} catch (error) {
console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);
process.exit(1);
@@ -359,7 +360,8 @@ Environment variables:
LETTABOT_API_URL API server URL (default: http://localhost:8080)
SIGNAL_CLI_REST_API_URL Signal daemon URL (default: http://127.0.0.1:8090)
Note: WhatsApp uses the API server. Other channels use direct platform APIs.
Note: File sending uses the API server for supported channels (telegram, slack, discord, whatsapp).
Text-only messages use direct platform APIs (WhatsApp uses API).
`);
}