From 091f0604e0b12283bb889dc8b2e0bc3ce024665b Mon Sep 17 00:00:00 2001 From: hoppermeister Date: Mon, 20 Feb 2017 17:07:13 -0500 Subject: [PATCH 1/3] Cute objects in cute bomb no longer repeat --- scripts/cute.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/scripts/cute.js b/scripts/cute.js index 428fbe9..a00b3c4 100644 --- a/scripts/cute.js +++ b/scripts/cute.js @@ -2,7 +2,6 @@ // Cute bomb is the cutest script //Commands: // fred cute me -// fred cute bomb // fred cute bomb N module.exports = function(robot){ @@ -15,7 +14,9 @@ module.exports = function(robot){ return; } - msg.send( (JSON.parse(body).data.children)[Math.floor(Math.random()*(JSON.parse(body).data.children).length)].data.url); + var json = JSON.parse(body).data.children; + + msg.send( json[random].data.url); }); }); @@ -31,8 +32,15 @@ module.exports = function(robot){ return; } + var json = JSON.parse(body).data.children; + + for(var i = 0; i < count; i++){ - msg.send( (JSON.parse(body).data.children)[Math.floor(Math.random()*(JSON.parse(body).data.children).length)].data.url); + var random = Math.floor(Math.random()*json.length); + msg.send( json[random].data.url); + if(json.length > 1){ + json.splice(random, 1); + } } }); }); From 2296bd2d7e5b968e229023991bfb3ee1d1bc689d Mon Sep 17 00:00:00 2001 From: Andrew Hopper Date: Tue, 3 Apr 2018 16:18:47 -0400 Subject: [PATCH 2/3] Garage Pubsub Alert Add a node if pubsubs are on sale that day (but only check once a day) --- scripts/garage.coffee | 40 +++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/scripts/garage.coffee b/scripts/garage.coffee index bcb48bd..04838d8 100644 --- a/scripts/garage.coffee +++ b/scripts/garage.coffee @@ -22,13 +22,21 @@ module.exports = (robot) -> if garage.garage.toLowerCase() is msg.match[2].toLowerCase() msg.send("Garage " + garage.garage + " is " + garage.perc + "% full") - robot.respond /garage/i, (msg)-> - getGarages (garages) -> + robot.respond /garage$/i, (msg)-> + getGarages (garages, pubsub) -> response = "" + smallest = 100 for garage in garages + if garage.perc < smallest and garage.garage != 'Libra' + smallest = garage.perc response += "Garage #{garage.garage} #{garage.perc}%\n" + if smallest > 90 + response += "http://i.imgur.com/OXlUFE1.jpg\n" + if pubsub + response += "" + msg.send(response) - + robot.respond /where should I park?/i, (msg)-> getGarages (garages) -> smallestGarage = {garage: "THEY'RE ALL FULL", perc: 100}; @@ -41,9 +49,10 @@ module.exports = (robot) -> getGarages = (callback) -> r = request 'https://secure.parking.ucf.edu/GarageCount/iframe.aspx/', (error, response, body) -> garages = [] - $ = cheerio.load(body); + pubsub = false; + $ = cheerio.load(body) $('.dxgvDataRow_DevEx').each (i, obj) -> - thisGarage = {}; + thisGarage = {} html = $(obj).html().replace(RegExp(' ', 'g'), '').split '\n' for line in html if line.startsWith("percent:") @@ -51,7 +60,20 @@ module.exports = (robot) -> thisGarage.perc = percent thisGarage.garage = ($(obj).find('.dxgv').html()).replace("Garage ", '') garages[i] = thisGarage - callback garages - return null - - + + if robot.brain.get('pubsubCheckDate') isnt (new Date()).toDateString() + robot.brain.set('pubsubCheckDate', (new Date()).toDateString()) + r2 = request 'http://www.arepublixchickentendersubsonsale.com/', (error2, response2, body2) -> + $ = cheerio.load(body2); + if $.html().includes("onsale:yes") + robot.brain.set('pubsub', 'true') + pubsub = true + else + pubsub = false + callback garages, pubsub + return null + else + if robot.brain.get('pubsub') is 'true' + pubsub = true + callback garages, pubsub + return null \ No newline at end of file From ed48cc4eaa7e33f48e51d9125d18800510b103c0 Mon Sep 17 00:00:00 2001 From: Andrew Hopper Date: Mon, 16 Jul 2018 04:52:35 -0400 Subject: [PATCH 3/3] Text Fix --- scripts/garage.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/garage.coffee b/scripts/garage.coffee index 04838d8..0e99e2f 100644 --- a/scripts/garage.coffee +++ b/scripts/garage.coffee @@ -33,7 +33,7 @@ module.exports = (robot) -> if smallest > 90 response += "http://i.imgur.com/OXlUFE1.jpg\n" if pubsub - response += "" + response += "But hey, Chicken Tender Subs are on sale! | www.arepublixchickentendersubsonsale.com" msg.send(response)