This repository was archived by the owner on May 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathcron.js
More file actions
37 lines (36 loc) · 1.25 KB
/
cron.js
File metadata and controls
37 lines (36 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import Cron from "https://cdn.jsdelivr.net/gh/hexagon/croner@4/src/croner.js";
import { b2s, s2h, echo } from "https://raw.githubusercontent.com/txthinking/denolib/master/f.js";
export default function () {
Cron("0 0 0 1 * *", async () => {
try {
await db.execute("update user set transfer=0");
} catch (e) {
echo(e);
}
});
Cron("0 0 0 * * *", async () => {
try {
var uv = await db.query("select * from user_vip where expiration>0 and expiration<=?", [parseInt(Date.now() / 1000)]);
for (var i = 0; i < uv.length; i++) {
await db.u("user_vip", { id: uv[i].id, expiration: 0 });
await db.c("task", { name: 'expiration', user_id: uv[i].user_id, data: JSON.stringify({user_id: uv[i].user_id}) });
}
} catch (e) {
echo(e);
}
});
Cron("0 0 * * * *", async () => {
try {
await db.c("task", { name: 'transfer', user_id: 0, data: '' });
} catch (e) {
echo(e);
}
});
Cron("0 0 * * * *", async () => {
try {
await db.c("task", { name: 'unmanaged_transfer', user_id: 0, data: '' });
} catch (e) {
echo(e);
}
});
}