forked from github/hubot-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request github#53 from carsonmcdonald/webshot
Capture an image of a given website
- Loading branch information
Showing
1 changed file
with
19 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Capture a webpage as an image using the bluga.net Easythumb API. API user and key needed from http://webthumb.bluga.net/api | ||
# | ||
# webshot me <url> - Captures the given url as an image. | ||
|
||
hashlib=require('hashlib') | ||
|
||
module.exports = (robot) -> | ||
robot.respond /webshot( me)? (.*)/i, (msg) -> | ||
if process.env.HUBOT_WEBTHUMB_USER and process.env.HUBOT_WEBTHUMB_API_KEY | ||
url = msg.match[2] | ||
console.log(url) | ||
msg.send 'http://webthumb.bluga.net/easythumb.php?user=' + process.env.HUBOT_WEBTHUMB_USER + '&url=' + encodeURIComponent(url) + '&size=large&hash=' + webthumbhash(process.env.HUBOT_WEBTHUMB_API_KEY, url) + '&cache=14#.jpeg' | ||
|
||
webthumbhash = (apikey, url) => | ||
now = new Date | ||
now = new Date(now.getTime() - (now.getTimezoneOffset() * 1000)) | ||
month = (now.getUTCMonth() < 9 ? '0' : '') + (now.getUTCMonth()+1) | ||
day = (now.getUTCDate() < 10 ? '0' : '') + now.getUTCDate() | ||
hashlib.md5(now.getUTCFullYear().toString() + month + day + url + apikey) |