Created
January 22, 2014 14:49
-
-
Save rubyist/8559996 to your computer and use it in GitHub Desktop.
Detect new campfire sounds
This file contains hidden or 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
function upInThis(array, value) { | |
for (var i = 0; i < array.length; i++) { | |
if (array[i] == value) return true; | |
} | |
return false; | |
} | |
function sayItProud(msg) { | |
message = this.chat.transcript.insertPendingMessage(msg); | |
new Campfire.OutgoingMessage(this.chat, message, msg, '').send(); | |
this.chat.dispatch('messageSpoken', message); | |
} | |
Campfire.Speaker.Filters.push( | |
function(message) { | |
if(message.match(/^\/soundlist\s*$/)) { | |
var knownSounds = [ | |
'56k', | |
'bell', | |
'bezos', | |
'bueller', | |
'clowntown', | |
'cottoneyejoe', | |
'crickets', | |
'dadgummit', | |
'dangerzone', | |
'danielsan', | |
'deeper', | |
'drama', | |
'greatjob', | |
'greyjoy', | |
'guarantee', | |
'heygirl', | |
'horn', | |
'horror', | |
'inconceivable', | |
'live', | |
'loggins', | |
'makeitso', | |
'noooo', | |
'nyan', | |
'ohmy', | |
'ohyeah', | |
'pushit', | |
'rimshot', | |
'rollout', | |
'sax', | |
'secret', | |
'sexyback', | |
'story', | |
'tada', | |
'tmyk', | |
'trololo', | |
'trombone', | |
'vuvuzela', | |
'what', | |
'whoomp', | |
'yeah', | |
'yodel' | |
]; | |
var soundList = []; | |
for (s in this.chat.sounds) { | |
if (!upInThis(knownSounds, s)) { | |
soundList.push(String(s)); | |
} | |
} | |
if (soundList.length == 0) { | |
sayItProud('No new sounds :('); | |
} else { | |
sayItProud('AWWW YISSSS! MUTHA. FUCKIN. NEW SOUNDS!: ' + soundList.sort().join(', ')); | |
} | |
} else { | |
return message; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment