代码拉取完成,页面将自动刷新
'use strict';
const superagent = require("superagent");
require('dotenv').config();
const { HOOKS, STORE_URL } = process.env;
exports.main_handler = async (event, context) => {
const res = await new Promise((resolve,reject)=>{
superagent.get(STORE_URL).query().then((res)=>{
resolve(res.text)
}).catch((err)=>{
console.log(err)
})
})
let jsonRes = {};
let resData = [];
try {
jsonRes = JSON.parse(res);
resData = jsonRes.data;
} catch (error) {
}
try {
let markdownMsg = '';
let msgSteamContent = '';
let msgSwitchContent = '';
let msgEpicContent = '';
let steamData = resData.filter((item)=>item.store === 'steam')[0].data;
let switchData = resData.filter((item)=>item.store === 'switch')[0].data;
let resEpicData = resData.filter((item)=>item.store === 'epic')[0].data;
JSON.parse(steamData).steamData.slice(0,10).map((item)=>{
msgSteamContent = `${ msgSteamContent } ><font color=\"Black\"> ${item.title} </font> 当前:<font color=\"Red\">${item.deals}</font> 折扣:<font color=\"Brown\">${item.steamtgl}</font>\n`
})
JSON.parse(switchData).switchData.slice(0,6).map((item)=>{
msgSwitchContent = `${msgSwitchContent} ><font color=\"Black\"> ${item.title} </font> 发售日期: <font color=\"Black\"> ${item.released} </font> 特价:<font color=\"Brown\">${item.specialPrice}</font> 原价:<font color=\"comment\">${item.oldPrice}</font>\n`
})
JSON.parse(resEpicData).forEach(element => {
msgEpicContent = `${msgEpicContent} ><font color=\"Black\"> ${element.title} </font> 特价:<font color=\"Brown\"> ${element.fmtPrice.intermediatePrice} </font> 原价:<font color=\"comment\"> ${element.fmtPrice.originalPrice} </font>\n`
});
let tkeUrl = `[【Powered by TKEx 任务平台】](https://kubernetes.woa.com/v4/overview)`
markdownMsg = {
"msgtype": "markdown",
"markdown": {
"content": `今日Steam史低\n${msgSteamContent}\n\n今日Switch港服折扣\n${msgSwitchContent}\n\n本周Epic促销\n${msgEpicContent}\n\n-${tkeUrl}`
}
}
await new Promise((resolve,reject)=>{
superagent.post(HOOKS).send(markdownMsg).then((res)=>{
console.log(res.text)
resolve(0)
}).catch((err)=>{
console.log(err)
})
})
} catch (error) {
}
console.log(event)
console.log(event["non-exist"])
console.log(context)
return event
};
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。