1 Star 0 Fork 0

yanghang/ursa

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

搜索帮助