Back
Version 56
6/26/2024
const issue_regex =
/<ISSUE id="(\d+)">\s*<TITLE>(.*?)<\/TITLE>\s*<TEXT>(.*?)<\/TEXT>\s*<AUTHOR>(.*?)<\/AUTHOR>\s*(?:<EDITOR>(.*?)<\/EDITOR>\s*)?(?:<PIC1>(.*?)<\/PIC1>\s*)?(?:<PIC2>(.*?)<\/PIC2>\s*)?(?:<OPTION id="(\d+)">(.*?)<\/OPTION>\s*)*<\/ISSUE>/;
const option_regex = /<OPTION id="(\d+)">(.*?)<\/OPTION>\s*/g;
async function query(data) {
const response = await fetch(
"https://api-inference.huggingface.co/models/cardiffnlp/twitter-roberta-base-sentiment-latest",
{
headers: { Authorization: `Bearer ${Deno.env.get("HF_TOKEN")}` },
method: "POST",
body: JSON.stringify(data),
},
);
let result = await response.json();
return result;
}
export default async function(interval: Interval) {
const httpHeaders = {
"User-Agent": `${Deno.env.get("EMAIL")} AI Issue Answering`,
"X-Autologin": Deno.env.get("AUTOLOGIN"),
};
const myHeaders = new Headers(httpHeaders);
console.log("Starting...");
let response = await fetch(
`https://www.nationstates.net/cgi-bin/api.cgi?nation=${Deno.env.get("NATION_ID")}&q=issues`,
{
headers: myHeaders,
method: "GET",
},
);
myHeaders.set("X-Pin", response.headers.get("X-Pin"));
myHeaders.delete("X-Autologin");
let result = await response.text();
let issue = result.match(issue_regex);
console.log(issue);
Updated: June 26, 2024