forked from NARKOZ/hacker-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfucking_coffee.js
More file actions
41 lines (30 loc) · 986 Bytes
/
fucking_coffee.js
File metadata and controls
41 lines (30 loc) · 986 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env node
/* Before running:
npm install telnet-client
*/
var exec = require('child_process').exec;
var telnet = require('telnet-client');
var me = 'my_username';
exec("who", function(error, stdout, stderr) {
// Exit if no sessions with my username are found
if(stdout.indexOf(me) == -1)
process.exit(/*1*/);
var coffee_machine_ip = 'xxx.xxx.xxx.xxx';
var password = 'xxxx';
var con = new telnet();
con.on('ready', function(prompt) {
con.exec('Password: ' + password, function(error, res) {
// Brew Coffee!
con.exec('sys brew', function(error, res) {
// Wait for 24s
setTimeout(function() {
// Pour Coffee!
con.exec('sys pour', function(error, res) {
con.end();
});
}, 24000);
});
});
});
con.connect({host: coffee_machine_ip});
});