Setting up a list


#1

I am completely new to Nightbot and have little to no idea about how to set up custom commands. What I specifically want to know how to do it how when someone comes in and wants to submit a course (I stream mostly Mario Maker btw) that nightbot can pick that up and put them in a line and when I need to see that line, or if others want to see it, I can type something else in and see the line or others can do so as well.


#2

Because these commands contain private tokens, you should add them through the Nightbot web interface: https://beta.nightbot.tv/commands/custom.

Go to https://twitch.center/customapi/quote/generate. You will see three lines. Your first token is after token= and before &data= on the first line. Your second token is after token= and before &data= on the second and third lines. Replace FIRSTTOKEN and SECONDTOKEN with these before you add the following commands.

!submitcourse
$(eval q=`$(urlfetch json http://twitch.center/customapi/quote/list?token=FIRSTTOKEN&no_id=1)`;u=`$(user)`.split(" ")[0];c=`$(query)`.split(" ")[0];e=false;r=/([^ ]*): [^ ]* /g;while((m=r.exec(q))!==null){if(u.toLowerCase()==m[1].toLowerCase()){e=true}}if(e){"$EXISTS$"}else if(!c){"$NOCOURSE$"}else{"addquote?token=SECONDTOKEN&data="+encodeURIComponent(`${u}: ${c} `)})

!submitcourseadder
$(eval if(`$(urlfetch json http://twitch.center/customapi/$(query))`.startsWith("Successfully added entry ")){`@$(user) your course was submitted!`}else if(`$(query)`=="$EXISTS$"){`@$(user) you have already submitted a course!`}else if(`$(query)`=="$NOCOURSE$"){`@$(user) enter the course link after !submitcourse`}else{`@$(user) use !submitcourse`})

!next3
$(eval q=`$(urlfetch json http://twitch.center/customapi/quote/list?token=FIRSTTOKEN&no_id=1)`;n3="";i=0;r=/([^ ]*): ([^ ]*) /g;while((m=r.exec(q))!==null&&i<3){n3+=`${m[1]}: ${m[2]} `;i++}i==0?"There are no courses in the queue":`Next ${i==1?"course":i+" courses"}: ${n3}`)

!fullqueue
Full course queue: http://twitch.center/customapi/quote/list?token=FIRSTTOKEN

!popqueue (userlevel moderator)
$(eval r=`$(urlfetch json http://twitch.center/customapi/delquote?token=SECONDTOKEN&data=1)`;m=r.match(/^Successfully deleted entry #1: (.*)$/);if(m){m[1]}else if(r=="Invalid entry index"){"The course queue is empty"}else{`Unknown error (${r})`})

!clearqueue (userlevel moderator)
$(eval q=`$(urlfetch json http://twitch.center/customapi/quote/list?token=FIRSTTOKEN)`;r=`$(urlfetch json http://twitch.center/customapi/delquote?token=SECONDTOKEN&clear=1)`;if(q=="There are no quotes added"){"The course queue is already empty"}else if(r=="All entries have been deleted"){"The course queue has been cleared"}else{`Unknown error (${r})`})

Command explanations:

!submitcourse:
Only one course may be submitted per user. If there is a space in whatever the user typed, anything after it is ignored. This is because I assume the users are supposed to submit links. Other than that, there is no validation of whether what the user typed is actually a course, since I don’t know what website you’re using. I can add that if you give an example of a course link.

!submitcourseadder:
Utility command for !submitcourse. Don’t use manually.

!next3:
View the next 3 courses in the queue.

!fullqueue:
Link to a website containing the entire course queue.

!popqueue:
Nightbot will print the first course in the queue and remove it from the queue.

!clearqueue:
Remove everything from the course queue.

If the commands don’t work at all, you didn’t properly insert your tokens.


Queueing System
#6

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