Skip to content

Instantly share code, notes, and snippets.

@gotakk
Forked from Remiii/README.md
Last active August 28, 2015 13:53
Show Gist options
  • Save gotakk/1905f41d4d38c51dca13 to your computer and use it in GitHub Desktop.
Save gotakk/1905f41d4d38c51dca13 to your computer and use it in GitHub Desktop.
Hubot MamaCake (Paris 18e)
# 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"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment