todbot / Blink1Control2

Blink1Control GUI to control blink(1) USB RGB LED devices.
http://blink1.thingm.com/
Apache License 2.0
154 stars 26 forks source link

Add Slack Integration #186

Closed Skarlso closed 11 months ago

Skarlso commented 1 year ago

Hello. I'm back. :D

Skarlso commented 1 year ago

Hey @todbot.

So I think I added this thing to everything. :D However, it's not working. The service doesn't seem to start up.

Is there something I'm missing here? I don't get any logs and events from the service at all. The Slack part of the code IS working; I tested that separately and saw messages arriving in the channel. I'm not sure what else could be missing. :)

todbot commented 1 year ago

Hi! I would check your personal blink1control2-config.json and make sure it has the slackService object and that it has an enabled: true. Other than that, looks good so far!

Skarlso commented 1 year ago

Ah dang!! I added it to the defaults only after I first executed the dev env. :D So it wrote it out without the slack service 🤦.

ALSO! :D

It turns out that events aren't showing up!

This, for example:

        try {
            console.log("WHAT3")
            token = utils.decrypt( self.config.password );
            console.log("WHAT4")
        } catch(err) {
            console.log("ERR: ", err)
            log.msg('SlackService: invalid user token for rule',rule.name);
            return;
        }

Didn't show me anything in the logs. Not until I added a console.log.

ERR:  TypeError: Cannot read properties of undefined (reading 'split')
    at Object.decrypt (utils.js:33:26)
    at Object.start (slackService.js:69:21)
    at eval (maingui.js:95:16)

Events said no logs..

Skarlso commented 1 year ago

Finally, I figured out that password is the wrong value to look for. It's passwordHash. :D

But now I'm getting:

xhr.js:143 Refused to set unsafe header "User-Agent"
Skarlso commented 1 year ago

It's working. :D

Screenshot 2022-12-03 at 19 46 34

Sadly, I'm getting rate limited.

Skarlso commented 1 year ago

It's trying to connect over and over.. is there a way perhaps to reuse existing connections? Maybe through some state or something?

Skarlso commented 1 year ago

also, it looks like I need to use a different node client actually. rtm-api is now web-api.

Skarlso commented 1 year ago

Dang, it. The RTM is horrible. I will have to use the Events API. :( This means people will have to surface the call-back URL. Which is fine, I guess. You can use something like ngrok, which is quite common to open something up temporarily. Then, from there, using this and ngrok and pasting in the URL should be fine. If you have the app running anyways, you might as well start ngrok in the background for it.

What do you think?