Created
January 3, 2012 17:50
-
-
Save rubyist/1556059 to your computer and use it in GitHub Desktop.
nyan for a nyan
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
// Add this to your ~/Library/Application Support/Propane/unsupported/caveatPatchor.js | |
var nyanForNyan = true; | |
if (nyanForNyan) { | |
Campfire.NyanForNyan = Class.create({ | |
initialize: function(chat) { | |
this.chat = chat; | |
}, | |
replayNYANGOOOOO: function() { | |
(function() { | |
this.chat.soundmanager.play('nyan') | |
}).bind(this).defer(); | |
m = this.chat.transcript.insertPendingMessage('nyan', new Template(this.chat.soundTemplate), {description: ImageAutolink.transform(this.chat.sounds['nyan']) || Autolink.emoji(this.chat.sounds[body])}); | |
new Campfire.OutgoingMessage(this.chat, m, 'nyan', 'sound').send(); | |
this.chat.dispatch('messageSpoken', m); | |
}, | |
onMessagesInserted: function(messages) { | |
for (var i = 0; i < messages.length; i++) { | |
var message = messages[i]; | |
var author = message.authorElement(); | |
var body = message.bodyElement(); | |
if ((message.element.id !== 'message_pending') && (body.textContent.match(/nyan/i) || (message.kind === 'sound' && message.getSound() === 'nyan'))) { | |
setTimeout(this.replayNYANGOOOOO, 5000); | |
} | |
} | |
} | |
}); | |
Campfire.Responders.push("NyanForNyan"); | |
window.chat.installPropaneResponder("NyanForNyan", "nyanfornyan"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment