V3
This commit is contained in:
parent
9341181f99
commit
236ca371bb
39 changed files with 659 additions and 1531 deletions
26
src/libs/quotaReset.ts
Normal file
26
src/libs/quotaReset.ts
Normal file
|
@ -0,0 +1,26 @@
|
|||
import * as fs from "fs";
|
||||
import { connectToDb, resetQuota } from "./mysql";
|
||||
|
||||
function getLastResetDate(): number {
|
||||
const data: string = fs.readFileSync("../data/lastreset.txt", "utf8");
|
||||
return parseInt(data);
|
||||
}
|
||||
|
||||
export async function checkReset() {
|
||||
const lastResetDate = getLastResetDate();
|
||||
const now = Date.now() / 1000;
|
||||
|
||||
if (now - lastResetDate > 1000 * 60 * 60 * 24 * 30) {
|
||||
fs.writeFileSync("../data/lastreset.txt", now.toString());
|
||||
|
||||
const connection = await connectToDb();
|
||||
|
||||
await resetQuota(connection);
|
||||
|
||||
connection.end();
|
||||
|
||||
return;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue