Unknown Twitch Channel from $(urlfetch)


I am having difficulty with a command that I wrote returning “Unknown Twitch Channel”. I’m unsure what I’ve done wrong, and I would very much appreciate if anybody can help me out.


$(twitch $(urlfetch https://teamsarge.000webhostapp.com/strip.php?USER=$(touser)) “Make sure to give {{name}} a follow at {{url}} - {{name}} is {{status}} with {{game}}”)


Shoutout Stripper <?php print_r(strtolower(ltrim($_GET['USER'],"@"))); ?>

Your web host is injecting HTML into your response to advertise itself. Check the image below to see what your API is returning:

Nightbot doesn’t parse HTML. Your API should return plain text. However, what your API does is very simple and can be accomplished easily using Nightbot’s eval variable. Here is an example:

$(twitch $(eval decodeURIComponent("$(querystring)").split(" ")[0].replace(/^@+/,"")||`$(user)`) "Make sure to give {{name}} a follow at {{url}} - {{name}} is {{status}} with {{game}}")

That’s impressively aggravating. ~_~ Will that decode perform in a similar manner to ltrim in that it will take no action if the @ is not found?

.replace(/^@+/,"") removes all @ at the beginning of the input.

Also, a followup question. I didn’t know that inline functions would work in any manner. What language or style does the functionality follow?

JavaScript. More info here: https://docs.nightbot.tv/commands/variables/eval

/^@+/ is a regular expression

Perfect. I appreciate your help, mate.

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