Add basic compliment on a specific day of the year

This commit is contained in:
rejas 2020-03-08 23:18:09 +01:00
parent 39cb582e07
commit 82b50d3059

View File

@ -28,7 +28,10 @@ Module.register("compliments", {
"Wow, you look hot!", "Wow, you look hot!",
"You look nice!", "You look nice!",
"Hi, sexy!" "Hi, sexy!"
] ],
date: [
["12-10", "Happy birthday, Ada Lovelace!"]
],
}, },
updateInterval: 30000, updateInterval: 30000,
remoteFile: null, remoteFile: null,
@ -102,6 +105,8 @@ Module.register("compliments", {
*/ */
complimentArray: function() { complimentArray: function() {
var hour = moment().hour(); var hour = moment().hour();
var year = moment().year();
var today = moment(new Date());
var compliments; var compliments;
if (hour >= this.config.morningStartTime && hour < this.config.morningEndTime && this.config.compliments.hasOwnProperty("morning")) { if (hour >= this.config.morningStartTime && hour < this.config.morningEndTime && this.config.compliments.hasOwnProperty("morning")) {
@ -122,6 +127,12 @@ Module.register("compliments", {
compliments.push.apply(compliments, this.config.compliments.anytime); compliments.push.apply(compliments, this.config.compliments.anytime);
this.config.compliments.date.forEach(d => {
if (today.isSame(year + "-" + d[0], "month")) {
compliments.push(d[1]);
}
});
return compliments; return compliments;
}, },