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 #70 from mrepol742/master
Browse files Browse the repository at this point in the history
Initial Commit
  • Loading branch information
mrepol742 authored Feb 7, 2024
2 parents 66e822c + 890e14d commit 170e827
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,14 +301,16 @@ function redfox_fb(fca_state, login, cb) {
new redfox(fca_state, (err, api) => {
if (err) {
handleError({ stacktrace: err, cuid: login });
accounts = accounts.filter((item) => item !== login);

if (err && err.error && err.error == "unable to get cookie.") {

accounts = accounts.filter((item) => item !== login);
for (threads in settingsThread) {
if (settingsThread[threads].lock && settingsThread[threads].lock == login) {
delete settingsThread[threads]["lock"];
}
}

if (err && err.error && err.error == "unable to get cookie.") {
unlinkIfExists(__dirname + "/data/cookies/" + login + ".bin");
unlinkIfExists(__dirname + "/data/cookies/" + login + ".key");
}
Expand Down Expand Up @@ -401,16 +403,16 @@ function redfox_fb(fca_state, login, cb) {

api.eventListener(async (err, event) => {
if (err) {
handleError({ stacktrace: err, cuid: login, e: event });

if (err && err.error && err.error == "unable to get cookie.") {
handleError({ stacktrace: err, cuid: login, e: event });

accounts = accounts.filter((item) => item !== login);
for (threads in settingsThread) {
if (settingsThread[threads].lock && settingsThread[threads].lock == login) {
delete settingsThread[threads]["lock"];
}
}

if (err && err.error && err.error == "unable to get cookie.") {
unlinkIfExists(__dirname + "/data/cookies/" + login + ".bin");
unlinkIfExists(__dirname + "/data/cookies/" + login + ".key");
}
Expand Down Expand Up @@ -1376,7 +1378,7 @@ async function ai22(api, event, query, query2) {
if (userAnswer == settings.shared.quiz[q].correctAnswer1 || userAnswer == settings.shared.quiz[q].correctAnswer) {
addBalance(name, points);
} else {
removeBalance(name, 150);
removeBalance(name, 500);
}
});

Expand Down Expand Up @@ -5982,14 +5984,21 @@ async function ai(api, event) {
data.shift();
const picker = Math.floor(Math.random() * 2);
if (/^\d+$/.test(data[0])) {
const points = parseInt(data[0]);
let points = parseInt(data[0]);
if (/^(head(s|)|tail(s|))$/.test(data[1])) {
getUserProfile(event.senderID, async function (name) {
if (!name.balance && event.senderID != settings.shared.root) {
sendMessage(api, event, "You have 0 $ balance yet.");
} else if (points >= name.balance && event.senderID != settings.shared.root) {
sendMessage(api, event, "You don't have enough balance!");
} else if (points < 500) {
sendMessage(api, event, "Token provided is too small! Minimum of 500 tokens.");
} else if (points > 9999) {
sendMessage(api, event, "Token provided is too larged! Maximum of 10, 000 tokens");
} else if ((picker == 1 && /^head(s|)$/.test(data[1])) || (picker == 0 && /^tail(s|)$/.test(data[1]))) {
if (points >= 2000) {
points = points - (points * 0.15);
}
addBalance(name, points);
sendMessage(api, event, "You win!");
} else {
Expand All @@ -6006,7 +6015,7 @@ async function ai(api, event) {
addBalance(name, 500);
sendMessage(api, event, "You win!");
} else {
removeBalance(name, 250);
removeBalance(name, 200);
sendMessage(api, event, "You loss!");
}
});
Expand Down Expand Up @@ -6034,6 +6043,10 @@ async function ai(api, event) {

const answer = quiz[picker].answer;

if (!users.admin.includes(event.senderID) && settings[api.getCurrentUserID()].owner != event.senderID && !accounts.includes(event.senderID) && settings.shared.root != event.senderID && settings.shared.delay && bn) {
await sleep(2000);
}

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 Down Expand Up @@ -6627,7 +6640,7 @@ function isGoingToFast(api, event) {
});
});
}
if (!!users.list.find((user) => event.senderID === user.id && user["name"] === undefined)) {
if (!users.list.find((user) => event.senderID === user.id && !user["name"])) {
api.getUserInfo(event.senderID, async (err, data1) => {
if (err) return handleError({ stacktrace: err, cuid: api.getCurrentUserID(), e: event });
utils.logged("old_user " + event.threadID + " " + data1[event.senderID].name);
Expand Down

0 comments on commit 170e827

Please sign in to comment.