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