Created
October 26, 2011 20:40
hubot script to insert images from bukk.it
This file contains hidden or 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
# <anything> lolz <anything> - BRING THE LOLZ | |
select = require("soupselect").select | |
htmlparser = require "htmlparser" | |
util = require 'util' | |
class LolzFinder | |
constructor: (msg) -> | |
@msg = msg | |
@bukkit = "http://bukk.it" | |
@handler = new htmlparser.DefaultHandler() | |
@parser = new htmlparser.Parser(@handler) | |
allLolz: (cb) -> | |
@msg.http(@bukkit).get() (err,res,body) => | |
@parser.parseComplete(body) | |
cb("#{@bukkit}/#{a.attribs.href}" for a in select(@handler.dom, 'td a')) | |
random: (cb) -> | |
@allLolz (lolz) => | |
cb @msg.random(lolz) | |
module.exports = (robot) -> | |
robot.respond /.*lolz/i, (msg) -> | |
lolz = new LolzFinder msg | |
lolz.random (lol) -> | |
msg.send lol |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment