twitter_test.js 1.0 KB

12345678910111213141516171819202122232425262728293031
  1. import * as path from 'path';
  2. import Worker from './twitter'
  3. import Webshot from './webshot';
  4. const configPath = './config.json';
  5. let worker;
  6. try {
  7. const config = require(path.resolve(configPath));
  8. worker = new Worker(
  9. Object.fromEntries(Object.entries(config).map(([k, v]) => [k.replace('twitter_', ''), v]))
  10. );
  11. } catch (e) {
  12. console.log('Failed to parse config file: ', configPath);
  13. process.exit(1);
  14. }
  15. const webshot = new Webshot(worker.mode, () => {
  16. worker.webshot = webshot;
  17. worker.getTweet('1296935552848035840', (msg, text, author) => {
  18. console.log(author + text);
  19. console.log(JSON.stringify(msg));
  20. }).catch(console.log);
  21. worker.getTweet('1296935552848035841', (msg, text, author) => {
  22. console.log(author + text);
  23. console.log(JSON.stringify(msg));
  24. }).catch(console.log);
  25. });
  26. worker.queryUser('tomoyokurosawa').then(console.log).catch(console.log);
  27. worker.queryUser('tomoyourosawa').then(console.log).catch(console.log);
  28. worker.queryUser('@tomoyokurosawa').then(console.log).catch(console.log);