• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
MagicMirror Forum
  • Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.

Unable to put a compliment weekly.

Scheduled Pinned Locked Moved Troubleshooting
2 Posts 2 Posters 957 Views 2 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    elwonner
    last edited by Dec 7, 2020, 7:12 AM

    I want to put a compliment every friday, but i did not find any information on the documentation neither google.
    It is possible to do this??

    1 Reply Last reply Reply Quote 0
    • A Offline
      ashishtank Module Developer
      last edited by ashishtank Dec 7, 2020, 5:55 PM Dec 7, 2020, 5:53 PM

      Hi @elwonner
      It’s doable with minor code change. Below is the code you need to achieve the same.

      1. Compliments declaration
      		compliments: {
      			anytime: ["Hey there sexy!"],
      			morning: ["Good morning, handsome!", "Enjoy your day!", "How was your sleep?"],
      			afternoon: ["Hello, beauty!", "You look sexy!", "Looking good today!"],
      			evening: ["Wow, you look hot!", "You look nice!", "Hi, sexy!"],
      			"....-01-01": ["Happy new year!"],
      			"Monday": ["Hello Monday !"],
                              "Friday": ["Thank God, It's Friday !"]
      		},
      
      1. ComplimentsArray function
      complimentArray: function () {
      		var hour = moment().hour();
      		var date = this.config.mockDate ? this.config.mockDate : moment().format("YYYY-MM-DD");
                      var day = this.config.mockDay ? this.config.mockDay : moment().format('dddd'); //Add this line
      		var compliments;
      
      ------ removed some code for brevity, do not actually remove it !
      
                      for (var entry in this.config.compliments) {
      			if (new RegExp(entry).test(date) || new RegExp(entry).test(day)) { //Change this line, Note the second check for day
      				compliments.push.apply(compliments, this.config.compliments[entry]);
      			}
      		}
      
      

      Output should be as below

      bdb5ce80-c904-444d-bd35-31723a0e1ed5-image.png
      77500428-e8a5-46ff-8613-1b5e09a601b5-image.png

      –
      Ashish

      1 Reply Last reply Reply Quote 0
      • 1 / 1
      1 / 1
      • First post
        2/2
        Last post
      Enjoying MagicMirror? Please consider a donation!
      MagicMirror created by Michael Teeuw.
      Forum managed by Sam, technical setup by Karsten.
      This forum is using NodeBB as its core | Contributors
      Contact | Privacy Policy