Skip to content

Commit

Permalink
Merge remote branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
erunion committed Apr 25, 2011
2 parents 775c620 + 2295f72 commit 55cc3fb
Show file tree
Hide file tree
Showing 4 changed files with 222 additions and 179 deletions.
8 changes: 2 additions & 6 deletions README.markdown
Expand Up @@ -24,11 +24,7 @@ Use node.js to interact with Campfire chat rooms.
"created_at": "2010-01-13 01:00:00"
}

## Known Issues

* The web interface stops updating for the user once a message is sent.

## To-Do
## To-do

* Better error handling.
* Support more API methods.
Expand All @@ -42,7 +38,7 @@ Use node.js to interact with Campfire chat rooms.

The MIT License

Copyright (c) 2010 Tristan Dunn
Copyright (c) 2011 Tristan Dunn

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
50 changes: 25 additions & 25 deletions examples/growl.js
@@ -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);
});
});
});
28 changes: 14 additions & 14 deletions examples/ping.js
@@ -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));
}
});
});
});

0 comments on commit 55cc3fb

Please sign in to comment.