From 3afb1d991dc30fb08b0c9375d70cb7280625ae76 Mon Sep 17 00:00:00 2001 From: rnhmjoj Date: Fri, 28 Apr 2017 19:15:00 +0200 Subject: [PATCH] Revert "Removed stale meme" This reverts commit 076d50baa48381ec0f1aa48fde00b6b1d603b0d5. --- scripts/stallman-bomb.coffee | 23 +++++++++++++++++++++++ 1 file changed, 23 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..ade610c --- /dev/null +++ b/scripts/stallman-bomb.coffee @@ -0,0 +1,23 @@ +# 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' + +url = 'https://stallman.org/photos/rms-working/mid/' + +module.exports = (robot) -> + robot.respond /stallbomb( (\d+))?/i, (res) -> + n = parseInt res.match[2] || 10 + + robot.http(url).get() (err, _, body) -> + if err then return res.send 'error: stallman is not amused' + $ = 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 [1..n] \ No newline at end of file