Block automated lighting command while not streaming

I have chat controlled lights via IFTTT webhooks, but the problem is that the command can work even when i’m not streaming. the command is this:

!commands add !LightOn $(urlfetch

so i figured out how to check if i am streaming or not and to have it relay a specific message as such:

!commands add !test $(eval a=decodeURIComponent(’$(twitch $(channel) “{{uptimeLength}}”)’);a.toLowerCase()!=‘channel is not live’?’$(urlfetch’:’ ')

the command executes with the light turning on as expected, but i get a returned error in the chat window of ‘Right-hand side of ‘instanceof’ is not an object’ instead of the expected output of ‘Congratulations! You’ve fired the event’. does anyone know what i am doing wrong?

Inner variables evaluate before the outer ones. This means that the command will run the $(urlfetch) before executing the code in the $(eval), therefore activating your lights independently of whether you are streaming or not.

That said, this revised command will stop the command from returning instanceof errors.

$(eval `$(twitch $(channel) "{{uptimeLength}}")`!=`channel is not live`?decodeURIComponent(`$(querystring $(urlfetch`):` `)

first off, thank you so much @RokettoJanpu and it was some of your other posts that got me as far as i got in the first place! anyway, the issue now is very strange. the URLFetch part of the command seems to be executing during the evaluation process because the Eval part of the command returns the expected results for for both streaming and not streaming but the lights turn on in both cases. i am testing by just changing the != to == during the Eval part.

ok, i miss-read the reply and will invert the commands. but yes, no more error, so i am very excited about that part! thanks again and i’ll re-post the final outcome.

after finding the article Nightbot resolves `$(urlfetch)` before $(eval) , i have split this into two different commands in the following way:

!first (alias to !second)
-a=!second $(eval ‘$(twitch $(channel) “{{uptimeLength}}”)’!=‘channel is not live’?'’:’ ')

$(urlfetch $(query))

the first command checks to see if the channel is streaming, if they are, it passes the entire URL to the second command. as this is an eval command, the URL is hidden on the website and it isn’t visible to chat due to the alias part of the command. the second command simply takes the results and fetches the location. the expected message is received when the channel is streaming. when the channel is not streaming ‘Error Connecting To Remote Server’ is received, which i am satisfied with as it shouldn’t execute the URL anyway. if a better second command can be produced so no error is received at all, i wouldn’t turn it down, but this is now working sufficiently.

I rewrote !second so it outputs the $(urlfetch) response only if the input contains your maker key. This ensures that no one can use !second directly. Replace KEY with your key.

$(eval decodeURIComponent(`$(querystring)`).includes(`KEY`)?`$(urlfetch $(query))`:` `)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.