This repository has been archived by the owner on Jun 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Watches for screencast links and posts the images from the main page.
- Loading branch information
1 parent
675f4f2
commit e4a7183
Showing
1 changed file
with
32 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,32 @@ | ||
# Description: | ||
# Post screencast image link | ||
# | ||
# Dependencies: | ||
# None | ||
# | ||
# Configuration: | ||
# None | ||
# | ||
# Commands: | ||
# http://screencast.com/... - Display image from Screencast | ||
# | ||
# Author: | ||
# Chris Larson | ||
|
||
Select = require( "soupselect" ).select | ||
HTMLParser = require "htmlparser" | ||
|
||
module.exports = (robot) -> | ||
robot.hear /(http:\/\/)?screencast.com\/t\/([^\s]*)/i, (msg) -> | ||
SCShortId = escape(msg.match[2]) | ||
try | ||
msg.http("http://screencast.com/t/"+SCShortId).get() (err, resp, body) -> | ||
htmlHandler = new HTMLParser.DefaultHandler( (()->), ignoreWhitespace: true ) | ||
htmlParser = new HTMLParser.Parser htmlHandler | ||
|
||
htmlParser.parseComplete body | ||
try | ||
url = Select( htmlHandler.dom, "img.embeddedObject" )[0].attribs.src | ||
catch error | ||
msg.send url | ||
catch error |