diff --git a/app.js b/app.js index d57e05d..5c2723c 100644 --- a/app.js +++ b/app.js @@ -10,7 +10,7 @@ require("dotenv") // 引入一个个路由模块 const danmakuRouter = require("./routes/danmaku"); -const ipinfoRouter = require("./routes/ipinfo"); +// const ipinfoRouter = require("./routes/ipinfo"); const airportsubRouter = require("./routes/airportsub"); const imgRouter = require("./routes/img"); // const schedule = require("./schedule/schedule"); @@ -38,7 +38,7 @@ app.use("/upload", express.static(__dirname + "/upload")); // 加载路由 app.use("/", danmakuRouter); -app.use("/ipinfo", ipinfoRouter); +// app.use("/ipinfo", ipinfoRouter); app.use("/sub", airportsubRouter); app.use("/img", imgRouter); diff --git a/schedule/cf2dns.js b/schedule/cf2dns.js deleted file mode 100644 index f2c5348..0000000 --- a/schedule/cf2dns.js +++ /dev/null @@ -1,60 +0,0 @@ -const axios = require("axios"); -const dnspod = require("../utils/dnspod"); - -const KEY = "o1zrmHAF"; -const DOMAINS = { - "home999.cc": { - "gd": { - "移动": "CM", - "联通": "CU", - "电信": "CT", - "境内": "CT", - }, - } -}; - -async function get_optimization_ip() { - const res = await axios.post("https://api.hostmonit.com/get_optimization_ip", { "key": KEY , "type": "v4" }); - return res.data; -} - -//TODO 改进result输出,显示所选线路信息 -async function main() { - const cfips = await get_optimization_ip(); - if (cfips.code !== 200) { - console.log("GET CLOUDFLARE IP ERROR: ----Time: " + new Date().toLocaleString()); - return; - } - for (const domain in DOMAINS) { - const sub_domains = DOMAINS[domain]; - for (const sub_domain in sub_domains) { - console.log(sub_domain,domain, "删除非默认线路的记录"); - const records = await dnspod.get_record(domain, sub_domain); - for (const record of records) { - if (record.line !== "默认") { - const res = await dnspod.del_record(domain, record); - if (res.status.code!=="1") - return "fail!"+res.status.message; - // console.log(record); - } - } - console.log(sub_domain,domain, "添加非默认线路的记录"); - const record = JSON.parse(JSON.stringify(records[0])); - for (const line in sub_domains[sub_domain]) { - for (let i=0;i<2;i++) { - const ISP = sub_domains[sub_domain][line]; - record.line = line; - record.type = "A"; - record.value = cfips["info"][ISP][i].ip; - const res = await dnspod.add_record(domain, record); - if (res.status.code!=="1") - return "fail!"+res.status.message; - console.log(cfips["info"][ISP][i]); - } - } - } - } - return "success!"; -} - -module.exports = main; diff --git a/schedule/covidbook.js b/schedule/covidbook.js deleted file mode 100644 index fe8f78b..0000000 --- a/schedule/covidbook.js +++ /dev/null @@ -1,120 +0,0 @@ -const axios = require("axios"); -const tgbot = require("../tgbot/tgbot.js"); - -const rootPath = "https://eservice.ssm.gov.mo/covidvacbook/"; -const chatID = [619935997, 5646988443]; -const IDTYPES = ["J", "f", "M", "h", "O", "n"]; - -console.log("covidbook.js loaded"); - -function sendMessage(msg) { - const bot = tgbot.hkaliyun; - chatID.forEach(id => { - bot.sendMessage(id, msg); - }); -} - -async function GetLocationQuotaList() { - const url = rootPath + "Booking/GetLocationQuotaList"; - const res = await axios.post(url, {}); - const data = res.data; - const mrnalocationquotalist = data.filter(locationquota => (locationquota.rspsrv === "HC6" || locationquota.rspsrv === "HC8" || locationquota.rspsrv === "CHCSJ(MRNA)" || locationquota.rspsrv === "CHCSJ2(MRNA)" || locationquota.rspsrv === "SSM1(MRNA)")); - const ivlocationquotalist = data.filter(locationquota => (locationquota.rspsrv === "HC1" || locationquota.rspsrv === "HC2" || locationquota.rspsrv === "HC3" || locationquota.rspsrv === "HC4" || locationquota.rspsrv === "HC5" || locationquota.rspsrv === "HC7" || locationquota.rspsrv === "HC9" || locationquota.rspsrv === "HC11" || locationquota.rspsrv === "CHCSJ" || locationquota.rspsrv === "CHCSJ2" || locationquota.rspsrv === "KW1" || locationquota.rspsrv === "SSM1" || locationquota.rspsrv === "MUST1" || locationquota.rspsrv === "FAOM1" || locationquota.rspsrv === "FAOM2" || locationquota.rspsrv === "SSM2")); - return { - ivlocationquotalist, - mrnalocationquotalist - }; -} - -async function GetLocationPeriodByIdtype(idtype) { - const url = rootPath + "Booking/GetLocationPeriodByIdtype"; - var data = { idtype: idtype }; - const res = await axios.post(url, data); - return { periodlist: res.data }; -} - -async function getlocationbyidtype(idtype) { - var data = { idtype: idtype }; - var url = rootPath + "Booking/GetLocationByIdtype"; - const res = await axios.post(url, data); - return { location: res.data }; -} - -async function GetBookDate(idtype) { - var url = rootPath + "Booking/GetBookDate"; - var checkquota = false; - - let date = new Date(); - let year = date.getFullYear(); - let month = (date.getMonth() + 1).toString() - .padStart(2, "0"); - let day = date.getDate() - .toString() - .padStart(2, "0"); - var time2 = `${year}${month}${day}`; - - var data = { - idtype: idtype, - afterdate: time2, - checkquota: checkquota - }; - const res = await axios.post(url, data); - return { bookdatelist: res.data }; -} - -async function GetlocationList() { - var url = rootPath + "Booking/GetlocationList"; - const res = await axios.post(url, {}); -} - -async function main() { - const { - ivlocationquotalist, - mrnalocationquotalist - } = await GetLocationQuotaList(); - const quotalist = mrnalocationquotalist; - - console.log("covidbook query"); - //筛选出可预约的日期 - for (const idtype of IDTYPES) { - const { bookdatelist } = await GetBookDate(idtype); - const { location } = await getlocationbyidtype(idtype); - const name = location[0].name_c; - if (bookdatelist.length != 0) { - sendMessage(name + "\n" + bookdatelist.join("\n")); - } - } - - // // 筛选出当日有余量的接种站 - // const quotalistfilter = quotalist.filter(x => x.sum != '0') - // if (quotalistfilter.length != 0) { - // console.log('有余量'); - // const time2 = new Date().toLocaleTimeString(); - // bot.sendMessage(chatID, `当前时间:${time2},以下是有余量的接种站:`); - // for (const l of quotalistfilter) { - // bot.sendMessage(chatID, `${l.name_c} : ${l.sum}`); - // } - // } else console.log('无余量'); - - // 遍历每个接种站尚有余额之时段 - // for (const item of quotalist) { - // const { location } = await getlocationbyidtype(item.idtype) - // const { periodlist } = await GetLocationPeriodByIdtype(item.idtype) - // if (periodlist.length != 0) { - // const name = location[0].name_c; - // const periodlisttext = periodlist.map(l => `${l.booktime} 餘額 : ${l.ava_quota}`) - // bot.sendMessage(chatID, name + '\n' + periodlisttext.join('\n')); - // } - // } - -} - -module.exports = main; - -if (!module.parent) { - // 引入环境变量 - require("dotenv") - .config("../.env"); - main(); - sendMessage("测试"); -} diff --git a/schedule/schedule.js b/schedule/schedule.js deleted file mode 100644 index a8aea5b..0000000 --- a/schedule/schedule.js +++ /dev/null @@ -1,38 +0,0 @@ -const cron = require("node-cron"); -const leancloud = require("../utils/leancloud"); -const chai = require("chai"); -const chaiHttp = require("chai-http"); -const cf2dns = require("./cf2dns"); - -function subcache(app) { - console.log("Running Cron Job:subcache"); - chai.use(chaiHttp); - chai.request(app) - .get("/sub/cache") - .end((err, res) => { - leancloud.add("Schedule", { - name: "subcache", - result: res.text - }); - console.log(res.text); - }); -} - -module.exports = (app) => { - //TODO 添加自动删除一个月前的日志 - console.log("schedule.js loaded"); - // 自动刷新订阅 - // cron.schedule("0 */8 * * *", () => { - // subcache(app); - // }); - // Cloudflare优选IP - // cron.schedule("*/15 * * * *", () => { - // cf2dns().then((result)=>{ - // leancloud.add("Schedule", { - // name: "cf2dns", - // result - // }); - // }); - // }); -}; -