Created
May 17, 2017 00:28
-
-
Save Pompeu/5f0c93c8c75284deb4dd63521c1d44b8 to your computer and use it in GitHub Desktop.
ap.js
This file contains hidden or 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
| const five = require("johnny-five"); | |
| const rp = require('request-promise'); | |
| const board = new five.Board({ | |
| repl:false | |
| }); | |
| const key = '?api_key=427d10b3-5493-4cc4-b6ed-d121edea162b'; | |
| const player = 'https://br1.api.riotgames.com/lol/summoner/v3/summoners/by-name/Soldierkill'; | |
| const currentGame = 'https://br1.api.riotgames.com/observer-mode/rest/consumer/getSpectatorGameInfo/BR1/'; | |
| board.on("ready", function(){ | |
| var instance = this; | |
| var led = new five.Led({ | |
| pin: 13, | |
| board: this[0] | |
| }); | |
| rp(player + key) | |
| .then(function(dataPlay){ | |
| return JSON.parse(dataPlay).id; | |
| }) | |
| .then(function (playerId) { | |
| instance.loop(10000, function() { | |
| return rp(currentGame + playerId + key) | |
| .then(function(dataCurrent){ | |
| console.log(dataCurrent); | |
| dataCurrent = JSON.parse(dataCurrent); | |
| if(dataCurrent){ | |
| led.on(); | |
| }else{ | |
| led.off(); | |
| } | |
| }); | |
| }); | |
| }) | |
| .catch(console.log); | |
| }); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment