Editing commands with script

is there a way too make it so that a script can edit commands in nighbot? i know i can use url fetch, but can i make it so that a script edits the url fetch without using eval?

@denniskarbon

You could write a script to interface with the Nightbot API to edit a custom command. Relevant documentation: https://api-docs.nightbot.tv/#edit-custom-command-by-id

Host that script somewhere, then you can use a $(urlfetch) to call that script.

i have around 8 commands i want to be edited, i need the script too read off what is on the clipboard(what im copying) then change those 8 commands too that. right now im using custom command (!editlink “link”) eval deleting current information in custom api quote system then using urlfetch too output the link from those 8 command. my goal i too make it so that the script copies what is in the clipboard too the custom api quote system so that i dont have too use !editlink

dont think you answer would help that, and i dont have that much experience making scripts. so trying too learn some new stuff here :slight_smile:

If you’re looking for a way to edit those 8 commands without using !editlink, you would either have to edit those commands through the Nightbot dashboard (a simpler option) or, as said before, write a script that interfaces with the Nightbot API (or, if the 8 commands are making urlfetch requests to the quote list, then a script that interfaces with the quote API).

what is the easiest way for the script too interface qith the quote api?

Your script should make HTTP requests to the quote API.

An example if you’re using PHP to run cURL commands:

<?php

// Enter your quote list private token here
$pt = "PRIVATE_TOKEN";
$ch = curl_init();

/* If I recall correctly, requests to the quote API are GET requests. 
   This is probably unnecessary because curls are GET by default. 
   Do this for requests like POSTs/PUTs/DELETEs etc. */
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true);

// Enter whatever stuff you want to add to the quote list
params = array("token" => $pt, "data" => "DATA_TO_ENTER");
curl_setopt($ch, CURLOPT_URL, "https://twitch.center/customapi/addquote?" . http_build_query($params));

echo curl_exec($ch);
curl_close($ch);

?>

could it be possible too make python script change the content in the custom api?

Any server-side language where you can make HTTP requests should work.

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