forked from tristandunn/node-campfire
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote branch 'upstream/master'
- Loading branch information
Showing
4 changed files
with
222 additions
and
179 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,38 @@ | ||
var system = require('sys'); | ||
var Campfire = require('../lib/campfire').Campfire; | ||
|
||
Campfire.initialize({ | ||
var instance = new Campfire({ | ||
token : 'YOUR_TOKEN', | ||
account : 'YOUR_ACCOUNT' | ||
}); | ||
|
||
var | ||
room = Campfire.Room(ROOM_ID); | ||
room.join(function() { | ||
room.listen(function(message) { | ||
// Ignore emotes, sounds, timestamps, etc. | ||
if (message.type != 'TextMessage') { | ||
return; | ||
} | ||
instance.room(ROOM_ID_OR_NAME, function(room) { | ||
room.join(function() { | ||
room.listen(function(message) { | ||
// Ignore emotes, sounds, timestamps, etc. | ||
if (message.type != 'TextMessage') { | ||
return; | ||
} | ||
|
||
// Ignore your own messages. | ||
// if (message.user.name == 'YOUR_NAME') { | ||
// return; | ||
// } | ||
// Ignore your own messages. | ||
// if (message.user.name == 'YOUR_NAME') { | ||
// return; | ||
// } | ||
|
||
// Only notify on keywords. | ||
// var keywords = ['YOUR_NAME', 'URGENT', 'Whatever']; | ||
// | ||
// if (!message.body.match(new RegExp(keywords.join('|')))) { | ||
// return; | ||
// } | ||
// Only notify on keywords. | ||
// var keywords = ['YOUR_NAME', 'URGENT', 'Whatever']; | ||
// | ||
// if (!message.body.match(new RegExp(keywords.join('|')))) { | ||
// return; | ||
// } | ||
|
||
var | ||
command = '/usr/local/bin/growlnotify'; | ||
command += ' -t "' + message.user.name + '"'; | ||
command += ' -m "' + message.body.replace('"', "'") + '"'; | ||
command += ' --image "examples/images/icon.png"'; | ||
var | ||
command = '/usr/local/bin/growlnotify'; | ||
command += ' -t "' + message.user.name + '"'; | ||
command += ' -m "' + message.body.replace('"', "'") + '"'; | ||
command += ' --image "examples/images/icon.png"'; | ||
|
||
system.exec(command); | ||
system.exec(command); | ||
}); | ||
}); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,24 @@ | ||
var system = require('sys'); | ||
var Campfire = require('../lib/campfire').Campfire; | ||
|
||
Campfire.initialize({ | ||
var instance = new Campfire({ | ||
token : 'YOUR_TOKEN', | ||
account : 'YOUR_ACCOUNT' | ||
}); | ||
|
||
var | ||
room = Campfire.Room(ROOM_ID); | ||
room.join(function() { | ||
room.listen(function(message) { | ||
if (message.body == 'PING') { | ||
system.puts('PING received.'); | ||
instance.room(ROOM_ID_OR_NAME, function(room) { | ||
room.join(function() { | ||
room.listen(function(message) { | ||
if (message.body == 'PING') { | ||
system.puts('PING received.'); | ||
|
||
room.speak('PONG', function(data) { | ||
system.puts('PONG sent at ' + data.message.created_at + '.'); | ||
}); | ||
} else { | ||
system.puts('Received unknown message:'); | ||
system.puts(system.inspect(message)); | ||
} | ||
room.speak('PONG', function(data) { | ||
system.puts('PONG sent at ' + data.message.created_at + '.'); | ||
}); | ||
} else { | ||
system.puts('Received unknown message:'); | ||
system.puts(system.inspect(message)); | ||
} | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.