twitter_test.js 1.3 KB

123456789101112131415161718192021222324252627282930
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. const path = require("path");
  4. const twitter_1 = require("./twitter");
  5. const webshot_1 = require("./webshot");
  6. const configPath = './config.json';
  7. let config, worker;
  8. try {
  9. config = require(path.resolve(configPath));
  10. worker = new twitter_1.default(Object.fromEntries(Object.entries(config).map(([k, v]) => [k.replace('twitter_', '').replace(/_(.)/g, (_, $1) => $1.toUpperCase()), v])));
  11. }
  12. catch (e) {
  13. console.log('Failed to parse config file: ', configPath);
  14. process.exit(1);
  15. }
  16. const webshot = new webshot_1.default(config.playwright_ws_spec_endpoint, worker.mode, () => {
  17. worker.webshot = webshot;
  18. worker.getTweet('1296935552848035840', (msg, text, author) => {
  19. console.log(author + text);
  20. console.log(JSON.stringify(msg));
  21. }).catch(console.log);
  22. worker.getTweet('1296935552848035841', (msg, text, author) => {
  23. console.log(author + text);
  24. console.log(JSON.stringify(msg));
  25. }).catch(console.log);
  26. });
  27. worker.queryUser('tomoyokurosawa').then(console.log).catch(console.log);
  28. worker.queryUser('tomoyourosawa').then(console.log).catch(console.log);
  29. worker.queryUser('@tomoyokurosawa').then(console.log).catch(console.log);
  30. //# sourceMappingURL=twitter_test.js.map