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

Commit

Permalink
Merge pull request #49 from mrepol742/master
Browse files Browse the repository at this point in the history
Initial PR
  • Loading branch information
mrepol742 authored Jan 30, 2024
2 parents b9e7ca7 + ab108fe commit 41fb4bd
Show file tree
Hide file tree
Showing 28 changed files with 836 additions and 144 deletions.
2 changes: 1 addition & 1 deletion data/accountPreferences.json

Large diffs are not rendered by default.

24 changes: 0 additions & 24 deletions data/test-find.js

This file was deleted.

21 changes: 0 additions & 21 deletions data/test.js

This file was deleted.

41 changes: 0 additions & 41 deletions data/test_insert.js

This file was deleted.

38 changes: 23 additions & 15 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,16 @@ let settings = JSON.parse(fs.readFileSync(__dirname + "/data/accountPreferences.
let settingsThread = JSON.parse(fs.readFileSync(__dirname + "/data/threadPreferences.json", "utf8"));
let users = JSON.parse(fs.readFileSync(__dirname + "/data/users.json", "utf8"));
let groups = JSON.parse(fs.readFileSync(__dirname + "/data/groups.json", "utf8"));
let quiz = JSON.parse(fs.readFileSync(__dirname + "/data/quiz.json", "utf-8"));
let asciifonts = JSON.parse(fs.readFileSync(__dirname + "/data/ascii.json"));
let dyk = JSON.parse(fs.readFileSync(__dirname + "/data/dyk.json"));
let wyr = JSON.parse(fs.readFileSync(__dirname + "/data/wyr.json"));
let Eball = JSON.parse(fs.readFileSync(__dirname + "/data/8ball.json"));
let joke = JSON.parse(fs.readFileSync(__dirname + "/data/joke.json"));
let cat = JSON.parse(fs.readFileSync(__dirname + "/data/cat.json"));
let crashLog = JSON.parse(fs.readFileSync(__dirname + "/data/crash-log.json"));

let quiz = JSON.parse(fs.readFileSync(__dirname + "/src/data/quiz.json", "utf-8"));
let asciifonts = JSON.parse(fs.readFileSync(__dirname + "/src/data/ascii.json"));
let dyk = JSON.parse(fs.readFileSync(__dirname + "/src/data/dyk.json"));
let wyr = JSON.parse(fs.readFileSync(__dirname + "/src/data/wyr.json"));
let Eball = JSON.parse(fs.readFileSync(__dirname + "/src/data/8ball.json"));
let joke = JSON.parse(fs.readFileSync(__dirname + "/src/data/joke.json"));
let cat = JSON.parse(fs.readFileSync(__dirname + "/src/data/cat.json"));

let package = JSON.parse(fs.readFileSync(__dirname + "/package.json", "utf8"));
let cmdPage = JSON.parse(gen());
let R_S_H_12_mmm = fs.existsSync(__dirname + "/.nosave");
Expand Down Expand Up @@ -4441,7 +4443,7 @@ async function ai(api, event) {
} else {
getUserProfile(id, async function (name) {
if (!name.balance) {
sendMessage(api, event, name + " have 0 $ balance.");
sendMessage(api, event, name.firstName + " have 0 $ balance.");
} else {
sendMessage(api, event, utils.formatOutput("Balance", [formatDecNum((name.balance / 1000) * 0.007) + "$ " + name.firstName], "github.com/prj-orion"));
}
Expand Down Expand Up @@ -6140,15 +6142,19 @@ async function ai(api, event) {
}
const picker = Math.floor(Math.random() * quiz.length);
let construct = quiz[picker].question + "\n";
let choiceN = ["A", "B", "C", "D"];
let cAA;
for (choice in quiz[picker].choices) {
let c = quiz[picker].choices[choice];
construct += "\n" + choiceN[choice] + ". " + c;
if (c.replaceAll(" ", "").toLowerCase() == quiz[picker].answer) {
cAA = choiceN[choice].toLowerCase();
let cAA = "";

if (quiz[picker].choices) {
let choiceN = ["A", "B", "C", "D"];
for (choice in quiz[picker].choices) {
let c = quiz[picker].choices[choice];
construct += "\n" + choiceN[choice] + ". " + c;
if (c.replaceAll(" ", "").toLowerCase() == quiz[picker].answer) {
cAA = choiceN[choice].toLowerCase();
}
}
}

const answer = quiz[picker].answer;
api.sendMessage(updateFont(construct, event.senderID), event.threadID, async (err, messageInfo) => {
if (err) return sendMessageErr(api, event, event.threadID, event.messageID, event.senderID, err);
Expand All @@ -6157,6 +6163,8 @@ async function ai(api, event) {
settings.shared["quiz"] = [];
}

if (!messageInfo.messageID) return utils.logged("undefined messageinfo.messageID");

settings.shared.quiz.push({ correctAnswer: answer, correctAnswer1: cAA, messageID: messageInfo.messageID, time: Math.floor(Date.now() / 1000) + 60 });
await sleep(60000);
delete settings.shared.quiz[picker];
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
43 changes: 43 additions & 0 deletions scratch/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
const axios = require("axios");
const FormData = require("form-data");

const OPENAI_API_KEY = "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";

const client = axios.create({
headers: {
Authorization: "Bearer " + OPENAI_API_KEY,
},
});

const params = {
id: "cmpl-7BlVtrcMHjzfvlpPDw8O7yKYx8FLI",
prompt: "How are you?",
model: "text-davinci-003",
max_tokens: 10,
temperature: 0,
};

const openai = axios.create({
headers: {
Authorization: "Bearer " + OPENAI_API_KEY,
},
});

async function createCompletions(params) {
let aa = await openai
.post("https://api.openai.com/v1/completions", params)
.then((result) => {
return result;
})
.catch((err) => {
return err;
});
return aa;
}

async function aa() {
let aaa = await createCompletions(params);
console.log(aaa);
}

aa();
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 41fb4bd

Please sign in to comment.