Skip to content

Instantly share code, notes, and snippets.

@iannsp
Last active August 29, 2015 13:56
Show Gist options
  • Save iannsp/9258106 to your computer and use it in GitHub Desktop.
Save iannsp/9258106 to your computer and use it in GitHub Desktop.
A Simple RuleSte to Say Hello based on time of the day. Use RulezB to process this ruleset: // https://www.npmjs.org/package/rulezb
exports.greetings = {
returnType:'text',
rules:[
function(data){
d = new Date();
hour = d.getHours();
if(hour >=0 && hour <= 11){
return "Good Morning "+ data.name;
}else if(hour > 11 && hour <= 17){
return "Good Afternoon "+ data.name;
}else if(hour > 17 && hour <=22){
return "Good Evening "+ data.name;
}else if(hour > 22 && hour < 24){
return "Good Night "+ data.name;
}
}
]
};
// how to use
// > node rulezb.js -r greetings -f '{"name":"Ivo Nascimento"}'
// Good Evening Ivo Nascimento
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment