Advertisement
Guest User

Untitled

a guest
Apr 17th, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. var Beam = require('beam-client-node');
  2. var Tetris = require('beam-interactive-node');
  3. const readline = require('readline');
  4. var stream = <channelID>;
  5. var auth = {
  6. username: 'username',
  7. password:'passs'
  8. };
  9.  
  10. const rl = readline.createInterface({
  11. input: process.stdin,
  12. output: process.stdout
  13. });
  14.  
  15. rl.question('Please enter 2Fa code(if you dont have one press enter):', (answer) => {
  16. auth.code = answer;
  17. start()
  18. });
  19. function start() {
  20. const beam = new Beam();
  21. beam.use('password', auth)
  22. .attempt()
  23. .then(() => {
  24. return beam.game.join(stream);
  25. }).then(res => {
  26. const details = {
  27. remote: res.body.address,
  28. channel: stream,
  29. key: res.body.key
  30. };
  31. const robot = new Tetris.Robot(details);
  32. robot.handshake(err => {
  33. if (err) {
  34. throw new Error('Error connecting to Tetris', err);
  35. }
  36. });
  37.  
  38. robot.on('report', report => {
  39. console.log(report);
  40. // Try console.log(report.tactile)
  41. // console.log(report.joystick)
  42. });
  43. }).catch(err => {
  44. if (err.message !== undefined && err.message.body !== undefined) {
  45. console.log(err);
  46. } else {
  47. throw err;
  48. }
  49. });
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement