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.

    MMM-Slack stop randomise messages

    Scheduled Pinned Locked Moved Troubleshooting
    14 Posts 4 Posters 7.8k Views 4 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.
    • G Offline
      gekberlin @saibam
      last edited by

      @saibam Thanks for your fast reply!
      I’ve put in the code but then I didn’t get any message displayed anymore.
      Did I have done something wrong ?

      	getDom: function() {
      		var messageElement = document.createElement('div');
      		if (currentMessageCount < this.slackMessages.length || currentMessageCount == 0){
      	currentMessageId = 0;
      	currentMessageCount = this.slackMessages.length;
      }
      var maxAllowed = 5;
      var topMessages = this.slackMessages.slice(0, (maxAllowed 0));
      var maxCount = Math.min(maxAllowed, topMessages.length);
      if (currentMessageId == maxCount 0) { currentMessageId = 0; }
      var currentMessage = topMessages[currentMessageId].message;
      currentMessage = emoji_replace(currentMessage);
      messageElement.innerHTML = currentMessage;
      currentMessageId ++;
      		}
      		return messageElement;
      	}
      });
      
      
      saibamS 1 Reply Last reply Reply Quote 0
      • saibamS Offline
        saibam @gekberlin
        last edited by saibam

        @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.

        1 Reply Last reply Reply Quote 0
        • mediathreatM Offline
          mediathreat @saibam
          last edited by

          @saibam Which Slack token do you use to connect to slack and do you have to put the leading # hash sign in the config file for the channel where it listens?

          saibamS 2 Replies Last reply Reply Quote 0
          • saibamS Offline
            saibam @mediathreat
            last edited by

            @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.

            1 Reply Last reply Reply Quote 0
            • saibamS Offline
              saibam @mediathreat
              last edited by

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

              mediathreatM 1 Reply Last reply Reply Quote 0
              • mediathreatM Offline
                mediathreat
                last edited by

                Thanks! This nailed it perfectly! Hopefully the MMM-SLACK package maintainer might add this info to be clearer. Now that I have it working, I wonder if I can go in and see if I can add showing photos from a slack channel to the code base

                1 Reply Last reply Reply Quote 0
                • mediathreatM Offline
                  mediathreat @saibam
                  last edited by

                  @saibam do you think its possible to modify the code to get images or links that are posted into the slack channel and display them on the magic mirror?

                  saibamS 1 Reply Last reply Reply Quote 0
                  • saibamS Offline
                    saibam @mediathreat
                    last edited by

                    @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

                    1 Reply Last reply Reply Quote 0
                    • 1
                    • 2
                    • 2 / 2
                    • First post
                      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