mirror of
https://github.com/cassoule/flopobot_v2.git
synced 2026-01-18 16:37:40 +01:00
new skin fetch text + fetch everyday at 7am
This commit is contained in:
14
index.js
14
index.js
@@ -141,6 +141,7 @@ async function getAkhys() {
|
||||
})
|
||||
|
||||
let newSkinCount = 0;
|
||||
let newSkinText = '';
|
||||
for (const skin of skins) {
|
||||
try {
|
||||
if (skin.contentTierUuid !== null) {
|
||||
@@ -261,12 +262,14 @@ async function getAkhys() {
|
||||
maxPrice: maxPrice(skinBasePrice),
|
||||
});
|
||||
newSkinCount++;
|
||||
newSkinText += skin.displayName + ' | ';
|
||||
}
|
||||
} catch (e) {
|
||||
//
|
||||
}
|
||||
}
|
||||
console.log(`New skins : ${newSkinCount}`);
|
||||
if (newSkinCount <= 30) console.log(`New skins : ${newSkinCount}`);
|
||||
} catch (e) {
|
||||
console.error('Error while fetching skins:', e);
|
||||
}
|
||||
@@ -518,8 +521,8 @@ client.once('ready', async () => {
|
||||
await getAkhys();
|
||||
console.log('Ready')
|
||||
|
||||
// every 5 minutes
|
||||
cron.schedule('*/5 * * * *', async () => {
|
||||
// every 10 minutes
|
||||
cron.schedule('*/10 * * * *', async () => {
|
||||
const FIVE_MINUTES = 5 * 60 * 1000;
|
||||
|
||||
// clean 5 minutes old inventories
|
||||
@@ -601,6 +604,13 @@ client.once('ready', async () => {
|
||||
console.error('Message hydratation:', err);
|
||||
}
|
||||
});
|
||||
|
||||
// users/skins dayly fetch at 7am
|
||||
cron.schedule('0 7 * * *', async() => {
|
||||
// fetch eventual new users/skins
|
||||
await getAkhys();
|
||||
console.log('Users and skins fetched')
|
||||
})
|
||||
});
|
||||
|
||||
/**
|
||||
|
||||
@@ -48,7 +48,7 @@ export const getUserInventory = flopoDB.prepare('SELECT * FROM skins WHERE user_
|
||||
export const getTopSkins = flopoDB.prepare('SELECT * FROM skins ORDER BY maxPrice DESC LIMIT 10');
|
||||
|
||||
export const insertManyUsers = flopoDB.transaction(async (users) => {
|
||||
for (const user of users) try { await insertUser.run(user) } catch (e) { console.log('user insert failed') }
|
||||
for (const user of users) try { await insertUser.run(user) } catch (e) { console.log('user insert failed (might already exists)') }
|
||||
});
|
||||
export const updateManyUsers = flopoDB.transaction(async (users) => {
|
||||
for (const user of users) try { await updateUser.run(user) } catch (e) { console.log('user update failed') }
|
||||
|
||||
Reference in New Issue
Block a user