Skip to content
This repository has been archived by the owner on Nov 7, 2024. It is now read-only.

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mrepol742 committed Mar 26, 2024
1 parent 0090490 commit 57b5e5b
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 54 deletions.
6 changes: 5 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@ DEBUG=false
# apikeys
FACEBOOK=6628568379%7Cc1e620fa708a1d5696fb991c1bde5662
# this is global openai key owners can set their own respective keys if they want to
OpenAI=
OpenAI=

# Server
LOG_PORT=8081
PORT=8080
8 changes: 3 additions & 5 deletions .github/workflows/npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@ jobs:
with:
node-version: 20
cache: "npm"
- name: NPM Clean Install
run: npm ci
- name: NPM install
run: npm i --include=dev
- name: Eslint
run: |
npm i --include=dev
npm run eslint ./
run: npm run eslint ./

96 changes: 48 additions & 48 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ let cmdPage = JSON.parse(gen());

if (process.env.DEBUG) {
settingsThread = { default: { leave: false, unsend: false, nsfw: true, cmd: 1 } };
utils.logged("debug_enb overriding default threads settings");
}

/*
Expand Down Expand Up @@ -124,7 +125,7 @@ const latinC = /[^a-z0-9\s]/gi;
const normalize = /[\u0300-\u036f|\u00b4|\u0060|\u005e|\u007e]/g;

/*
const LOG_PORT = process.env.LOG_PORT || 3001;
const LOG_PORT = process.env.LOG_PORT;
http.createServer(getLogs()).listen(LOG_PORT, () => {
utils.logged("log_server_running http://localhost:" + LOG_PORT);
});
Expand Down Expand Up @@ -376,13 +377,8 @@ function redfox_fb(fca_state, login, cb) {
unlinkIfExists(__dirname + "/data/cookies/" + login + ".key");
}

if (typeof cb === "function") {
return cb(true);
}

if (accounts.length == 0) {
addAccount();
}
if (typeof cb === "function") return cb(true);
if (accounts.length == 0) addAccount();
return;
}

Expand Down Expand Up @@ -5693,40 +5689,46 @@ async function ai(api, event) {
} else {
data.shift();
let value = data.join(" ");
if (value == "--anime") {
getResponseData("https://animechan.vercel.app/api/random").then((response) => {
if (response == null) return sendMessage(api, event, handleError({ stacktrace: response, cuid: api.getCurrentUserID(), e: event }));
sendMessage(api, event, response.quote + "\n\nby " + response.character + " of " + response.anime);
});
} else if (value == "--advice") {
getResponseData("https://zenquotes.io/api/random").then((response) => {
if (response == null) return sendMessage(api, event, handleError({ stacktrace: response, cuid: api.getCurrentUserID(), e: event }));
let result;
for (let i = 0; i < response.length; i++) {
result = response[i].q;
}
sendMessage(api, event, result);
});
} else if (value == "--inspiration") {
getResponseData("https://zenquotes.io/api/random").then((response) => {
if (response == null) return sendMessage(api, event, handleError({ stacktrace: response, cuid: api.getCurrentUserID(), e: event }));
let result;
for (let i = 0; i < response.length; i++) {
result = response[i].a + " says\n" + response[i].q;
}
sendMessage(api, event, result);
});
} else if (value == "--motivation") {
getResponseData("https://zenquotes.io/api/random").then((response) => {
if (response == null) return sendMessage(api, event, handleError({ stacktrace: response, cuid: api.getCurrentUserID(), e: event }));
let result;
for (let i = 0; i < response.length; i++) {
result = response[i].q + "\n\nby " + response[i].a;
}
sendMessage(api, event, result);
});
} else {
sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: qoute type" + "\n " + example[Math.floor(Math.random() * example.length)] + " qoute --anime");
switch (value) {
case "--anime": {
getResponseData("https://animechan.vercel.app/api/random").then((response) => {
if (response == null) return sendMessage(api, event, handleError({ stacktrace: response, cuid: api.getCurrentUserID(), e: event }));
sendMessage(api, event, response.quote + "\n\nby " + response.character + " of " + response.anime);
});
}
case "--advice": {
getResponseData("https://zenquotes.io/api/random").then((response) => {
if (response == null) return sendMessage(api, event, handleError({ stacktrace: response, cuid: api.getCurrentUserID(), e: event }));
let result;
for (let i = 0; i < response.length; i++) {
result = response[i].q;
}
sendMessage(api, event, result);
});
}
case "--inspiration": {
getResponseData("https://zenquotes.io/api/random").then((response) => {
if (response == null) return sendMessage(api, event, handleError({ stacktrace: response, cuid: api.getCurrentUserID(), e: event }));
let result;
for (let i = 0; i < response.length; i++) {
result = response[i].a + " says\n" + response[i].q;
}
sendMessage(api, event, result);
});
}
case "--motivation": {
getResponseData("https://zenquotes.io/api/random").then((response) => {
if (response == null) return sendMessage(api, event, handleError({ stacktrace: response, cuid: api.getCurrentUserID(), e: event }));
let result;
for (let i = 0; i < response.length; i++) {
result = response[i].q + "\n\nby " + response[i].a;
}
sendMessage(api, event, result);
});
}
default: {
sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: qoute type" + "\n " + example[Math.floor(Math.random() * example.length)] + " qoute --anime");
}
}
}
} else if (testCommand(api, query, "time--timezone", event.senderID)) {
Expand All @@ -5737,18 +5739,16 @@ async function ai(api, event) {
} else {
let body = getDataFromQuery(data);
if (isValidTimeZone(body)) {
sendMessage(api, event, "It's " + getCurrentDateAndTime(body));
} else {
sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: time --timezone tmz" + "\n " + example[Math.floor(Math.random() * example.length)] + " time --timezone Asia/Manila");
return sendMessage(api, event, "It's " + getCurrentDateAndTime(body));
}
sendMessage(api, event, "Houston! Unknown or missing option.\n\n Usage: time --timezone tmz" + "\n " + example[Math.floor(Math.random() * example.length)] + " time --timezone Asia/Manila");
}
} else if (testCommand(api, query, "time", event.senderID, "user", true)) {
getUserProfile(event.senderID, async function (name) {
if (name.firstName != undefined && name.timezone) {
sendMessage(api, event, "It's " + getCurrentDateAndTime(name.timezone));
} else {
sendMessage(api, event, "It's " + getCurrentDateAndTime("Asia/Manila"));
return sendMessage(api, event, "It's " + getCurrentDateAndTime(name.timezone));
}
sendMessage(api, event, "It's " + getCurrentDateAndTime("Asia/Manila"));
});
} else if (testCommand(api, query, "newyear", event.senderID, "user", true)) {
if (isGoingToFast(api, event)) return;
Expand Down

0 comments on commit 57b5e5b

Please sign in to comment.