[CustomAPI] Quote system

Introduction

This custom api adds Quote functionality for your channel through nightbot.
It allows you to add quotes, and have users request random or specific quotes.

Warning: This is meant to be a system for adding quotes in Twitch chat, and not an arbitrary database. There is no guarantees for uptime or data retention. I reserve the right to limit and boot off any abusive use of this API at anytime. If you want a database, please host your own custom API.

Automatic Installation

For this method, you need to be the owner of the channel.
Also, make sure you don’t already have any custom commands named
!quote, !addquote or !delquote, as they will be overwritten.

All you have to do is visit this webpage, and sign in with Nightbot.
It will automatically add those 3 commands to your channel

https://twitch.center/customapi/quote/nightbot

Manual Installation

This method is for those who are very familiar with creating and editing complex commands.
If you’re a mod of another channel, if you want to customize the commands, or use another bot,
you can manually add the 3 commands yourself. Be careful though, if you do it through chat
and someone sees your secret token, they will be able to modify your quotes.

Simply go here to generate the 3 commands: https://twitch.center/customapi/quote/generate

Make sure you set the userlevel for addquote and delquote to moderator only.
EDIT: You can now add &no_id=1 to the url to disable numbering on quotes.
EDIT2: You can now delete ALL quotes by adding &clear=1 to !delquote command.
EDIT3: You can now silence non-error responses (“Quote added successfully”) with &silent=1

Usage

Get a quote

This one is usable by anyone, and there are 3 different ways to use it.

!quote
This will return a random quote

!quote 4
This will return the 4th quote in the list
You can use negative numbers (-1 would be the last quote)

!quote cookie
This will return a random quote containing the word “cookie”

There’s also a special command:
!quote list
This returns a webpage with all the quotes in a list

Add a quote

To add a new quote, you simply pass it to the !addquote command:
!addquote This is a new quote!

Remove a quote

There are two ways to remove a quote. Each quote when printed has an id, so you can use that:

This will delete quote #5
!delquote 5

Or, you can specify a substring of the quote, it will only delete it if there’s only one match
!delquote new quote

Editing a quote

This hasn’t been fully tested yet, and it’s not automatically added as part of the “Automatic install”, but you can manually add a “!editquote” command pointing to http://twitch.center/customapi/editquote using the private key. The syntax is:
!editquote [id] [new quote]

So for example:
!editquote 5 new quote replacing quote #5

Common issues

I accidentally got rid of my !quote command

If you still have access to the private token (used for !addquote/!delquote), you can recover using:

https://twitch.center/customapi/quote/recover?token=<private_token>

Unicode characters don’t work

Nightbot handles special characters fine, you may not have installed the commands properly. If you’re using another bot, you need to lookup documentation for that bot and contact them, as they behave differently. For example, on StreamElements bot, you need to use $(queryencode $(1:|' ')) instead of ${querystring}.

I’m getting 500 error

There may be something wrong with either Nightbot or my servers. Wait a bit for transient issues; if it persists, feel free to DM me on Twitter.

Suggestion / bugs

This is fresh out of the oven and hasn’t been thoroughly tested yet.
If you run into any strange behaviors, feel free to make a post here.
Similarly, if you have any suggestion for extra functionality, feel free to leave a comment.

26 Likes

Just set this up for a streamer who used to have a bot setup for quotes but no longer does. This worked via manual installation just fine, haven’t seen any issues so far (haven’t used it extensively obviously) and actually seems a lot more expansive than most quote systems on other bots. Nice job!

3 Likes

is there a way to customize this so that instead of using !quote, !addquote, and !delquote, we can use something like !darren (or anything specific)? What im trying to set up is a system so that you can add quote-sets for different regulars in a chat.

For example:
!darren would return a random quote from darren.
!john would return a random quote from john.
!barry would return a random quote from barry.

How would I need to customize the command to be able to do this? Also, is there a way to remove the number of the quote in the response? Right now, any time i use !quote, it’s returning something like “3. TestQuote”; I’d prefer it just say “TestQuote”

1 Like

You can achieve that using manual installation. If you go to the generate page, it gives you 3 commands. First is for getting a quote, second for adding and third for deleting.

Go to the nightbot control panel > commands > custom, and manually add 3 commands (!john, !addjohn, !deljohn) with the 3 commands respectively. Make sure to set !addjohn and !deljohn to moderator only.

Then, refresh the page the generate page to get a new set of links, then repeat the same process again for barry and darren.

Currently there’s no way to remove the number. You kinda need to for knowing which quote to delete. You can delete quotes with words but it’s not a very safe way of doing it.

1 Like

Awesome! i got the first part to work (unique quote indices), but wondering if there’s still not a way to remove the number from the return response.

I understand your point about the numbers being important for when you’re deleting quotes & the quotes list, but shouldn’t there be a way to have the quote return everything but the number?

When a new quote is entered, it’s assigned a number in the list (which will adjust if you delete quotes added before the newest one); since we’re adding the quotes without numbers, Im sure there’s a way to see the quotes without them. I believe that this would be similar to song lists in Nightbot–Nightbot will assign a song a number when it goes into the queue, but doesn’t necessarily show that number when someone issues a command to see what the current song playing is.

I don’t have much experience with coding, but if you want to send me a copy of the custom api then I could at least try to take a stab at something. If you’d rather not send it over, no worries…even if we can’t figure out a way to remove the numbers, this is still a pretty cool feature!

1 Like

Here you go:

Simply append &no_id=1 at the end of the !quote link.

It’d look something like so:

$(urlfetch http://twitch.center/customapi/quote?token=******&data=$(querystring)&no_id=1)

3 Likes

This is perfect. Thank you!

1 Like

Hey, I have a problem with server respond. When I add quote and then I type !quote, bot responds Nightbot: Remote Server Returned Code 500. So, how should I repair it? Thanks :slight_smile:

1 Like

@blaboscz Thank you for reporting the bug! There was an issue with Unicode characters, it could be fixed now.

2 Likes

Thank you so much, just one more thing, the same problem is with !quote list --> http://twitch.center/customapi/quote/list?token=23a39153 There is the same respond with code 500

1 Like

Good catch once again. Fixed.

2 Likes

Great job :slight_smile: Thank you so much. This is the best API i had ever used :slight_smile:

1 Like

Hi, is there anyway to delete all quotes at once or do you have to go one by one?

1 Like

I actually did add something for that, forgot to document it here, I’ll add it in a bit.

In the meantime, refer to this post:

If you have any questions, as how to set it up, feel free to ask.

2 Likes

Any idea how to add a quote with a specific number? For example, if I deleted quote 1, and there are quotes 2 and 3, how do I add a new quote in the space of quote 1 without it becoming quote 4?

1 Like

If you delete quote 1 quote 2 becomes quote 1. All the way up the line, the rest of the quotes fill in the gap.

Is there any way to make nightbot say random quotes using timers?

1 Like

Yes, actually. In your timer if you set the alias to be your !quote command or if you set the message field to be customapi/urlfetch for the quote grabber missing the $(querystring) variable it will always pull a random quote for your timer to send out.

1 Like

So, i should put something like:
$(urlfetch http://twitch.center/customapi/quote?token=TOKEN)

Is that right?

1 Like

Put:
$(urlfetch http://twitch.center/customapi/quote?token=TOKEN&data=)
Just to be safe

2 Likes