[CustomAPI] Quote system

Yeah no spaces. Exact string that we had before entered into the timer.

1 Like

What did the query look like?

1 Like

$(urlfetch http://twitch.center/customapi/quote?token=8df3f178&data=$(querystring)&no_id=1)

1 Like

Yeah, you canā€™t use variables in timers. Here, $(querystring) getā€™s replaced what what the person puts after the command in chat. But in timers thereā€™s nothing. So basically just remove that.

$(urlfetch http://twitch.center/customapi/quote?token=8df3f178&data=&no_id=1)

2 Likes

Interesting. I removed that before and still got the same thing. :frowning: But Iā€™m trying it again

1 Like

Yeah it worked. Damn. I totally tried taking that out and it didnā€™t seem to work. Thanks again Ehsankia!

1 Like

Itā€™s working great for me, Iā€™ve added it to 2 of the Channels Iā€™m a Nightbot Editor for, Iā€™m Just wondering if thereā€™s a way to just have month/year without a Day for the time stamps? I donā€™t see it in the list of common variables

Edit: I Just realised itā€™s a normal Nightbot $(time) command, DOY. I found itā€¦ Still This is a great API, Keep Up the good work :smiley:

1 Like

Hereā€™s Yep you can put any valid time format string. More examples here:
http://momentjs.com/docs/#/displaying/

Getting ā€œno matching quote foundā€ again. :frowning:

This time it is on my other list: http://twitch.center/customapi/quote/list?token=d49fff23

Timer Query: $(urlfetch http://twitch.center/customapi/quote?token=d49fff23&data=&no_id=1)

1 Like

This seems to be working fine with the Timer Query you posted.

Figured this out. I had an alias defined in the configuration of the timer. Case solved.

When adding a quote to the bot today, Iā€™m getting ā€œRemote Server Returned Code 500ā€. But I can retrieve and delete quotes, just not add this one for some reason. !addquote Either that, or Duncy hasnā€™t had a chance to harden for a very very long time.

Any idea what might be causing this? Otherwise Iā€™m really happy with this API! Thank you for developing it :smiley:

Interesting, it has to do with the game youā€™re playing (Pokemon) and the fact that your quote automatically includes the game name. More specific, itā€™s the ā€œĆ©ā€ in the name. But the bug isnā€™t with you, it seems like nightbot $(game) is sending the game name with the wrong encoding. It seems to be latin-1 instead of utf-8?

@night can you look into that?

Aha! That makes sense for sure. Thanks for looking into it :slight_smile: Is there a way I can add it manually? I like having the game and time added to the quotes so that we have a referencepoint.

@ehsankia do you have a quick repro for the issue? encoding is already utf8

The way I have it is:

$(urlfetch http://example.com/?data=$(twitch $(channel) "{{game}}"))

And my channel game is set to any Pokemon game with Ć© in it.

And my server is receiving data=Pok%E9mon

\xe9 is a valid latin-1 character, not utf-8

Should I be wrapping the $(twitch) variable in some query variable?

Yes, you should be wrapping it in $(querystring)ā€¦ so $(urlfetch http://example.com/?data=$(querystring $(twitch $(channel) "{{game}}"))) should work I think

Works, though using $(channel) was giving me ā€œunknown twitch channelā€. Is there a nest limit for variable? Because this is 3 layers deep (twitch inside querystring inside fetchurl).

I hardcoded my channel name though and can confirm the unicode bug goes away.

so try that @hopsqueak, surround the $(twitch) variable with $(querystring) and you may need to replace $(channel) with your real channel name.

Iā€™m somewhat lost at this whole thing, so could you help me modify the command Iā€™ve got so that I can adjust it to the two version of nightbot I maintain?

This is my !addquote command:
$(urlfetch http://twitch.center/customapi/addquote?token=redacted&data=$(querystring) [$(time Australia/Lindeman ā€œLā€)] [$(twitch $(channel) ā€œ{{game}}ā€)])

$(urlfetch http://twitch.center/customapi/addquote?token=redacted&data=$(querystring) [$(time Australia/Lindeman "L")] [$(querystring $(twitch $(channel) "{{game}}"))])

if that fails replace $(channel) with your actual username.

1 Like