Skip to content

Instantly share code, notes, and snippets.

@sunnygleason
Created April 19, 2017 18:38
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 sunnygleason/2b2a425e6693f7484c56148dd7e13726 to your computer and use it in GitHub Desktop.
Save sunnygleason/2b2a425e6693f7484c56148dd7e13726 to your computer and use it in GitHub Desktop.
Advanced BLOCKS Techniques - Event Types BLOCK
export default (request) => {
const pubnub = require('pubnub');
var message = "Welcome, ";
var punctuation = "!";
if (request.message.action == 'join') {
message = "Welcome, ";
punctuation = "!";
} else if (request.message.action == 'timeout') {
message = "Still there, ";
punctuation = "?";
} else if (request.message.action == 'leave') {
message = "Goodbye, ";
punctuation = ".";
} else if (request.message.action == 'state') {
message = "New state from ";
punctuation = ".";
}
return pubnub.publish({
channel:'presence-channel',
message:{
text:message + request.message.uuid + punctuation,
from:'PresenceBot'
}
}).then(() => {
return request.ok();
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment