MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    1. Home
    2. saibam
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 8
    • Groups 0

    saibam

    @saibam

    1
    Reputation
    449
    Profile views
    8
    Posts
    0
    Followers
    0
    Following
    Joined
    Last Online

    saibam Unfollow Follow

    Best posts made by saibam

    • RE: MMM-Slack stop randomise messages

      @gekberlin Yes. Change maxAllowed to 5. Put it in MMM-Slack.js under the getDom: function() where it creates the html elements. I also noticed that it didnt work as expected where I had (maxCount -1) and (maxAllowed - 1). I removed the -1 and it worked like a charm.

      posted in Troubleshooting
      saibamS
      saibam

    Latest posts made by saibam

    • RE: MMM-Slack stop randomise messages

      @mediathreat I think it is possible, as long as the images have some kind of html address or similar, but I have no idea how to do it. I’ve moved on to other projects now :) almost finished an arcade cabinet :D

      posted in Troubleshooting
      saibamS
      saibam
    • RE: MMM-Slack stop randomise messages

      @mediathreat here is the correct link to create your token: https://api.slack.com/custom-integrations/legacy-tokens

      posted in Troubleshooting
      saibamS
      saibam
    • RE: MMM-Slack stop randomise messages

      @mediathreat we followed the link in the readme https://api.slack.com/tokens and from there we created our own app. I’m sorry I can’t find where I found the token in there, you will have to try and error your way :) I will keep looking some but can’t guarantee I find anything. Slack API pages are a mess imo. And no you don’t need the leading # in the config file.

      posted in Troubleshooting
      saibamS
      saibam
    • RE: MMM-Slack stop randomise messages

      @gekberlin Yes.

      currentMessage = emoji_replace(currentMessage);
      

      will not work as emoji_replace is my own function for replacing :smiley: with an emoji.
      so just get rid of that line and it will work.

      And you will also have to instantiate currentMessageId and currentMessageCount globally. I.e.

      var currentMessageId = 0
      var currentMessageCount = 0
      

      at the top of the js file.

      posted in Troubleshooting
      saibamS
      saibam
    • RE: MMM-Slack stop randomise messages

      @gekberlin Yes. Change maxAllowed to 5. Put it in MMM-Slack.js under the getDom: function() where it creates the html elements. I also noticed that it didnt work as expected where I had (maxCount -1) and (maxAllowed - 1). I removed the -1 and it worked like a charm.

      posted in Troubleshooting
      saibamS
      saibam
    • RE: MMM-Slack stop randomise messages

      @ninjabreadman thanks for the answer but this will only show the latest message. I solved it in a rather long but still nice way. The idea is to show the latest 10 messages and when a new message is sent it will show it instantly.
      currentMessageCount and currentMessgeId are global variables instantiated to 0. emoji_replace is my own function to include emojis in the message.

      if (currentMessageCount < this.slackMessages.length || currentMessageCount == 0){ 
      	currentMessageId = 0;
      	currentMessageCount = this.slackMessages.length;
      }
      var maxAllowed = 10;
      		
      var topMessages = this.slackMessages.slice(0, (maxAllowed - 1));
      		
      var maxCount = Math.min(maxAllowed, topMessages.length);
      		
      if (currentMessageId == maxCount - 1) { currentMessageId = 0; }
      		
      var currentMessage = topMessages[currentMessageId].message;
      currentMessage = emoji_replace(currentMessage);
      messageElement.innerHTML = currentMessage;
      currentMessageId ++;
      
      posted in Troubleshooting
      saibamS
      saibam
    • RE: MMM-Slack stop randomise messages
      if(this.slackMessages.length > 0) {
           var randomMessageId = Math.floor(Math.random() * this.slackMessages.length);
           var randomMessage = this.slackMessages[randomMessageId].message;
      

      I want just ‘x’ instead of the ‘randomMessageId’ on the last line and can’t figure out how to do it.

      posted in Troubleshooting
      saibamS
      saibam
    • MMM-Slack stop randomise messages

      I am trying to get rid of the randomiser in MMM-Slack module. I want the messages to show in order from oldest to newest. I’m sure I’m approaching it the wrong way but I just can’t get it to work without the randomiser. Pls help!

      posted in Troubleshooting
      saibamS
      saibam