From 07c75c0cf8c2d27aa866c0529ac688204a63b30e Mon Sep 17 00:00:00 2001 From: rnhmjoj Date: Mon, 3 Aug 2015 03:53:16 +0200 Subject: [PATCH] Add stallbomb --- scripts/stallman-bomb.coffee | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 scripts/stallman-bomb.coffee diff --git a/scripts/stallman-bomb.coffee b/scripts/stallman-bomb.coffee new file mode 100644 index 0000000..51b1096 --- /dev/null +++ b/scripts/stallman-bomb.coffee @@ -0,0 +1,22 @@ +# Description: +# send pictures of Richard Stallman computing across the world +# +# Commands +# hubot stallbomb ... - spam the chat with Richard Stallman +# +# Author: +# Michele Guerini Rocco (rnhmjoj) +# + +cheerio = require 'cheerio' + +module.exports = (robot) -> + robot.respond /stallbomb( (\d+))?/i, (res) -> + n = parseInt res.match[2] || 10 + url = 'https://stallman.org/photos/rms-working/mid/' + robot.http(url).get() (err, _, body) -> + if err then return callback err, {} + + $ = cheerio.load body + links = (url+$(i).attr 'href' for i in $('a') when $(i).attr('href')[0..2] is 'mid') + res.send (res.random links for _ in [0..n]).join '\n' \ No newline at end of file