diff --git a/care.js b/care.js index 364d0bf..e991bbc 100755 --- a/care.js +++ b/care.js @@ -15,6 +15,7 @@ var chalk = require('chalk'); var bunnySay = require('sign-bunny'); var yosay = require('yosay'); var weather = require('weather-js'); +var request = require('request'); var inPomodoroMode = false; @@ -102,6 +103,7 @@ function tick() { doTheWeather(); doTheTweets(); doTheCodes(); + doTheJokes(); } function doTheWeather() { @@ -200,6 +202,30 @@ function doTheCodes() { }); } +function doTheJokes() { + + request.get({url: 'http://tambal.azurewebsites.net/joke/random', json: true}, function (err, res, body) { + + if(err) { + + parrotSay('Knock, Knock! Ops ERROR!').then(function(text) { + parrotBox.content = text; + screen.render(); + }); + + } else { + + parrotSay(body.joke).then(function(text) { + parrotBox.content = text; + screen.render(); + }); + + } + + }); + +} + function makeBox(label) { return { label: label, diff --git a/config.js b/config.js index 77f22c8..546c021 100644 --- a/config.js +++ b/config.js @@ -24,6 +24,8 @@ var config = { // Set to false if you're an imperial savage. <3 celsius: (process.env.TTC_CELSIUS || 'true') === 'true', + + joke: (process.env.TTC_JOKE === 'true'), terminal_title: (process.env.TTC_TERMINAL_TITLE === 'false' ? null : '✨💖 tiny care terminal 💖✨'), diff --git a/package.json b/package.json index 3d4139f..16df971 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,8 @@ "blessed": "^0.1.81", "blessed-contrib": "^4.7.5", "chalk": "^2.4.1", + "parrotsay-api": "^0.1.1", + "request": "^2.81.0", "git-user-name": "^2.0.0", "git-utils": "^5.4.0", "gitlog": "^3.1.2",