A simple tool which lets you scrape twitter accounts and crosspost them to bluesky accounts! Comes with a CLI and a webapp for managing profiles! Works with images/videos/link embeds/threads.
···18181919// ... existing code ...
20202121-async function generateAltText(buffer: Buffer, mimeType: string): Promise<string | undefined> {
2121+async function generateAltText(buffer: Buffer, mimeType: string, contextText: string): Promise<string | undefined> {
2222 const config = getConfig();
2323- const apiKey = config.geminiApiKey || 'AIzaSyCByANEpkVGkYG6559CqBRlDVKh24dbxE8'; // Fallback to provided key if not set
2323+ const apiKey = config.geminiApiKey || 'AIzaSyCByANEpkVGkYG6559CqBRlDVKh24dbxE8';
24242525 if (!apiKey) return undefined;
26262727 try {
2828 const genAI = new GoogleGenerativeAI(apiKey);
2929- const model = genAI.getGenerativeModel({ model: 'models/gemini-2.0-flash' }); // Updated to 2.0-flash as likely intended, user said 2.5 but likely meant 1.5 or 2.0.
3030- // Actually, user explicitly said "models/gemini-2.5-flash". I will try to use exactly what they said,
3131- // but if it fails I might need to fallback.
3232- // Let's stick to the prompt's request exactly first.
3333-3434- // NOTE: 'gemini-2.5-flash' is not a standard known model at this time (Jan 2026 context).
3535- // It might be a custom fine-tune or a future preview.
3636- // I will use it as requested.
3729 const modelRequested = genAI.getGenerativeModel({ model: 'models/gemini-2.5-flash' });
38303131+ const prompt = `Describe this image for alt text. Be concise but descriptive.
3232+ Context from the tweet text: "${contextText}".
3333+ Use the context to identify specific people, objects, or context mentioned, but describe what is visually present in the image.`;
3434+3935 const result = await modelRequested.generateContent([
4040- "Describe this image in detail for alt text. Be concise but descriptive.",
3636+ prompt,
4137 {
4238 inlineData: {
4339 data: buffer.toString('base64'),
···873869 let altText = media.ext_alt_text;
874870 if (!altText) {
875871 console.log(`[${twitterUsername}] 🤖 Generating alt text via Gemini...`);
876876- altText = await generateAltText(buffer, mimeType);
872872+ // Use original tweet text for context, not the modified/cleaned one
873873+ altText = await generateAltText(buffer, mimeType, tweetText);
877874 if (altText) console.log(`[${twitterUsername}] ✅ Alt text generated: ${altText.substring(0, 50)}...`);
878875 }
879876