Last active
August 29, 2015 13:56
-
-
Save ikr7/8949891 to your computer and use it in GitHub Desktop.
Japan PvP鯖のマップをお知らせするbot
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
{ | |
"name": "pvpbot", | |
"version": "0.0.1", | |
"description": "Uho, good bot...", | |
"main": "app.js", | |
"dependencies": { | |
"ntwitter": "~0.5.0", | |
"request": "~2.33.0" | |
}, | |
"devDependencies": {}, | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "ikr7", | |
"license": "BSD-2-Clause" | |
} |
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 request = require('request'), | |
ntwitter = require('ntwitter'); | |
var twi = new ntwitter({ | |
'consumer_key': '', | |
'consumer_secret': '', | |
'access_token_key': '', | |
'access_token_secret': '' | |
}); | |
var run = function(){ | |
request.get({ | |
'uri': 'https://pvp.minecraft.jp/servers.json', | |
'json': true | |
}, function(error, response, body){ | |
if(!error){ | |
body.servers.forEach(function(ele){ | |
var nextMap = ele.Server.nextMap; | |
if( | |
nextMap == 'Out Post' || | |
nextMap == 'Fluffy Mine' || | |
nextMap == 'The Siege' || | |
nextMap == 'The Two Towers' || | |
nextMap == 'Cold Bridge DTC' | |
){ | |
var text = '@aWtyNw__ '; | |
text += ele.Server.name + ' の 次のマップは ' + nextMap + ' です。 #JPMCPvP'; | |
twi.updateStatus(text, function(err, res){ | |
if(!err){ | |
console.log('Posted:\n\"', text, '\"'); | |
}else{ | |
console.error(err) | |
} | |
setTimeout(run, 20 * 1000); | |
}); | |
} | |
}); | |
} | |
}); | |
}; | |
run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment