1 Star 0 Fork 0

yanghang/ursa

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
index.js 2.88 KB
一键复制 编辑 原始数据 按行查看 历史
yanghang 提交于 2024-02-27 10:57 . feat: 更新steam信息
'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
};
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/ock/ursa.git
git@gitee.com:ock/ursa.git
ock
ursa
ursa
master

搜索帮助