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.
···1819// ... existing code ...
2021-async function generateAltText(buffer: Buffer, mimeType: string): Promise<string | undefined> {
22 const config = getConfig();
23- const apiKey = config.geminiApiKey || 'AIzaSyCByANEpkVGkYG6559CqBRlDVKh24dbxE8'; // Fallback to provided key if not set
2425 if (!apiKey) return undefined;
2627 try {
28 const genAI = new GoogleGenerativeAI(apiKey);
29- 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.
30- // Actually, user explicitly said "models/gemini-2.5-flash". I will try to use exactly what they said,
31- // but if it fails I might need to fallback.
32- // Let's stick to the prompt's request exactly first.
33-34- // NOTE: 'gemini-2.5-flash' is not a standard known model at this time (Jan 2026 context).
35- // It might be a custom fine-tune or a future preview.
36- // I will use it as requested.
37 const modelRequested = genAI.getGenerativeModel({ model: 'models/gemini-2.5-flash' });
38000039 const result = await modelRequested.generateContent([
40- "Describe this image in detail for alt text. Be concise but descriptive.",
41 {
42 inlineData: {
43 data: buffer.toString('base64'),
···873 let altText = media.ext_alt_text;
874 if (!altText) {
875 console.log(`[${twitterUsername}] 🤖 Generating alt text via Gemini...`);
876- altText = await generateAltText(buffer, mimeType);
0877 if (altText) console.log(`[${twitterUsername}] ✅ Alt text generated: ${altText.substring(0, 50)}...`);
878 }
879
···1819// ... existing code ...
2021+async function generateAltText(buffer: Buffer, mimeType: string, contextText: string): Promise<string | undefined> {
22 const config = getConfig();
23+ const apiKey = config.geminiApiKey || 'AIzaSyCByANEpkVGkYG6559CqBRlDVKh24dbxE8';
2425 if (!apiKey) return undefined;
2627 try {
28 const genAI = new GoogleGenerativeAI(apiKey);
0000000029 const modelRequested = genAI.getGenerativeModel({ model: 'models/gemini-2.5-flash' });
3031+ const prompt = `Describe this image for alt text. Be concise but descriptive.
32+ Context from the tweet text: "${contextText}".
33+ Use the context to identify specific people, objects, or context mentioned, but describe what is visually present in the image.`;
34+35 const result = await modelRequested.generateContent([
36+ prompt,
37 {
38 inlineData: {
39 data: buffer.toString('base64'),
···869 let altText = media.ext_alt_text;
870 if (!altText) {
871 console.log(`[${twitterUsername}] 🤖 Generating alt text via Gemini...`);
872+ // Use original tweet text for context, not the modified/cleaned one
873+ altText = await generateAltText(buffer, mimeType, tweetText);
874 if (altText) console.log(`[${twitterUsername}] ✅ Alt text generated: ${altText.substring(0, 50)}...`);
875 }
876