添加云函数js文件获取途径的环境变量
This commit is contained in:
@@ -161,7 +161,7 @@ cron "8 0-23/3 * * *" script-path=https://gitee.com/lxk0301/jd_scripts/raw/maste
|
|||||||
cron "20 7 * * *" script-path=https://gitee.com/lxk0301/jd_scripts/raw/master/jd_super_box.js,tag=京东超级盒子
|
cron "20 7 * * *" script-path=https://gitee.com/lxk0301/jd_scripts/raw/master/jd_super_box.js,tag=京东超级盒子
|
||||||
|
|
||||||
# 东东超市
|
# 东东超市
|
||||||
cron "11 1-23/5 * * *" script-path=https://gitee.com/lxk0301/jd_scripts/raw/master/jd_superMarket.js,tag=东东超市
|
cron "11 * * * *" script-path=https://gitee.com/lxk0301/jd_scripts/raw/master/jd_superMarket.js,tag=东东超市
|
||||||
|
|
||||||
# 赚京豆
|
# 赚京豆
|
||||||
cron "10 7 * * *" script-path=https://gitee.com/lxk0301/jd_scripts/raw/master/jd_syj.js, tag=赚京豆
|
cron "10 7 * * *" script-path=https://gitee.com/lxk0301/jd_scripts/raw/master/jd_syj.js, tag=赚京豆
|
||||||
|
|||||||
@@ -48,7 +48,7 @@
|
|||||||
"16 22 * * * https://gitee.com/lxk0301/jd_scripts/raw/master/jd_small_home.js, tag=东东小窝, img-url=https://raw.githubusercontent.com/58xinian/icon/master/ddxw.png, enabled=true",
|
"16 22 * * * https://gitee.com/lxk0301/jd_scripts/raw/master/jd_small_home.js, tag=东东小窝, img-url=https://raw.githubusercontent.com/58xinian/icon/master/ddxw.png, enabled=true",
|
||||||
"8 0-23/3 * * * https://gitee.com/lxk0301/jd_scripts/raw/master/jd_speed.js, tag=京东天天加速, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jdjs.png, enabled=true",
|
"8 0-23/3 * * * https://gitee.com/lxk0301/jd_scripts/raw/master/jd_speed.js, tag=京东天天加速, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jdjs.png, enabled=true",
|
||||||
"20 7 * * * https://gitee.com/lxk0301/jd_scripts/raw/master/jd_super_box.js, tag=京东超级盒子, img-url=https://raw.githubusercontent.com/Orz-3/task/master/jd.png, enabled=true",
|
"20 7 * * * https://gitee.com/lxk0301/jd_scripts/raw/master/jd_super_box.js, tag=京东超级盒子, img-url=https://raw.githubusercontent.com/Orz-3/task/master/jd.png, enabled=true",
|
||||||
"11 1-23/5 * * * https://gitee.com/lxk0301/jd_scripts/raw/master/jd_superMarket.js, tag=东东超市, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jxc.png, enabled=true",
|
"11 * * * * https://gitee.com/lxk0301/jd_scripts/raw/master/jd_superMarket.js, tag=东东超市, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jxc.png, enabled=true",
|
||||||
"10 7 * * * https://gitee.com/lxk0301/jd_scripts/raw/master/jd_syj.js, tag=赚京豆, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jd_syj.png, enabled=true",
|
"10 7 * * * https://gitee.com/lxk0301/jd_scripts/raw/master/jd_syj.js, tag=赚京豆, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jd_syj.png, enabled=true",
|
||||||
"55 23 * * 6 https://gitee.com/lxk0301/jd_scripts/raw/master/jd_unbind.js, tag=注销京东会员卡, img-url= https://raw.githubusercontent.com/58xinian/icon/master/jd_unbind.png, enabled=true",
|
"55 23 * * 6 https://gitee.com/lxk0301/jd_scripts/raw/master/jd_unbind.js, tag=注销京东会员卡, img-url= https://raw.githubusercontent.com/58xinian/icon/master/jd_unbind.png, enabled=true",
|
||||||
"55 23 * * * https://gitee.com/lxk0301/jd_scripts/raw/master/jd_unsubscribe.js, tag=取关京东店铺商品, img-url=https://raw.githubusercontent.com/Orz-3/task/master/jd.png, enabled=true",
|
"55 23 * * * https://gitee.com/lxk0301/jd_scripts/raw/master/jd_unsubscribe.js, tag=取关京东店铺商品, img-url=https://raw.githubusercontent.com/Orz-3/task/master/jd.png, enabled=true",
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ crazyJoy任务 = type=cron,cronexp="10 7 * * *",wake-system=1,timeout=3600,scrip
|
|||||||
东东小窝 = type=cron,cronexp="16 22 * * *",wake-system=1,timeout=3600,script-path=https://gitee.com/lxk0301/jd_scripts/raw/master/jd_small_home.js
|
东东小窝 = type=cron,cronexp="16 22 * * *",wake-system=1,timeout=3600,script-path=https://gitee.com/lxk0301/jd_scripts/raw/master/jd_small_home.js
|
||||||
天天加速 = type=cron,cronexp="8 0-23/3 * * *",wake-system=1,timeout=3600,script-path=https://gitee.com/lxk0301/jd_scripts/raw/master/jd_speed.js
|
天天加速 = type=cron,cronexp="8 0-23/3 * * *",wake-system=1,timeout=3600,script-path=https://gitee.com/lxk0301/jd_scripts/raw/master/jd_speed.js
|
||||||
京东超级盒子 = type=cron,cronexp="20 7 * * *",wake-system=1,timeout=3600,script-path=https://gitee.com/lxk0301/jd_scripts/raw/master/jd_super_box.js
|
京东超级盒子 = type=cron,cronexp="20 7 * * *",wake-system=1,timeout=3600,script-path=https://gitee.com/lxk0301/jd_scripts/raw/master/jd_super_box.js
|
||||||
东东超市 = type=cron,cronexp="11 1-23/5 * * *",wake-system=1,timeout=3600,script-path=https://gitee.com/lxk0301/jd_scripts/raw/master/jd_superMarket.js
|
东东超市 = type=cron,cronexp="11 * * * *",wake-system=1,timeout=3600,script-path=https://gitee.com/lxk0301/jd_scripts/raw/master/jd_superMarket.js
|
||||||
赚京豆 = type=cron,cronexp="10 7 * * *",wake-system=1,timeout=3600,script-path=https://gitee.com/lxk0301/jd_scripts/raw/master/jd_syj.js
|
赚京豆 = type=cron,cronexp="10 7 * * *",wake-system=1,timeout=3600,script-path=https://gitee.com/lxk0301/jd_scripts/raw/master/jd_syj.js
|
||||||
注销京东会员卡 = type=cron,cronexp="55 23 * * 6",wake-system=1,timeout=3600,script-path=https://gitee.com/lxk0301/jd_scripts/raw/master/jd_unbind.js
|
注销京东会员卡 = type=cron,cronexp="55 23 * * 6",wake-system=1,timeout=3600,script-path=https://gitee.com/lxk0301/jd_scripts/raw/master/jd_unbind.js
|
||||||
取关京东店铺商品 = type=cron,cronexp="55 23 * * *",wake-system=1,timeout=3600,script-path=https://gitee.com/lxk0301/jd_scripts/raw/master/jd_unsubscribe.js
|
取关京东店铺商品 = type=cron,cronexp="55 23 * * *",wake-system=1,timeout=3600,script-path=https://gitee.com/lxk0301/jd_scripts/raw/master/jd_unsubscribe.js
|
||||||
|
|||||||
40
index.js
40
index.js
@@ -1,24 +1,38 @@
|
|||||||
//'use strict';
|
//'use strict';
|
||||||
exports.main_handler = async (event, context, callback) => {
|
exports.main_handler = async (event, context, callback) => {
|
||||||
try {
|
try {
|
||||||
|
const { SCF_SOURCE_TYPE, SCF_SOURCE_URL } = process.env
|
||||||
//如果想在一个定时触发器里面执行多个js文件需要在定时触发器的【附加信息】里面填写对应的名称,用 & 链接
|
//如果想在一个定时触发器里面执行多个js文件需要在定时触发器的【附加信息】里面填写对应的名称,用 & 链接
|
||||||
//例如我想一个定时触发器里执行jd_speed.js和jd_bean_change.js,在定时触发器的【附加信息】里面就填写 jd_speed&jd_bean_change
|
//例如我想一个定时触发器里执行jd_speed.js和jd_bean_change.js,在定时触发器的【附加信息】里面就填写 jd_speed&jd_bean_change
|
||||||
for (const v of event["Message"].split("&")) {
|
for (const v of event["Message"].split("&")) {
|
||||||
console.log(v);
|
console.log(v);
|
||||||
var request = require('request');
|
var request = require('request');
|
||||||
//1.执行自己上传的js文件
|
switch (SCF_SOURCE_TYPE) {
|
||||||
//delete require.cache[require.resolve('./'+v+'.js')];
|
case 'local':
|
||||||
//require('./'+v+'.js')
|
//1.执行自己上传的js文件
|
||||||
|
delete require.cache[require.resolve('./'+v+'.js')];
|
||||||
//2.执行国内gitee远端js文件如果部署,在国内节点,选择1或2的方式
|
require('./'+v+'.js')
|
||||||
//request('https://gitee.com/lxk0301/jd_scripts/raw/master/'+v+'.js', function (error, response, body) {
|
break;
|
||||||
// eval(response.body)
|
case 'git':
|
||||||
//})
|
//2.执行github远端的js文件(因github的raw类型的文件被墙,此方法云函数不推荐)
|
||||||
|
request(`https://raw.githubusercontent.com/LXK9301/jd_scripts/master/${v}.js`, function (error, response, body) {
|
||||||
//3.执行github远端的js文件(因github的raw类型的文件被墙,此方法云函数不推荐)
|
eval(response.body)
|
||||||
request('https://gitee.com/lxk0301/jd_scripts/raw/master/' + v + '.js', function (error, response, body) {
|
})
|
||||||
eval(response.body)
|
break;
|
||||||
})
|
case 'custom':
|
||||||
|
//3.执行自定义远端js文件网址
|
||||||
|
if (!SCF_SOURCE_URL) return console.log('自定义模式需要设置SCF_SOURCE_URL变量')
|
||||||
|
request(`${SCF_SOURCE_URL}${v}.js`, function (error, response, body) {
|
||||||
|
eval(response.body)
|
||||||
|
})
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
//4.执行国内gitee远端js文件如果部署,在国内节点,选择1或2的方式
|
||||||
|
request(`https://gitee.com/lxk0301/jd_scripts/raw/master/${v}.js`, function (error, response, body) {
|
||||||
|
eval(response.body)
|
||||||
|
})
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(e)
|
||||||
|
|||||||
@@ -178,10 +178,8 @@ function getQuestions() {
|
|||||||
hasFound = true
|
hasFound = true
|
||||||
} else {
|
} else {
|
||||||
console.log(`在脚本内置题库中 未找到答案,去线上题库寻找~`);
|
console.log(`在脚本内置题库中 未找到答案,去线上题库寻找~`);
|
||||||
await requireTk();
|
ques = await getQues(vo.questionId)
|
||||||
ques = $.tk.filter(qo => qo.questionId === vo.questionId);
|
if (ques) {
|
||||||
if (ques.length) {
|
|
||||||
ques = ques[0]
|
|
||||||
let ans = JSON.parse(ques.correct)
|
let ans = JSON.parse(ques.correct)
|
||||||
let opt = vo.options.filter(bo => bo.optionDesc === ans.optionDesc)
|
let opt = vo.options.filter(bo => bo.optionDesc === ans.optionDesc)
|
||||||
if (opt.length) {
|
if (opt.length) {
|
||||||
@@ -282,6 +280,30 @@ function submitQues(question) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getQues(questionId) {
|
||||||
|
return new Promise(resolve => {
|
||||||
|
$.get({
|
||||||
|
'url': `http://qa.turinglabs.net:8081/api/v1/question/${questionId}/`,
|
||||||
|
'headers': {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
}
|
||||||
|
}, (err, resp, data) => {
|
||||||
|
try {
|
||||||
|
data = JSON.parse(data)
|
||||||
|
if (data.status === 200) {
|
||||||
|
resolve(data.data)
|
||||||
|
} else {
|
||||||
|
resolve(null)
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e)
|
||||||
|
} finally {
|
||||||
|
resolve()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
function answer(body = {}) {
|
function answer(body = {}) {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
$.get(taskUrl('mcxhd_brandcity_answerQuestion', {"costTime": 1, ...body}), async (err, resp, data) => {
|
$.get(taskUrl('mcxhd_brandcity_answerQuestion', {"costTime": 1, ...body}), async (err, resp, data) => {
|
||||||
@@ -427,24 +449,6 @@ function TotalBean() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function requireTk() {
|
|
||||||
return new Promise(resolve => {
|
|
||||||
$.get({
|
|
||||||
url: `http://qn6l5d6wm.hn-bkt.clouddn.com/question.json?t=${new Date().getTime()}`,
|
|
||||||
headers: {
|
|
||||||
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4371.0 Safari/537.36'
|
|
||||||
}
|
|
||||||
}, (err, resp, data) => {
|
|
||||||
try {
|
|
||||||
$.tk = JSON.parse(data).RECORDS;
|
|
||||||
} catch (e) {
|
|
||||||
console.log(e)
|
|
||||||
} finally {
|
|
||||||
resolve()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function safeGet(data) {
|
function safeGet(data) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ function getHomeData(info=false) {
|
|||||||
$.secretp = null
|
$.secretp = null
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
console.log(`当前爆竹${$.userInfo.raiseInfo.remainScore}🧨,下一关需要${$.userInfo.raiseInfo.nextLevelScore}🧨`)
|
console.log(`当前爆竹${$.userInfo.raiseInfo.remainScore}🧨,下一关需要${$.userInfo.raiseInfo.nextLevelScore - $.userInfo.raiseInfo.curLevelStartScore}🧨`)
|
||||||
|
|
||||||
if(info) {
|
if(info) {
|
||||||
message += `当前爆竹${$.userInfo.raiseInfo.remainScore}🧨\n`
|
message += `当前爆竹${$.userInfo.raiseInfo.remainScore}🧨\n`
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ function getHomeData(info=false) {
|
|||||||
$.secretp = null
|
$.secretp = null
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
console.log(`当前爆竹${$.userInfo.raiseInfo.remainScore}🧨,下一关需要${$.userInfo.raiseInfo.nextLevelScore}🧨`)
|
console.log(`当前爆竹${$.userInfo.raiseInfo.remainScore}🧨,下一关需要${$.userInfo.raiseInfo.nextLevelScore - $.userInfo.raiseInfo.curLevelStartScore}🧨`)
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$.secretp = null
|
$.secretp = null
|
||||||
|
|||||||
@@ -40,12 +40,12 @@ inputs:
|
|||||||
cronExpression: "0 3 */1 * * * *"
|
cronExpression: "0 3 */1 * * * *"
|
||||||
enable: true
|
enable: true
|
||||||
argument: jd_joy_feedPets&jd_joy&jd_moneyTree&jd_plantBean&jd_dreamFactory&jd_jdfactory&jd_nianCollect
|
argument: jd_joy_feedPets&jd_joy&jd_moneyTree&jd_plantBean&jd_dreamFactory&jd_jdfactory&jd_nianCollect
|
||||||
- timer: #宠汪汪积分兑换奖品 #宠汪汪偷好友积分与狗 #点点券 #东东小窝 #京东直播18豆 #集鞭炮赢京豆
|
- timer: #宠汪汪积分兑换奖品 #宠汪汪偷好友积分与狗 #点点券 #东东小窝 #京东直播18豆
|
||||||
parameters:
|
parameters:
|
||||||
name: joyreward_joysteal_necklace_smallhome_live_firecrackers
|
name: joyreward_joysteal_necklace_smallhome_live
|
||||||
cronExpression: "0 0 0-16/8,20 * * * *"
|
cronExpression: "0 0 0-16/8,20 * * * *"
|
||||||
enable: true
|
enable: true
|
||||||
argument: jd_joy_reward&jd_joy_steal&jd_necklace&jd_small_home&jd_live&jd_firecrackers
|
argument: jd_joy_reward&jd_joy_steal&jd_necklace&jd_small_home&jd_live
|
||||||
- timer: #京东全民开红包 #进店领豆 #取关京东店铺商品 #注销京东会员卡 #京东抽奖机 #京东汽车 #京东秒秒币 #小鸽有礼
|
- timer: #京东全民开红包 #进店领豆 #取关京东店铺商品 #注销京东会员卡 #京东抽奖机 #京东汽车 #京东秒秒币 #小鸽有礼
|
||||||
parameters:
|
parameters:
|
||||||
name: redPacket_shop_unsubscribe_unbind_lotteryMachine_car_ms_xg
|
name: redPacket_shop_unsubscribe_unbind_lotteryMachine_car_ms_xg
|
||||||
|
|||||||
Reference in New Issue
Block a user