Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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