Open FranciscoG opened 6 years ago
I really really want to do the GET JSON one.
%% GET key.to[2].item FROM url %%
Strict syntax
Trigger must begin and end with the %%
GET
FROM
I'm sure Dubtrack already does this but I will sanitize the return before putting it in the chat
started this work in 1.24.0
using "{ .... }" instead of "%% ... %%"
for now only simple GET requests work
see this comment for an example of how to create this kind of special code trigger
need to add Accept/Content-type JSON headers
these commands can possibly be replaced with the new trigger code but I need to extend what I've done
most of them return JSON but some don't
!fact
just uses the response body as is, plain text
!todayfact
uses today's date so will have to provide those a util constants
var month = new Date().getMonth() + 1;
var day = new Date().getDate();
!urban
combines three different parts of an API return
!translate just builds a URL and puts it on screen, not api calls so have to consider that as well
and finally, figure out a way to search and filter triggers. Could !wasitbrad be done in trigger code?
GET
- means that this code block will be making a URL get request
GET JSON.<pathToData>
- the json.
signals that there will be a json response and everything after the dot will be the path to traverse using lodash.get in the object
GET TEXT
- will signal that the response is too be treated as plain text
FROM <url>
- set the URL to make a request from
Still thinking about how to format them. For now inside brackets will do i guess. Trying to figure out what wont clash
{M}
- will be the current month as Int: var month = new Date().getMonth() + 1;
{D}
- will be the today's date: var day = new Date().getDate();
!urban combines three different parts of an API return
// get the first reponse
var first = json.list[0];
let def = first.definition;
let word = first.word;
let link = first.permalink;
bot.sendChat(`*${word}* - ${def} ${link}`);
GET JSON.list[0] FROM <url> FORMAT "${word} - ${definition} ${link}"
makes the api call from the url
sets json.list[0] as a local var: var obj = json.list[0]
then parses the templates replacing the words using them as keys from the local var
FORMAT string
- parse string and replace each ${key}
with value of obj[key]
More Keywords
FLOW
- makes the trigger add a flow point
FLOW emoji
- use a different emoji
PROP
PROP emoji
very similar to the normal way of doing it (+prop=ghost
) but slightly modified to follow the syntax I'm creating
note to self, the input in the chat box has a character limit of 255 but the input in the DM panel does not have a character limit
As of now we have the following
%me% - insert the person's name into a trigger %dj% - insert the current DJ's name into a trigger +prop - make the current trigger give a prop point +flow - to add flow points
other possibilities
for example right now if you use
+prop
you get this: @%dj% now has 137 props :fist:maybe something like
+prop=heart
will change it to this @%dj% now has 137 props :heart:+[system]
to add points in triggersso when we add a
dank
ortrippy
point system we can simple use them+dank
or+trippy
and also use the same system where you can set the icon+dank=smoking
examples:
%% GET {url} FROM https://random.dog/woof.json
%% GET {file} FROM https://random.dog/meow
you can also access sub properties of the json just using the dot notation. It will use lodash.get internally%% GET data.images[1].url from https://whatever.com/api