Last active
August 29, 2015 13:56
-
-
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
This file contains hidden or 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
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