Limit Nightbot Command Usage per Day

Hello Communities

I want a make a command that keeps a record of the number of days where the viewer is actually PRESENT in my channel (NOT !followage)

I figure one way to do that is to make a command that user can use only once per day

For example,
if the user types !present for the first time, nightbot will response: “{trouser} is present for 1 day”

if the user types the same command before a 12am, it will either not response or give the same response as above

if the user types the command the next day nightbot will response: “{trouser} is present for 2 days” , etc.

Is there anyway I can do this?

Also, if its possible I also want to:

  1. I want the command to only work while I am streaming
  2. I want the reset time to be 12am KST (Korean Standard Timezone) because I am streaming in a Korean server and most of my viewers are Korean

Hiya, this whole setup is very specific, I dont think there is a build-in way to accomplish this. However with $(urlfetch) or $(eval) you can create externsal scripts that could handle this.

what url should I use for the $(urlfetch) variable?

and unfortunately I don’t know javasciprt enough to use $(eval) but thanks for your response

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

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