Limit Nightbot Command Usage per Day

Hey @jungwookrlee!

I’m not sure it’ll work and I don’t have time to test it, so please keep me updated if it works.


We’ll use the quote system API. You’ll get your TOKENS by clicking on the second link in the post, in the Manual Installation section, use these in the commands I wrote. To know where to look for your PUBLIC_TOKEN and PRIVATE_TOKEN, look at the field bellow:

$(urlfetch https://twitch.center/customapi/quote?token=PUBLIC_TOKEN&data=$(querystring))
$(urlfetch https://twitch.center/customapi/addquote?token=PRIVATE_TOKEN&data=$(querystring))
$(urlfetch https://twitch.center/customapi/delquote?token=PRIVATE_TOKEN&data=$(querystring))

Keep your PRIVATE_TOKEN secret, don’t share it anywhere. Add the following commands from the dashboard. Don’t use the chat as anyone could monitor it and copy the token, they could then edit your data.


Now for the commands, I’m not sure it’ll work, but it’s worth the try:

!present:

$(eval d=`$(urlfetch json https://twitch.center/customapi/quote/list?token=PUBLIC_TOKEN)`.split(`|`);i=d.indexOf(`$(user)`);t=`$(time Asia/Seoul "YYYYMMDD")`;if(`$(twitch $(channel) "{{status}}")`==`live`){if(i>0){if(t!=d[i-1]){`/editquote?token=PRIVATE_TOKEN&data=${d[i-2].replace(`.`,``)}|${t}|${d[i]}|${d[i+1]+1}|`}else{`r`}}else{`/addquote?token=PRIVATE_TOKEN&data=|${t}|$(user)|1|`}}else{`o`})

_present: alias of !present, type _present in the alias field of !present.

$(eval a=$(urlfetch https://twitch.center/customapi$(query));q=`$(query)`.split(`|`);q.length>1?`$(user) has been present for ${q[q.length-2]}`:q==`o`?`You can't use this command now, $(user).`:q==`r`?`You already used the command today, $(user).`:`ERROR`;)

Possible point of failure: the quote API might not add quotes, which would result in the whole thing not working, I recommend testing the command and having a look and see if it added the quotes at:
https://twitch.center/customapi/quote/list?token=PUBLIC_TOKEN