17 console.log("Starting...");
18 let response = await fetch(
19 `https://www.nationstates.net/cgi-bin/api.cgi?nation=${nations[i]}&q=issues`,
20 {
21 headers: myHeaders,
3Requires:
4- Huggingface token (HF_TOKEN) for the sentiment analysis of options. Generate a read-only token at [Huggingface](https://huggingface.co/settings/tokens) after making an account to use.
5- Email address (EMAIL) for user agent. Required as per [NationStates ToS](tionstates.net/pages/api.html#terms)
6- Autologin token (AUTOLOGIN) for logging into NationStates. See [NationStates API docs](https://www.nationstates.net/pages/api.html#authenticating) for more info.
7- Nation name (NATION_ID). Put your nation name, the one you use when you login to your account.
8
9[](https://www.val.town/v/stevekrouse/blob_admin_app/fork)
10
11It uses [basic authentication](https://www.val.town/v/pomdtr/basicAuth) with your [Val Town API Token](https://www.val.town/settings/api) as the password (leave the username field blank).
12
13# TODO
11async function query(data) {
12 const response = await fetch(
13 "https://api-inference.huggingface.co/models/cardiffnlp/twitter-roberta-base-sentiment-latest",
14 {
15 headers: { Authorization: `Bearer ${Deno.env.get("HF_TOKEN")}` },
34 console.log("Starting...");
35 let response = await fetch(
36 `https://www.nationstates.net/cgi-bin/api.cgi?nation=${Deno.env.get("NATION_ID")}&q=issues`,
37 {
38 headers: myHeaders,
71
72 let execute_issue = await fetch(
73 `https://www.nationstates.net/cgi-bin/api.cgi?nation=${
74 Deno.env.get("NATION_ID")
75 }&c=issue&issue=${issue_id}&option=${selected_option}`,
1/** @jsxImportSource npm:hono/jsx */
2
3import { api } from "https://esm.town/v/pomdtr/api";
4import { extractValInfo } from "https://esm.town/v/pomdtr/extractValInfo";
5import { Island } from "https://esm.town/v/pomdtr/hono_island";
17const router = new Hono();
18
19const me = await api("/v1/me", { authenticated: true });
20const author = me.username;
21
57});
58
59router.post("/api/refresh", async () => {
60 const tests = await loadTests();
61
65async function loadTests(): Promise<TestType[]> {
66 const query = `https://esm.town/v/${author}/test_explorer`;
67 const { data: vals } = await api(`/v1/search/vals?query=${query}`, { authenticated: true });
68 const tests = {};
69 for (const val of vals) {
103}
104
105router.post("/api/run", async (c) => {
106 const body = await c.req.json();
107 try {
1/** @jsxImportSource npm:hono/jsx */
2
3import { api } from "https://esm.town/v/pomdtr/api";
4import { extractValInfo } from "https://esm.town/v/pomdtr/extractValInfo";
5import { Island } from "https://esm.town/v/pomdtr/hono_island";
56});
57
58router.post("/api/refresh", async () => {
59 const tests = await loadTests();
60
64async function loadTests(): Promise<TestType[]> {
65 const query = `https://esm.town/v/${author}/test_explorer`;
66 const { data: vals } = await api(`/v1/search/vals?query=${query}`, { authenticated: true });
67 const tests = {};
68 for (const val of vals) {
102}
103
104router.post("/api/run", async (c) => {
105 const body = await c.req.json();
106 try {
1/** @jsxImportSource npm:hono/jsx */
2
3import { api } from "https://esm.town/v/pomdtr/api";
4import { extractValInfo } from "https://esm.town/v/pomdtr/extractValInfo";
5import { Island } from "https://esm.town/v/pomdtr/hono_island";
56});
57
58router.post("/api/refresh", async () => {
59 const tests = await loadTests();
60
64async function loadTests(): Promise<TestType[]> {
65 const query = `https://esm.town/v/${author}/test_explorer`;
66 const { data: vals } = await api(`/v1/search/vals?query=${query}`, { authenticated: true });
67 const tests = {};
68 for (const val of vals) {
102}
103
104router.post("/api/run", async (c) => {
105 const body = await c.req.json();
106 try {
33
34In order to define a test, the user need to import the Test class from `https://val.town/v/<account>/Test`.
35So we can use the api to search for vals containing the `https://val.town/v/<account>/Test` string to locate the vals containing tests.
36
37Next, we need to extract the tests from the val exports. We use `exported instanceof Test` to filter them (at some point we will probably use static analysis for this).
6
7// Make sure to set these environment variables
8const token = Deno.env.get("DUB_API_KEY");
9const dubWorkspaceId = Deno.env.get("DUB_WORKSPACE_ID");
10const signingSecret = Deno.env.get("SLACK_MUX_LINK_SIGNING_SECRET");
57 // If the destination is `list`, return a list of all the existing short links
58 if (destination === "list") {
59 const req = await fetch(`https://api.dub.co/links?workspaceId=${dubWorkspaceId}`, {
60 headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json" },
61 });
84
85 try {
86 const resp = await fetch(`https://api.dub.co/links?workspaceId=${dubWorkspaceId}`, options).then(
87 response => response.json(),
88 );
3Requires:
4- Huggingface token (HF_TOKEN) for the sentiment analysis of options. Generate a read-only token at [Huggingface](https://huggingface.co/settings/tokens) after making an account to use.
5- Email address (EMAIL) for user agent. Required as per [NationStates ToS](tionstates.net/pages/api.html#terms)
6- Autologin token (AUTOLOGIN) for logging into NationStates. See [NationStates API docs](https://www.nationstates.net/pages/api.html#authenticating) for more info.
7- Nation name (NATION_ID). Put your nation name, the one you use when you login to your account.
8