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!")