This repository has been archived by the owner on Aug 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
180 additions
and
68 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,53 @@ | ||
import dataStore from "../data/dataStore"; | ||
import axios from "axios"; | ||
|
||
var parsedBlacklist = []; | ||
var personalBlacklist = []; | ||
|
||
const updateLists = async () => { | ||
var lists = []; | ||
const updatePersonalBlacklist = async () => { | ||
var updatedList = []; | ||
await axios | ||
.get("https://api.pixelic.de/hypixel/v1/overlay/reportsystem/list/personal", { headers: { "X-API-Key": dataStore.get("pixelicKey"), "cache-control": "no-cache" } }) | ||
.then((res) => lists.push(res.data.reports)) | ||
.then((res) => { | ||
updatedList = res.data.reports; | ||
}) | ||
.catch(() => {}); | ||
personalBlacklist = updatedList; | ||
}; | ||
|
||
// TODO: Add other extra custom blacklist from other people | ||
var globalBlacklist = []; | ||
|
||
var updatedLists = []; | ||
for (const list of lists) { | ||
for (const entry of list) { | ||
const checkForDuplicate = updatedLists.some((e) => e.suspect === entry.suspect); | ||
if (checkForDuplicate) { | ||
if (checkForDuplicate.reason === "sniper" && entry.reason === "cheater") { | ||
updatedLists[updatedLists.findIndex((e) => e.suspect === entry.suspect)].reason = "cheater"; | ||
} | ||
} else { | ||
updatedLists.push(entry); | ||
} | ||
} | ||
} | ||
parsedBlacklist = updatedLists; | ||
const updateGlobalBlacklist = async () => { | ||
var updatedList = []; | ||
await axios | ||
.get("https://api.pixelic.de/hypixel/v1/overlay/reportsystem/list/global", { headers: { "X-API-Key": dataStore.get("pixelicKey"), "cache-control": "no-cache" } }) | ||
.then((res) => { | ||
updatedList = res.data.reports; | ||
}) | ||
.catch(() => {}); | ||
globalBlacklist = updatedList; | ||
}; | ||
|
||
updateLists().then(() => {}); | ||
const updateLists = () => { | ||
if (dataStore.get("blacklists").some((l) => l.name === "Personal" && l.enabled === true)) updatePersonalBlacklist(); | ||
if (dataStore.get("blacklists").some((l) => l.name === "Global" && l.enabled === true)) updateGlobalBlacklist(); | ||
}; | ||
|
||
setInterval(async () => { | ||
await updateLists(); | ||
updateLists(); | ||
setInterval(() => { | ||
updateLists(); | ||
}, 60 * 1000); | ||
|
||
export default { | ||
add: (UUID, reason) => { | ||
parsedBlacklist.push({ suspect: UUID, reason: reason }); | ||
personalBlacklist.push({ suspect: UUID, reason: reason }); | ||
}, | ||
remove: (UUID) => { | ||
parsedBlacklist = parsedBlacklist.filter((p) => p.suspect !== UUID); | ||
personalBlacklist = personalBlacklist.filter((p) => p.suspect !== UUID); | ||
}, | ||
check: (UUID) => { | ||
if (UUID === undefined) return null; | ||
if (parsedBlacklist.some((p) => p.suspect === UUID)) return parsedBlacklist.find((p) => p.suspect === UUID).reason; | ||
if (dataStore.get("blacklists").some((l) => l.name === "Personal" && l.enabled === true) && personalBlacklist.some((p) => p.suspect === UUID)) return personalBlacklist.find((p) => p.suspect === UUID).reason; | ||
if (dataStore.get("blacklists").some((l) => l.name === "Global" && l.enabled === true) && globalBlacklist.some((p) => p.suspect === UUID)) return globalBlacklist.find((p) => p.suspect === UUID).reason; | ||
return null; | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.