NightDev Community Forums

[CustomAPI] Quote system


#332

double checked, yes, it may however be a different token on addquote and delquote/purge, could that be an issue?


#333

You can use this tool developed by ehsankia to check what public token is paired with your private token:

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

Replace PRIVATE_TOKEN with your private token (16 characters long).


#334

Thanks for the check tool, I was indeed adding with a different token than trying to delete, remade all 3 commands and it all works good now :slight_smile:


#336

what i need to do for personal quotes for each user in my channel? (generate a personal token when its used for first time), its possible?, and how?


#337

@lopolo2

No need to generate new tokens. If you want to add someone’s name to a quote, just do something like this:

!addquote [some quote] - [name of whoever said the quote]

#338

Hi, I’ve been asked to create a command in a channel which uses this quote API.

The command in question inserts a random quote from that channel’s quote list in the middle of a name provided, as though it were using the quote as a nickname. For example, if a user types:
!aka John Smith
Nightbot would return:
John “[quote]” Smith

I’ve tried to test a version of this in my own channel, but did so using the token of the channel I’m creating it for, which I assume is the reason it has not worked; on first use, it returned, “[other channel] is not defined” and on every subsequent use it returned, “Right-hand side of ‘instanceof’ is not an object”.

The command is as follows, split for greater legibility:

$(eval
a=decodeURIComponent($(querystring)).split();
b=a[0]?a.length:0;
c=$(urlfetch https://twitch.center/customapi/quote?token=********&no_id=1 );
d=(a[0] + ’ “’ + c+ '” ');
while(i=1;i<=(b-1);i++;){
d+=a[i];
}
${d};
)

Is this a valid command, or is there a way I could implement this in this streamer’s channel?


#339

@tulsaeh

!addcom -cd=5 !aka $(eval a=decodeURIComponent(`$(querystring)`).split(` `);if(a.length>1){a.splice(1,0,`$(urlfetch https://twitch.center/customapi/quote?token=********&no_id=1)`);a.join(` `);}else{`Enter at least a first and last name!`;})

#340

That’s wonderful, thank you!
Is there a way to also add in “quotation marks” to the quote being added (without adding space between them and the quote message)? I tried a couple methods that I thought would work, but they all give me an error.


#341

Just put in quotation marks inside the string:

!addcom -cd=5 !aka $(eval a=decodeURIComponent(`$(querystring)`).split(` `);if(a.length>1){a.splice(1,0,`"$(urlfetch https://twitch.center/customapi/quote?token=********&no_id=1)"`);a.join(` `);}else{`Enter at least a first and last name!`;})

#342

That makes sense, I didn’t understand what the ` symbol really meant in JS but I’ve read up and now that makes sense. Thank you again.


#343

I hate to be a bother and I do apologise, but I’ve added more functionality and have not been able to figure out why this isn’t working.

A lot of the quotes in question are added with pretty inconsistent formatting, some have attributions, some have gratuitous quotation marks and some have none. I want to do two things: (1) remove final instances of ’ -’ and chop off the rest of the quote from that point, and (2) remove all instances of the " character in the quote. Here’s what I have:

!addcom !aka $(eval a=decodeURIComponent($(querystring)).split();b=`$(urlfetch https://twitch.center/customapi/quote?token=********&no_id=1 )`;c=b.lastIndexOf(’ -’);d=’’;if(c>0){d=b.substr(0,c);}else{d=b;}d.replace(/"/g, ‘’);if(a.length>1){a.splice(1,0,`"${d}"`);a.join(` `);}else{`${a}, a.k.a. “${d}”`;})

Anyone’s help would be greatly appreciated.


#344
$(eval a=decodeURIComponent(`$(querystring)`).split(` `);b=`$(urlfetch https://twitch.center/customapi/quote?token=********&no_id=1)`.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[0]!=``?`${a}, a.k.a. "${b}"`:`Missing input!`;})

#345

Thanks so much! I put this in (with the appropriate token) and I still got “Right-hand side of ‘instanceof’ is not an object” however.


#346

The command, for reasons I am not sure of yet, must be edited through the dashboard instead of chat.


#347

Out of curiosity, would there be a way to edit the url nested in the b variable based on arguments passed to the command? I am thinking of how to add &data=(final argument) if that final argument is a number. I thought of how I would do this, but could not fit it into the message field as it’s too long.


#348

@tulsaeh

The following setup uses two commands, !aka and _aka, with !aka aliased to _aka:

!addcom -cd=5 !aka -a=_aka $(eval a=decodeURIComponent(`$(querystring)`).split(` `);b=parseInt(a[a.length-1]).toString();if(b==a[a.length-1]){a.unshift(b);a.pop();}else{a.unshift(`#`);}a.join(` `))

!addcom -cd=5 _aka $(eval try{a=decodeURIComponent(`$(querystring)`).split(`$(1) `)[1].split(` `);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}"`;}}catch(e){`Missing input!`;})

Usage:
!aka [name] [optional quote list index number]

If the input index number is larger than the quote list size, a nickname will be chosen at random.


#349

Thank you! I tried to test this in my channel and I’m getting the following error report:


The reason for the !editcom was to add a space in between -a=_aka and $(eval in the first command.


#350

I tried adding the commands both through chat and through the dashboard. !aka can be added through chat, but _aka must be added through the dashboard.


#351

You are incredible. Thank you. Mind if I ask what arguments exactly !aka is passing to _aka here? I may want to create a couple of other aliases for more specific names.


#352

Oh also! I was running a few more test cases and is it possible to get Nightbot to give the error message when !aka is called by itself with no arguments?


I couldn’t tell what would need to be changed, sadly.

This is not that big a deal of course, just asking if there’s a quick fix!