[CustomAPI] Quote system


#265

Bless up, you a real one G


#266

how to use str.slice() to silence the Successfully added entry #? tnx~~


#267

Instead of

$(urlfetch http://twitch.center/customapi/addquote?token=YOURTOKEN&data=$(querystring))

use

$(eval `$(urlfetch http://twitch.center/customapi/addquote?token=YOURTOKEN&data=$(querystring))`;" ")

#268

Hello! I was just wondering if I could have some help getting the !editquote command to work. I have tried adding it in my channel as suggested, but when I test it, I always get “Invalid Entry Index” from Nightbot. I’m wondering if it has to do with the way I formatted my quotes, with dates and names, which is different from the default way. Other than that, I have no idea what could be causing it. What I’m adding in is

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

and my addquote command is

$(urlfetch http://twitch.center/customapi/addquote?token=MYTOKEN&data="$(eval var q = “$(query)”; q.slice(q.indexOf(" “) + 1))” - $(touser), $(time US/Eastern “L”))

Any help would be greatly appreciated!


#269

You have to type !editquote ENTRYINDEX NEWVALUE
For example: !editquote 1 New value for first quote

Also, you aren’t properly encoding the quote in your addquote command. The quote should be encoded so that if you type special characters like & when using your addquote command, they are treated as data and not as special characters. Here is a fixed version:

$(urlfetch http://twitch.center/customapi/addquote?token=MYTOKEN&data=$(eval var q = decodeURIComponent("$(querystring)"); encodeURIComponent("\"" + q.slice(q.indexOf(" ") + 1) + "\" - "))$(querystring $(touser), $(time US/Eastern "L")))

#270

Thank you so much! It all works properly now. Thanks for fixing my addquote as well. I was wondering why special characters broke the quote, but I figured it might be a limitation of the bot. Turns out it was just me not knowing what I was doing. I was wondering if it was possible to keep the format when I do !editquote. What I mean is, I currently have to do this
quote
And I would like to not have to add the whole formatting in every time when I edit a quote, and just edit the part in quotation marks ONLY, not the whole date and everything. It’s not that big of a deal if I have to do it manually that way, but I was just curious. Thank you for all of your help!


#271

Yes, but it will require you to make a second command named _!editquote and make !editquote an alias to _!editquote

Here are the commands:

!editquote (alias to _!editquote)
$(eval e=encodeURIComponent;m=decodeURIComponent("$(querystring)").match(/^(\d+) (.+)/);m?e(`${e(m[1])} ${e(m[2])}`):"0") $(urlfetch $(eval m=decodeURIComponent("$(querystring)").match(/^(\d+) .+/);m?`http://twitch.center/customapi/quote?token=PUBLICTOKEN&data=${encodeURIComponent(m[1])}&no_id=1`:"0"))

_!editquote
$(urlfetch http://twitch.center/customapi/editquote?token=PRIVATETOKEN&data=$(eval d=decodeURIComponent;if((a=d("$(querystring)").match(/^([^ ]+) (.*)/))&&(b=d(a[1]).match(/(\d+) (.+)/))&&(c=a[2].match(/^".*"([^"]*)$/)))encodeURIComponent(`${d(b[1])} "${d(b[2])}"${c[1]}`);else"0"))

#272

Thank you so much for all of your help @am_1! I appreciate it a ton. I wish I knew all of this a year ago when I started setting up this API. You are very helpful.


#273

But actually i want to run a if statement like this

$(eval decodeURIComponent("$(querystring $(2))").toLowerCase==“ID”?$(urlfetch http://twitch.center/customapi/addquote?token=TOKEN&data=$(querystring)).slice() +“You are right”:"$(user) Fail!")

If user say ID in second string, hide alert and show you are right, if not, show fail.


#274

Add a random quote function?


#275

If you don’t add a number a random quote is shown.


#276

alright i tried learning this on my own but have had no success. the custom api for recent followers will not work for me keeps popping up saying " The most recent followers are No channel"


#277

@ehsankia I’ve noticed that the negative index causes the last added quote to be listed as either “-1”, “0” or the listed number (example 259). Additionally, if we call “!quote” and a string/word and a quote is not found, it only pulls the last quote. Is it possible to either respond with a random quote or “no quote found”?

Example: “!quote curse” is used, however, no quote is found using the word “curse” so it pulls the last quote added.


#278

Is there any way nightbot does not need to send me an answer?


[CustomAPI] Queue system
#279

@coffeman0 You can use $(eval) to make Nightbot send a request to the API but also not output its response like so:

$(eval a='$(urlfetch http://twitch.center/customapi/addquote?token=yourPrivateTokenHere&data=dataInput)';' ')

Creating the variable a will call the $(urlfetch) variable within the $(eval), using the API. Then it’ll make Nightbot output a space, which will then make the message blank.


#280

I am using the quote system for my game requests so people do !gamerequest (name of game) and it adds it to the list. My issue is the ! command is not seen to my viewers so i was wondering if there was a way for it to respond with what they added.
Nightbot currently says this: Successfully added entry #4
However it would be cool if it said this: Successfully added entry #4 - Zelda

or whatever. or even a line after that simply said the game name. any thoughts or Ideas… thank you all


#281

@Durendx The response for the command can be:

$(urlfetch http://twitch.center/customapi/addquote?token=...) - $(query)

Nightbot would say “Successfully added entry #X” then say what was added in the $(query) after that.


#282

@ehsankia, do you know if the !delquote and !editquote commands are not working at the moment? I just found this thread and added to my channel but those 2 commands are not functioning right.

I have added 4 quotes just fine and they show when I !quote 1 or 3 but when I do !delquote 3 or 1, it says “no matching entry found”

Are you able to help?


#284

I don’t know if this is still being responded to but how do you make nightbot say “quote #3” instead of just “3.”? Also when I try to say !quote #3 instead of !quote 3 it doesn’t recognize that either. It seems to not recognize the # at all. I’m not great with programming so any help would be appreciated


#285

@andywall In your command response just do something like:

Quote #$(urlfetch http://twitch.center/customapi/...)