Skip to content

Commit

Permalink
Support for multiple rooms.
Browse files Browse the repository at this point in the history
Conflicts:

	config.yml
  • Loading branch information
copyhacker committed May 31, 2011
1 parent 78d6b57 commit 26cf7f0
Show file tree
Hide file tree
Showing 3 changed files with 841 additions and 26 deletions.
5 changes: 4 additions & 1 deletion config.yml.example
Expand Up @@ -3,4 +3,7 @@
token: 'YOUR_TOKEN_HERE'
account: 'YOUR_CAMPFIRE_SUBDOMAIN'
ssl: true
room_id: YOUR_ROOM_NUMBER
room_ids:
- Room 1
- 123
- Room The Third
55 changes: 30 additions & 25 deletions lib/marshmallow.js
@@ -1,3 +1,4 @@
var _ = require('../vendor/underscore.js');
var Campfire = require('../vendor/campfire/lib/campfire').Campfire;

var marshmallow = function(config, definition) {
Expand All @@ -14,37 +15,41 @@ var marshmallow = function(config, definition) {

var campfireInstance = new Campfire(config);

campfireInstance.room(config.room_id, function(room) {
room.join(function() {
room.listen(function(message) {
if (message.type != "TextMessage"){
return;
}
_.each(config.room_ids, function(room_id) {
console.log('Joining room ' + room_id);
campfireInstance.room(room_id, function(room) {
room.join(function() {

var match;
for (re in messages) {
if (re == 'catchAll') {
continue;
} else if (match = message.body.match(re)) {
room.listen(function(message) {
if (message.type != "TextMessage"){
return;
}

var match;
for (re in messages) {
if (re == 'catchAll') {
continue;
} else if (match = message.body.match(re)) {

match.shift();

campfireInstance.user(message.user_id, function(speaker) {
messages[re].call(room, match, speaker.user);
});

match.shift();

return;
}
}
if (messages['catchAll']) {
campfireInstance.user(message.user_id, function(speaker) {
messages[re].call(room, match, speaker.user);
messages['catchAll'].call(room, message, speaker.user);
});

return;
}
}
if (messages['catchAll']) {
campfireInstance.user(message.user_id, function(speaker) {
messages['catchAll'].call(room, message, speaker.user);
});
}
})
})
});
});
});

})
}

exports.marshmallow = marshmallow;

0 comments on commit 26cf7f0

Please sign in to comment.