-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheckJobs.js
More file actions
44 lines (37 loc) · 1.11 KB
/
Copy pathcheckJobs.js
File metadata and controls
44 lines (37 loc) · 1.11 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
38
39
40
41
42
43
44
const axios = require("axios");
const util = require("./util.js");
const config = require("./config.json");
async function main() {
const headers = {
Authorization: `Bearer ${config.v2token}`,
};
const { data } = await axios.get(
"https://www.v2ex.com/api/v2/nodes/jobs/topics",
{ headers }
);
const result = data.result
.map((item) => ({
title: item.title,
created: item.created,
url: item.url,
}))
.sort((a, b) => b.created - a.created);
const now = Date.now();
const topics = result.filter(
(item) => item.created * 1000 > now - 24 * 60 * 60 * 1000
);
const topicsRes = topics.map((item) => {
const created = new Date(item.created * 1000).toLocaleString("zh-CN");
return {
...item,
created,
};
});
const title = topicsRes.map((item) => item.title).join(";");
const msg = `24小时内话题${topicsRes.length}个,分别为${title}`;
console.log(topicsRes, { msg });
const alertTitle = "内容更新提示";
const semd = await util.sendMessage(alertTitle, msg);
return semd;
}
main().then((res) => console.log(res.data));