[CustomAPI] Quote system

You can see what !aka is passing to _aka by decoupling them (edit !aka on the dashboard and clear the Alias field) and testing various inputs. This is what !aka is passing to _aka:

[1] [2]

If the last argument is an integer, [1] is the last argument, else [1] is the ‘#’ character.

If the last argument is an integer, [2] is the user input excluding the last argument, else [2] is the entire user input.


This response for _aka should have better error handling. Remember to use the dashboard instead of chat:

$(eval d=decodeURIComponent;if(d(`$(2)`)!=`null`){a=d(`$(querystring)`).split(` `);a.shift();b=`$(urlfetch https://twitch.center/customapi/quote?token=********&no_id=1&data=$(1))`;b=b==`No matching entry found`?`$(urlfetch https://twitch.center/customapi/quote?token=********&no_id=1)`:b;b=b.replace(/[“”"]/g,``);c=b.lastIndexOf(` -`);b=c>-1?b.slice(0,c):b;if(a.length>1){a.splice(1,0,`"${b}"`);a.join(` `);}else{`${a}, a.k.a. "${b}"`;}}else{`Missing input!`;})

Oh okay, that actually seems totally obvious to me now, haha.

Thank you so much for all the help!

Hey!

Is there a way to edit the whole quote list more easily? We are at 1000 quotes now and would like to remove some.
The !delquote command gets the quote numbers all changed up (e.g. quote 600 is then quote 599).
The !editquote command is very handy for single quotes, but doing that for all quotes would be tedious.

Is there for example a txt, csv or any file where all the quotes are saved in that you can change from outside, without needing to use the nightbot commands?

Thanks!

Hi!

Having the same problem as @sttarrgazzerr atm - deleted my commands with the private token but still have access to the public one. Is there any type of reverse version of the tool below?

https://twitch.center/customapi/quote/recover?token=PRIVATE_TOKEN

Thanks!

I’m trying to implement the !editquote command for a streamer but I don’t understand what the “private key” is or how you get an !editquote command leading to a website to edit the quote. I’m new to this but have had no roadblocks with adding commands to nightbot until this one. Could anyone specify?

It’s the same as for the addquote/delquote, but instead it’s editquote in the URL/command line:

delquote: $(urlfetch https://twitch.center/customapi/delquote?token=TOKEN;data=$(querystring))
editquote: $(urlfetch https://twitch.center/customapi/editquote?token=TOKEN;data=$(querystring))
(tbh, I don’t know if &amp has to be after the TOKEN)

The token is a unique string of letters and numbers that only the streamer should know. The token is written in the add/delquote command lines when you first generated the command lines like it says in the original post.

I apologize for being dumb, I’ve tried multiple times to get it to work but I’ve had no luck. How exactly should it be typed out? I’ve tried it as what you said but it just said error.

also what do you mean by &amp?

@andywall

This is the command response you need to set up for !editquote:

$(urlfetch https://twitch.center/customapi/editquote?token=PRIVATE_KEY&data=$(querystring))

Replace PRIVATE_KEY with the private key to your quote list. This should be the 16-character long random string of letters and numbers that allows Nightbot to add/edit/delete quotes. You should already have this key handy if you already have a quote list set up. If you did not set up the quote list yourself, ask the streamer who you moderate for to private message it to you.

Just in case, this is the usage for !editquote:

!editquote [list ID number of the quote] [new quote]

Either write this in chat after Nightbot joined:
!commands add !editquote $(urlfetch http://twitch.center/customapi/editquote?token=[TOKEN]&data=$(querystring))

Or on the nightbot page (beta.nightbot tv/commands/custom) -> press “+Add command” button -> fill in Command = !editquote ; Message = $(urlfetch https://twitch.center/customapi/editquote?token=[TOKEN]&data=$(querystring))

replace [TOKEN] by the private key, like RokettoJanpu said.

Ignore what I said about “&amp”. I got that mistakenly by copy+pasting stuff around.

Is there a way to import quotes from another quote system? I currently use Streamlabs Chatbot but would like to move my quotes over to Nightbot.

@banrionjackie

If your Streamlabs Chatbot is reading off lines from a locally stored file, there is no good way to import your quotes to this quote system other than running the !addquote command for each and every line.


You may be better off storing your quotes as a Pastebin file.

Look at this pastebin file I use for a trivia command. Note the following aspects of the file:

  • The file starts and ends with square brackets []
  • Each trivia fact is bounded by backticks ``
  • The facts are separated by commas.

Go to https://pastebin.com and create a file for a new !quote command that follows the same aspects as detailed above. Once you create it, copy and paste the following command setup into your Nightbot dashboard to create the command. Replace RAW_PASTE_LINK with the raw paste link to your pastebin file (the link looks a bit like https://pastebin.com/raw/fooObarR):

$(eval a=$(urlfetch json RAW_PASTE_LINK);a[Math.floor(Math.random()*a.length)])

can you please help me where should i get this token?

@Sultan

Get a public and private token pair at https://twitch.center/customapi/quote/generate

The public token is 8 characters long and the private token is 16 characters long. The public token is located within the first generated link. The private token is located within both the second and third generated links. The tokens are found after token= and before &data=$(querystring) Copy these tokens down and keep them somewhere safe.

is it possible to edit the token site so i dont have to put in each and every quote when im adding a lot

@denniskarbon

If you’re familiar with cURL you could write a php script that loops through a list of quotes and makes a GET request to the quote API for each quote.

Example given below:

<?php

// Set up an array of quotes to be added to the quote list
$quotes = ["Hello world!","Sh-boom sh-boom! Oh life could be a dream!","Who toucha my spaghett?!"];

// Initialize cURL
$ch = curl_init();
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true);

$url = "https://twitch.center/customapi/addquote";

// Loop through the quotes array and add each one to the quote list via cURL
for($i=0; $i<count($quotes); $i++){
    $params = array("token" => "PRIVATE_TOKEN", "data" => $quotes[$i]);
    curl_setopt($ch, CURLOPT_URL, $url . "?" . http_build_query($params));
    curl_exec($ch);
}

// Job's done!
curl_close($ch);
echo "Job's done!";

?>

Can somebody help me please i can not get my win and kill counter to work this is all i need to achieve

Iwins user has 3 amount of wins with 1k 2k 3k

is there a list of the codes you can use on the api site name ? Trying to just pull the quote id without pulling the quote. like noid and clear all***

@The_Cerb

The quote API allows the following additional parameters.

no_id=1 will return a quote without the ID number in front of the quote:

$(urlfetch https://twitch.center/customapi/quote/list?token=PUBLIC_TOKEN&no_id=1)

clear=1 will clear all quotes from the list:

$(urlfetch https://twitch.center/customapi/delquote?token=PRIVATE_TOKEN&clear=1)

PUBLIC_TOKEN and PRIVATE_TOKEN are the public token (8 characters long) and private token (16 characters) of the quote list.

oh ok thanks for the response, thought there would be more.

Hey! I mod a Twitch chat and I think one of the other mods manually deleted the !quote command and now we can add and delete quotes but the !quote commands (i.e. !quote 1, !quote 2 etc) do not work… any ideas on how to fix this?