Running URL triggers Nightbot with no text reply

I’m trying to run URL triggers with nightbot using urlfetch. Yet instead of it returning a message in Chat, which is a list it fetches form the URL, I want it to just return a message (like ‘STROBE PARTY’), while running the code at the same time.

Context: Using Voice Monkey to link my chat to my Alexa and smart home

Code: STROBE PARTY! $(eval a=’ $(urlfetch urllink))

Output: STROBE PARTY! Unexpected identifier

I want to get rid of the ‘Unexpected identifier’.

You could use the eval Nightbot variable to ignore the output of the urlfetch and instead return your custom message.

$(eval "$(querystring $(urlfetch json";'STROBE PARTY')

Improved version that checks for urlfetch errors:

$(eval r=decodeURIComponent("$(querystring $(urlfetch json");/^(?:\[?Error|Remote Server Returned Code) /.test(r)?r:'STROBE PARTY')

cool that works perfectly!

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