Created
December 16, 2011 12:23
-
-
Save sapegin/1485847 to your computer and use it in GitHub Desktop.
My first Hubot script
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
# Croc’s moods | |
# Author: Artem Sapegin (http://sapegin.ru) | |
# | |
# croc me <mood> - Displays a link to <mood> mood of Pearls Before Swine’s croc | |
# http://coffeescriptcookbook.com/chapters/arrays/removing-duplicate-elements-from-arrays | |
Array::unique = -> | |
output = {} | |
output[@[key]] = @[key] for key in [0...@length] | |
value for key, value of output | |
module.exports = (robot) -> | |
robot.respond /crocs?(?: me)? (\w+)$/i, (msg) -> | |
croc = msg.match[1].toLowerCase() | |
msg.send if crocs[croc] then "http://savethehamsters.ru/crocs/##{crocs[croc]}" else help() | |
robot.respond /crocs?(?: me)?$/i, (msg) -> | |
msg.send help() | |
help = -> | |
moods = (v for k, v of crocs) | |
'Available moods:\n\n' + moods.unique().join('\n') | |
crocs = | |
angry: 'angry' | |
apathetic: 'apathetic' | |
confuse: 'confused' | |
confused: 'confused' | |
cry: 'cry' | |
drunk: 'drunk' | |
energy: 'energetic' | |
energetic: 'energetic' | |
happy: 'happy' | |
high: 'high' | |
holy: 'holy' | |
indifferent: 'indifferent' | |
love: 'loved' | |
loved: 'loved' | |
mischievous: 'mischievous' | |
nerd: 'nerdy' | |
nerdy: 'nerdy' | |
ok: 'okay' | |
okay: 'okay' | |
peace: 'peaceful' | |
peaceful: 'peaceful' | |
sad: 'sad' | |
sleepy: 'sleepy' | |
work: 'working' | |
working: 'working' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment