From 30fde36fa9471a407d0e540e4b477aa4cd3a146a Mon Sep 17 00:00:00 2001 From: notacoder69 Date: Tue, 9 Oct 2018 00:20:38 +0530 Subject: [PATCH] Added the 17 second delay to the nodeJS implementation of fucking-coffee --- nodejs/fucking_coffee.js | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/nodejs/fucking_coffee.js b/nodejs/fucking_coffee.js index b30a6b4..7652568 100644 --- a/nodejs/fucking_coffee.js +++ b/nodejs/fucking_coffee.js @@ -19,22 +19,25 @@ exec("who", function(error, stdout, stderr) { var password = 'xxxx'; var con = new telnet(); + con.on('ready', function(prompt) { - con.exec('Password: ' + password, function(error, res) { + setTimeout(function(){ + con.exec('Password: ' + password, function(error, res) { - // Brew Coffee! - con.exec('sys brew', function(error, res) { + // Brew Coffee! + con.exec('sys brew', function(error, res) { - // Wait for 24s - setTimeout(function() { + // Wait for 24s + setTimeout(function() { - // Pour Coffee! - con.exec('sys pour', function(error, res) { - con.end(); - }); - }, 24000); + // Pour Coffee! + con.exec('sys pour', function(error, res) { + con.end(); + }); + }, 24000); + }); }); - }); + },17000); }); con.connect({host: coffee_machine_ip});