Last active
April 17, 2016 02:12
-
-
Save ProbablePrime/10581b75a1b4ebaa742b1b8a160415d2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Beam = require('beam-client-node'); | |
var Tetris = require('beam-interactive-node'); | |
const readline = require('readline'); | |
var stream = <channelID>; | |
var auth = { | |
username: 'username', | |
password:'passs' | |
}; | |
const rl = readline.createInterface({ | |
input: process.stdin, | |
output: process.stdout | |
}); | |
rl.question('Please enter 2Fa code(if you dont have one press enter):', (answer) => { | |
auth.code = answer; | |
start() | |
}); | |
function start() { | |
const beam = new Beam(); | |
beam.use('password', auth) | |
.attempt() | |
.then(() => { | |
return beam.game.join(stream); | |
}).then(res => { | |
const details = { | |
remote: res.body.address, | |
channel: stream, | |
key: res.body.key | |
}; | |
const robot = new Tetris.Robot(details); | |
robot.handshake(err => { | |
if (err) { | |
throw new Error('Error connecting to Tetris', err); | |
} | |
}); | |
robot.on('report', report => { | |
console.log(report); | |
// Try console.log(report.tactile) | |
// console.log(report.joystick) | |
}); | |
}).catch(err => { | |
if (err.message !== undefined && err.message.body !== undefined) { | |
console.log(err); | |
} else { | |
throw err; | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment