asjon/scripts/stallman-bomb.coffee

23 lines
682 B
CoffeeScript
Raw Normal View History

2015-08-03 03:53:16 +02:00
# 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'
2015-08-03 06:20:52 +02:00
url = 'https://stallman.org/photos/rms-working/mid/'
2015-08-03 03:53:16 +02:00
module.exports = (robot) ->
robot.respond /stallbomb( (\d+))?/i, (res) ->
n = parseInt res.match[2] || 10
2015-08-03 06:20:52 +02:00
2015-08-03 03:53:16 +02:00
robot.http(url).get() (err, _, body) ->
2015-08-03 06:20:52 +02:00
if err then return res.send 'error: stallman is not amused'
2015-08-03 03:53:16 +02:00
$ = cheerio.load body
links = (url+$(i).attr 'href' for i in $('a') when $(i).attr('href')[0..2] is 'mid')
2015-08-03 06:20:52 +02:00
res.send res.random links for _ in [1..n]