Skip to content

Instantly share code, notes, and snippets.

@Nexuist
Last active August 20, 2017 23:31
Show Gist options
  • Save Nexuist/9923ceff5892f129db920a44919fbddd to your computer and use it in GitHub Desktop.
Save Nexuist/9923ceff5892f129db920a44919fbddd to your computer and use it in GitHub Desktop.
const text = "Congratulations! You won the Unreplied giveaway! Here's your promo code: PROMO. Thanks for participating! Make sure you tell all of your Mac friends about it too, they might like it as well!"
const codes = fs.readFileSync("promo_codes.txt", "utf8").split("\n"); // A text file with a promo code on each line
function generateLine(user) {
let encodedText = encodeURIComponent(text).replace(/'/g, "%27").replace("PROMO", codes.pop());
let link = `https://twitter.com/messages/compose?recipient_id=${user.id}&text=${encodedText}`;
return `${user.name} (@${user.screen_name}) - ${link}`;
}
var lines = luckyUsers.map(generateLine);
fs.writeFileSync("list.json", lines.join("\n"), "utf8");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment