# Description: # "facebook grabber." # # Dependencies: # None # # Configuration: # None # # Commands: # hubot show [me] mamacake - Display the daily meal of Mamacake # # Notes: # Show Daily Meal of Mamacake (Paris 18e) # # Author: # Adam Tahri (aka gotakk) module.exports = (robot) -> robot.hear /show( me)? mamacake/i, (response) -> robot.http("https://graph.facebook.com/oauth/access_token?client_id=YOUR_CLIENT_ID&client_secret=YOUR_CLIENT_SECRET&grant_type=client_credentials") .get() (err, res, body) -> tab = body.split '=' access_token = tab[1] robot.http("https://graph.facebook.com/v2.4/542218599184696/posts?fields=full_picture,message,created_time&access_token=" + access_token) .get() (err, res, body) -> data = JSON.parse body datetime = new Date(data.data[0]["created_time"]) today = new Date() if datetime.getDay() is today.getDay() response.send data.data[0]["full_picture"] else response.send "No meal was posted yet"