Created
October 3, 2014 18:16
-
-
Save silfreed/0a002976791cd9073b40 to your computer and use it in GitHub Desktop.
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
# Description: | |
# svelame will make you feel all warm .. in your head | |
# | |
# Dependencies: | |
# None | |
# | |
# Configuration: | |
# None | |
# | |
# Commands: | |
# hubot svela me - Receive a svela | |
# hubot svela bomb N - get N svela | |
svelas = [ | |
"http://laughingsquid.com/wp-content/uploads/253.jpg", | |
"http://littlemissredhead.files.wordpress.com/2010/12/bearded-knitted-hats2.jpg", | |
"https://img1.etsystatic.com/018/0/8022917/il_570xN.473772019_4zbl.jpg", | |
"http://1.bp.blogspot.com/_wg2mnzIH9mI/TKuttjGxOWI/AAAAAAAAHlo/CiAl4Sp65NA/s1600/Funny_Beard_Head_Knit_Caps__2.jpg", | |
"http://www.geekalerts.com/u/Star-Wars-Ewok-Knit-Hat.jpg", | |
"http://brimages.bikeboardmedia.netdna-cdn.com/wp-content/uploads/2009/10/lucha-libre-balaclava-sarahemcc.jpg", | |
"http://www.design-moderne.com/wp-content/uploads/2012/07/cat-in-the-hat-dog-hat.jpeg", | |
"http://i.dailymail.co.uk/i/pix/2013/01/08/article-2259253-16D099F0000005DC-681_634x744.jpg", | |
"http://thestarryeye.typepad.com/.a/6a00d8341cdd0d53ef0177434acde5970d-500wi", | |
] | |
shuffle = (a) -> | |
for i in [a.length-1..1] | |
# Choose random element `j` to the front of `i` to swap with. | |
j = Math.floor Math.random() * (i + 1) | |
# Swap `j` with `i`, using destructured assignment | |
[a[i], a[j]] = [a[j], a[i]] | |
# Return the shuffled array. | |
a | |
module.exports = (robot) -> | |
robot.respond /svela me/i, (msg) -> | |
msg.send msg.random svelas | |
robot.respond /svela bomb( (\d+))?/i, (msg) -> | |
count = msg.match[2] || 5 | |
msg.send svela for svela in shuffle(svelas)[1..count] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment