A bot that generates and posts random domains to Twitter
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. const dotenv = require("dotenv");
  2. const fs = require("fs");
  3. const minimist = require("minimist");
  4. const path = require("path");
  5. const Twitter = require("twit");
  6. const args = minimist(process.argv.slice(2));
  7. const helpText = `USAGE: node index.js [options]
  8. Options:
  9. --env-path, -e path to environment file (default: ./.env)
  10. --help, -h show this help message and exit`;
  11. if (args["help"] || args["h"]) {
  12. console.log(helpText);
  13. process.exit();
  14. }
  15. const envPath = args["env-path"] ? args["env-path"] : "./.env";
  16. dotenv.config({ path: envPath });
  17. const keys = {
  18. consumer_key: process.env.TWITTER_CONSUMER_KEY,
  19. consumer_secret: process.env.TWITTER_CONSUMER_SECRET,
  20. access_token: process.env.TWITTER_ACCESS_TOKEN_KEY,
  21. access_token_secret: process.env.TWITTER_ACCESS_TOKEN_SECRET,
  22. };
  23. const tlds = require("./tlds");
  24. const words = fs
  25. .readFileSync(process.env.DICTFILE, "utf-8")
  26. .split("\n")
  27. .filter((word) => /^[a-zA-Z]+$/.test(word))
  28. .map((word) => word.toLowerCase());
  29. const randomItem = (list) => {
  30. return list[Math.floor(Math.random() * list.length)];
  31. };
  32. const tld = randomItem(tlds);
  33. const word = randomItem(words);
  34. const twitter = new Twitter(keys);
  35. twitter.post("statuses/update", { status: `${word}${tld}` }, function(
  36. err,
  37. data,
  38. response,
  39. ) {});