Skip to content

Commit 151eb8f

Browse files
author
Leaf
committed
添加领个股竞猜奖励
1 parent e7a827b commit 151eb8f

1 file changed

Lines changed: 72 additions & 9 deletions

File tree

‎txstock.js‎

Lines changed: 72 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
腾讯自选股APP & 微信微证券公众号
3-
改自@CenBoMin大佬的脚本
3+
44
只适配了IOS,测试了青龙和V2P,其他平台请自行测试,安卓请自行测试
55
多用户用#隔开
66
@@ -253,12 +253,15 @@ async function getRewrite()
253253
if($request.url.indexOf("openid=") > -1)
254254
{
255255
//APP包
256+
let msgStr = ''
256257
$.setdata($request.url,'TxStockAppUrl')
257258
$.log(`获取TxStockAppUrl成功: ${$request.url}\n`)
258-
$.msg(`获取TxStockAppUrl成功: ${$request.url}\n`)
259+
msgStr += `获取TxStockAppUrl成功: ${$request.url}\n`
259260
$.setdata(JSON.stringify($request.headers),'TxStockAppHeader')
260261
$.log(`获取TxStockAppHeader成功: ${JSON.stringify($request.headers)}\n`)
261-
$.msg(`获取TxStockAppHeader成功: ${JSON.stringify($request.headers)}\n`)
262+
msgStr += `获取TxStockAppHeader成功: ${JSON.stringify($request.headers)}\n`
263+
264+
$.msg(msgStr)
262265
}
263266
else
264267
{
@@ -1989,7 +1992,7 @@ async function appGuessStatus() {
19891992
rndtime = Math.round(curTime.getTime())
19901993
currentHour = curTime.getHours()
19911994
currentDay = curTime.getDay()
1992-
let isGuessTime = ((currentHour < 13) && (currentHour > 9) && (currentDay < 6)) ? 1 : 0
1995+
let isGuessTime = ((currentHour < 13) && (currentHour > 9) && (currentDay < 6) && (currentDay > 0)) ? 1 : 0
19931996
return new Promise((resolve) => {
19941997
let url = {
19951998
url: `https://zqact.tenpay.com/cgi-bin/guess_home.fcgi?channel=1&source=2&new_version=3&_=${rndtime}&openid=${app_openid}&fskey=${app_fskey}&access_token=${app_token}&_appName=${app_appName}&_appver=${app_appver}&_osVer=${app_osVer}&_devId=${app_devId}`,
@@ -2019,10 +2022,20 @@ async function appGuessStatus() {
20192022
if(result.notice_info && result.notice_info[0]) {
20202023
if(logDebug) console.log(result)
20212024
if(result.notice_info[0].answer_status == 1) {
2022-
$.log(`上期猜涨跌回答正确,正在取得奖励\n`);
2025+
$.log(`上期猜上证指数涨跌回答正确,正在取得奖励\n`);
20232026
await appGuessAward(result.notice_info[0].date)
20242027
} else {
2025-
$.log(`上期猜涨跌回答错误\n`);
2028+
$.log(`上期猜上证指数涨跌回答错误\n`);
2029+
}
2030+
await $.wait(1000)
2031+
}
2032+
if(result.stock_notice_info && result.stock_notice_info[0]) {
2033+
if(logDebug) console.log(result)
2034+
if(result.stock_notice_info[0].guess_correct == 1) {
2035+
$.log(`上期猜个股涨跌回答正确,正在取得奖励\n`);
2036+
await appGuessStockAward(result.stock_notice_info[0].date)
2037+
} else {
2038+
$.log(`上期猜个股涨跌回答错误\n`);
20262039
}
20272040
await $.wait(1000)
20282041
}
@@ -2142,7 +2155,7 @@ async function appGetStockInfo(scode,markets) {
21422155
});
21432156
}
21442157

2145-
//猜涨跌奖励
2158+
//猜上证指数涨跌奖励
21462159
async function appGuessAward(guessDate) {
21472160
rndtime = Math.round(curTime.getTime())
21482161
return new Promise((resolve) => {
@@ -2170,9 +2183,59 @@ async function appGuessAward(guessDate) {
21702183
let result = JSON.parse(data);
21712184
if(logDebug) console.log(result)
21722185
if(result.retcode == 0) {
2173-
$.log(`获得猜涨跌奖励:${result.reward_memo} ${result.reward_value}金币\n`);
2186+
$.log(`获得上证指数猜涨跌奖励:${result.reward_memo} ${result.reward_value}金币\n`);
2187+
} else {
2188+
$.log(`获得上证指数猜涨跌奖励失败:${result.retmsg}\n`);
2189+
}
2190+
}
2191+
}
2192+
} catch (e) {
2193+
$.logErr(e, resp);
2194+
} finally {
2195+
resolve();
2196+
}
2197+
});
2198+
});
2199+
}
2200+
2201+
//猜个股涨跌奖励
2202+
async function appGuessStockAward(guessDate) {
2203+
rndtime = Math.round(curTime.getTime())
2204+
return new Promise((resolve) => {
2205+
let url = {
2206+
url: `https://zqact.tenpay.com/cgi-bin/activity/activity.fcgi?activity=guess_new&action=guess_stock_reward&guess_date=${guessDate}&channel=1&_=${rndtime}&openid=${app_openid}&fskey=${app_fskey}&access_token=${app_token}&_appName=${app_appName}&_appver=${app_appver}&_osVer=${app_osVer}&_devId=${app_devId}`,
2207+
headers: {
2208+
'Cookie': app_ck,
2209+
'Accept': `application/json, text/plain, */*`,
2210+
'Connection': `keep-alive`,
2211+
'Referer': `https://zqact.tenpay.com/activity/page/guessRiseFall/`,
2212+
'Accept-Encoding': `gzip, deflate, br`,
2213+
'Host': `zqact.tenpay.com`,
2214+
'User-Agent': app_UA,
2215+
'Accept-Language': `zh-cn`
2216+
},
2217+
};
2218+
$.get(url, async (err, resp, data) => {
2219+
try {
2220+
if (err) {
2221+
console.log("腾讯自选股: API查询请求失败 ‼️‼️");
2222+
console.log(JSON.stringify(err));
2223+
$.logErr(err);
2224+
} else {
2225+
if (safeGet(data)) {
2226+
let result = JSON.parse(data);
2227+
if(logDebug) console.log(result)
2228+
if(result.retcode == 0) {
2229+
if(result.stock_rewards && Array.isArray(result.stock_rewards)) {
2230+
for(let i=0; i<result.stock_rewards.length; i++) {
2231+
let rewardItem = result.stock_rewards[i]
2232+
console.log(rewardItem)
2233+
$.log(`猜中${rewardItem.stock_name}涨跌获得:${rewardItem.reward_desc}\n`);
2234+
}
2235+
}
2236+
$.log(`总奖励:${result.stock_reward_desc}\n`);
21742237
} else {
2175-
$.log(`获得猜涨跌奖励失败:${result.retmsg}\n`);
2238+
$.log(`获得个股猜涨跌奖励失败:${result.retmsg}\n`);
21762239
}
21772240
}
21782241
}

0 commit comments

Comments
 (0)