Created
December 14, 2015 21:41
-
-
Save johnywith1n/bb5f2213189367462fa2 to your computer and use it in GitHub Desktop.
check for 6.86 patch
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
'use strict'; | |
var Promise = require('bluebird'); | |
var request = Promise.promisifyAll(require('request')); | |
var open = require('open'); | |
var FOUND = false; | |
function promiseWhile(predicate, action) { | |
function loop() { | |
if (!predicate()) return; | |
return Promise.resolve(action()).then(loop); | |
} | |
return Promise.resolve().then(loop); | |
} | |
var createResponsePromise = function () { | |
return request.getAsync('http://blog.dota2.com/'); | |
} | |
promiseWhile(function () { | |
return !FOUND; | |
}, function () { | |
console.log('checking dota 2 blog at ' + new Date()); | |
return createResponsePromise().then(function (res) { | |
if (res.body.indexOf('6.86') > -1) { | |
FOUND = true; | |
console.log('6.86 IS HERE!!!!'); | |
open('http://blog.dota2.com/') | |
} | |
}).catch(function (e) { | |
console.error(e); | |
}).delay(60*1000); | |
}) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment