const axios = require('axios');
console.log("๐ AI News Tweet Generator Starting...");
console.log(`๐
Date: ${date}`);
console.log(`๐จ Style: ${tweetStyle}`);
console.log(`๐ Emojis: ${includeEmojis ? 'Yes' : 'No'}`);
const searchQueries = [
`AI news ${date}`,
`artificial intelligence ${date} latest`,
`"${date}" AI developments breakthrough`,
`AI companies ${date} funding regulation`
];
const newsCategories = {
regulatory: "๐จ",
funding: "๐ฐ",
products: "๐ฑ",
research: "๐ฌ",
healthcare: "๐ฅ",
enterprise: "๐ข",
security: "๐ก๏ธ",
openai: "๐ค",
google: "๐",
meta: "๐"
};
function generateTweetContent(newsItems, style) {
let tweet = "";
const hashtagsToAdd = hashtags || "#AINews #TechNews";
switch(style) {
case "headlines":
tweet = includeEmojis ? "๐จ Today's AI Headlines:\n\n" : "AI Headlines:\n\n";
newsItems.slice(0, 4).forEach(item => {
const emoji = includeEmojis ? (newsCategories[item.category] || "โข") : "โข";
tweet += `${emoji} ${item.title}\n\n`;
});
break;
case "roundup":
tweet = includeEmojis ? "๐ค AI NEWS ROUNDUP:\n\n" : "AI NEWS ROUNDUP:\n\n";
newsItems.slice(0, 3).forEach(item => {
const emoji = includeEmojis ? (newsCategories[item.category] || "โข") : "โข";
tweet += `${emoji} ${item.title}\n`;
});
tweet += "\n";
break;
case "thread":
tweet = includeEmojis ? "AI Update ๐งต\n\n" : "AI Update Thread\n\n";
newsItems.slice(0, 3).forEach((item, i) => {
tweet += `${i + 1}/ ${item.title}\n\n`;
});
break;
case "breaking":
const topNews = newsItems[0];
const emoji = includeEmojis ? "๐จ BREAKING: " : "BREAKING: ";
tweet = `${emoji}${topNews.title}\n\n`;
break;
}
tweet += hashtagsToAdd;
return tweet;
}
console.log("๐ฐ Gathering latest AI news...");
const mockNewsItems = [
{
category: "regulatory",
title: "Texas AG investigates Meta & Character.AI for misleading kids with AI mental health tools",
source: "Texas Attorney General"
},
{
category: "funding",
title: "AI wealth boom hits $2.7T with 498 unicorns - largest wealth creation in history",
source: "CNBC"
},
{
category: "products",
title: "Meta's Hypernova AR specs positioning to replace smartphones entirely",
source: "XR Today"
},
{
category: "healthcare",
title: "NHS trials AI tool for automatic patient discharge summaries",
source: "Healthcare IT"
},
{
category: "enterprise",
title: "TCS opens $3B AI data center in North Dakota",
source: "Moneycontrol"
},
{
category: "products",
title: "Grammarly launches AI agent suite for plagiarism detection & writing feedback",
source: "NewsBytes"
}
];
console.log("\n=== GENERATING TWEET OPTIONS ===");
const tweetOptions = [];
if (tweetStyle === "all") {
["headlines", "roundup", "thread", "breaking"].forEach(style => {
const content = generateTweetContent(mockNewsItems, style);
tweetOptions.push({
style: style,
content: content,
length: content.length
});
});
} else {
const content = generateTweetContent(mockNewsItems, tweetStyle);
tweetOptions.push({
style: tweetStyle,
content: content,
length: content.length
});
}
console.log(`\n=== AI NEWS TWEETS (${date.toUpperCase()}) ===\n`);
tweetOptions.forEach((tweet, index) => {
console.log(`OPTION ${index + 1} - ${tweet.style.toUpperCase()} STYLE (${tweet.length} chars):`);
console.log(tweet.content);
console.log(`${tweet.length <= maxTweetLength ? 'โ
Fits character limit' : 'โ Exceeds character limit'}`);
console.log("-".repeat(60));
});
const validTweets = tweetOptions.filter(t => t.length <= maxTweetLength);
const recommendedTweet = validTweets.length > 0 ? validTweets[0] : tweetOptions[0];
console.log("\n๐ฏ RECOMMENDED TWEET:");
console.log(recommendedTweet.content);
console.log(`\nCharacter count: ${recommendedTweet.length}/${maxTweetLength}`);
console.log(`Style: ${recommendedTweet.style.toUpperCase()}`);
console.log("\n๐ฐ NEWS SOURCES:");
const uniqueSources = [...new Set(mockNewsItems.map(item => item.source))];
uniqueSources.forEach(source => console.log(`โข ${source}`));
console.log("\n๐ฑ READY TO POST:");
console.log("โ
Copy the recommended tweet above");
console.log("โ
Paste into Twitter/X composer");
console.log("โ
Add media/images if desired");
console.log("โ
Schedule or post immediately");
console.log("\n๐ AI News Tweet Generator completed successfully!");
console.log("๐ก Tip: Run this daily for consistent AI news updates on your social media!")