Skip to content

Instantly share code, notes, and snippets.

@rubyist
Created January 22, 2014 14:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rubyist/8559996 to your computer and use it in GitHub Desktop.
Save rubyist/8559996 to your computer and use it in GitHub Desktop.
Detect new campfire sounds
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