Running URL triggers Nightbot with no text reply

Asked Dec 27, 2022·2 replies·Last activity 3 years ago·Open in Discord ↗
Archived from the original community forum
Things may have changed since it was written. Still stuck? Ask the community on Discord.

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

2 replies

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

text
$(eval "$(querystring $(urlfetch json https://mywebsite.com/abc/def))";'STROBE PARTY')

Improved version that checks for urlfetch errors:

text
$(eval r=decodeURIComponent("$(querystring $(urlfetch json https://mywebsite.com/abc/def))");/^(?:\[?Error|Remote Server Returned Code) /.test(r)?r:'STROBE PARTY')
Bronze Cricket said:
$(eval r=decodeURIComponent("$(querystring $(urlfetch json https://mywebsite.com/abc/def))");/^(?:\[?Error|Remote Server Returned Code) /.test(r)?r:'STROBE PARTY')

cool that works perfectly!