diff options
author | Linnea Gräf <nea@nea.moe> | 2024-05-30 15:02:32 +0200 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2024-05-30 15:02:32 +0200 |
commit | 935b8f83764ae168994911d9b7b075f12a69a828 (patch) | |
tree | b29925ef862d28f5f83e3937a0b7ec48f39b5959 | |
parent | 204045fadad21ecbe4f646effdb8208f86bd3d5d (diff) | |
download | mycelium-warning-1.2.0.tar.gz mycelium-warning-1.2.0.tar.bz2 mycelium-warning-1.2.0.zip |
Add more users1.2.0
-rw-r--r-- | app.js | 37 | ||||
-rw-r--r-- | mycelium-warning.xml | 13 |
2 files changed, 34 insertions, 16 deletions
@@ -1,15 +1,18 @@ -const HYPIXEL_API_KEY =process.env.HYPIXEL_API_KEY; -const DISCORD_WEBHOOK_URL =process.env.DISCORD_WEBHOOK_URL; +const HYPIXEL_API_KEY = process.env.HYPIXEL_API_KEY; +const DISCORD_WEBHOOK_URL = process.env.DISCORD_WEBHOOK_URL; const CHECK_INTERVAL = parseInt(process.env.CHECK_INTERVAL); // 10 minutes const WARN_AFTER = 60 * 60 * 9; // 9 hours -const profiles = [ - { - profile: "Tomato", - playerId: "4154a5602654493094d3497d2ad6849f", - ping: "281489313840103426", - }, -]; +const profiles = []; + +for (let i = 0; true; i++) { + if (!process.env["PROFILE" + i]) break; + profiles.push({ + profile: process.env["PROFILE" + i], + playerId: process.env["PLAYER" + i], + ping: process.env["DISCORD" + i], + }); +} function getProfile(p) { return fetch( @@ -21,7 +24,7 @@ function getProfile(p) { ); } function warn(userid) { - return fetch(DISCORD_WEBHOOK_URL+"?wait=true", { + return fetch(DISCORD_WEBHOOK_URL + "?wait=true", { headers: { "content-type": "application/json", }, @@ -46,10 +49,10 @@ async function checkCollections() { for (i in profiles) { const p = profiles[i]; const data = await getProfile(p); - console.log(data) + console.log(data); let collectionTotal = 0; for (memberid in data.members) { - const member = data.members[memberid] + const member = data.members[memberid]; const collectionOne = member.collection?.MYCEL; if (collectionOne) collectionTotal += collectionOne; } @@ -58,12 +61,14 @@ async function checkCollections() { lastCollection[i] = collectionTotal; lastCollectionGain[i] = Date.now(); } - console.log("last: "+last) - console.log("current: "+collectionTotal) + console.log("last: " + last); + console.log("current: " + collectionTotal); if (Date.now() - lastCollectionGain[i] > WARN_AFTER * 1000) { - warn(p.ping).then(it => it.json()).then(console.log, console.error); + warn(p.ping) + .then((it) => it.json()) + .then(console.log, console.error); } } } setInterval(checkCollections, CHECK_INTERVAL * 1000); -checkCollections() +checkCollections(); diff --git a/mycelium-warning.xml b/mycelium-warning.xml index 936c5f7..d715f9a 100644 --- a/mycelium-warning.xml +++ b/mycelium-warning.xml @@ -20,4 +20,17 @@ <Config Name="Discord WebHook URL" Target="DISCORD_WEBHOOK_URL" Default="" Mode="" Description="Where to send your pings too. Must be a webhook." Type="Variable" Display="always" Required="true" Mask="true"/> <Config Name="Check Interval" Target="CHECK_INTERVAL" Default="600" Mode="" Description="How often to query the Hypixel API" Type="Variable" Display="always" Required="false" Mask="false"/> + + + <Config Name="Minecraft UUID 1" Target="PLAYER0" Default="" Mode="" Description="The UUID of the first player you want to check for" Type="Variable" Display="always" Required="false" Mask="false"/> + <Config Name="Profile Cutename 1" Target="PROFILE0" Default="" Mode="" Description="The profile cute name (fruit) of the first player you want to check for" Type="Variable" Display="always" Required="false" Mask="false"/> + <Config Name="Discord iD 1" Target="DISCORD0" Default="" Mode="" Description="The discord id to ping once the mycelium levels are too high" Type="Variable" Display="always" Required="false" Mask="false"/> + + <Config Name="Minecraft UUID 2" Target="PLAYER1" Default="" Mode="" Description="The UUID of the first player you want to check for" Type="Variable" Display="always" Required="false" Mask="false"/> + <Config Name="Profile Cutename 2" Target="PROFILE1" Default="" Mode="" Description="The profile cute name (fruit) of the first player you want to check for" Type="Variable" Display="always" Required="false" Mask="false"/> + <Config Name="Discord iD 2" Target="DISCORD1" Default="" Mode="" Description="The discord id to ping once the mycelium levels are too high" Type="Variable" Display="always" Required="false" Mask="false"/> + + <Config Name="Minecraft UUID 3" Target="PLAYER2" Default="" Mode="" Description="The UUID of the first player you want to check for" Type="Variable" Display="always" Required="false" Mask="false"/> + <Config Name="Profile Cutename 3" Target="PROFILE2" Default="" Mode="" Description="The profile cute name (fruit) of the first player you want to check for" Type="Variable" Display="always" Required="false" Mask="false"/> + <Config Name="Discord iD 3" Target="DISCORD2" Default="" Mode="" Description="The discord id to ping once the mycelium levels are too high" Type="Variable" Display="always" Required="false" Mask="false"/> </Container> |