Special characters in $(query) when using urlfetch GET

Asked Mar 12, 2024·2 replies·Last activity 2 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.

With the command below, if $(query) contains special characters, they are dropped or $(query) is truncated. I understand why it would happen. It would mess with the URL but is there any solution. The two characters giving me trouble are & and +. anyway around this. I'd even consider replacing like the + symbol with the word plus as an example. Any suggestions? Here's the command:

$(urlfetch https://www.testdomain.com/nb/atest.php?cid= $(chatid)&user=$(user)&query="$(query)")

I've tried with and without quote and single quotes. Thanks! Cap

2 replies

Hiya, you should have a look at $(querystring), this variable can accepts arguments to convert it into a url-encoded string. $(querystring) without arguments is the url-encoded version of $(query), but you can also use for example $(querystring $(user))

https://docs.nightbot.tv/variables/querystring

Thank you!!!! That worked perfectly!!

Cap