Skip to content

Instantly share code, notes, and snippets.

@Remiii
Last active August 28, 2015 13:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Remiii/94dc6bb9567a8a63fe24 to your computer and use it in GitHub Desktop.
Save Remiii/94dc6bb9567a8a63fe24 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