Created
April 19, 2017 18:38
-
-
Save sunnygleason/2b2a425e6693f7484c56148dd7e13726 to your computer and use it in GitHub Desktop.
Advanced BLOCKS Techniques - Event Types BLOCK
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
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