Merge pull request #308 from fanhengkui/main

任务修复
This commit is contained in:
smallfawn authored and GitHub committed 2026-08-28 14:03:42 +08:00
commit bba41b42e4
2 files changed
+224 -50

No files matched your search

+181 -38
View File
@@ -34,12 +34,23 @@ class Task {
this.user = env.split(strSplitor);
this.token = this.user[0];
this.posts = []
this.goods = []
this.pageNum = 1
}
async run() {
await this.userInfo()
await this.signStatus();
await this.tasklist()
if (this.goods) {
$.log(`===========积分物品统计===========`)
for (let item of this.goods) {
$.log(`积分物品【${item.name}】,库存:${item.stock}`)
}
$.log(`===========积分物品统计===========`)
}
}
generateMd5Signature = function (e) {
@@ -82,6 +93,36 @@ class Task {
}
}
async signStatus() {
try {
let options = {
method: 'GET',
url: `https://api.xinc818.com/mini/sign/status`,
headers: {
"Content-Type": "application/json",
}
};
let { data: result } = await this.request(options);
if (result.code == 0) {
if (result.data) {
$.log(`✅账号[${this.index}] 签到状态【${result.data}】已签到🎉`)
} else {
$.log(`✅账号[${this.index}] 签到状态【${result.data}】未签到🎉`)
await $.wait(2000)
await this.signIn()
}
await $.wait(1000)
await this.signContinuous()
} else {
$.log(`❌账号[${this.index}] 签到状态查询失败`);
}
} catch (error) {
$.log(`❌账号[${this.index}] 签到状态查询异常:${error}`);
}
}
async signIn() {
let options = {
method: 'GET',
@@ -100,6 +141,28 @@ class Task {
}
}
async signContinuous() {
try {
let options = {
method: 'GET',
url: `https://api.xinc818.com/mini/sign/continuous`,
headers: {
"Content-Type": "application/json",
}
};
let { data: result } = await this.request(options);
if (result.code == 0) {
$.log(`✅账号[${this.index}] 连续签到【${result.data}】天🎉`)
}
} catch (e) {
$.log(`❌账号[${this.index}] 查询连续签到天数异常:${e}`);
}
}
async share() {
let options = {
method: 'GET',
@@ -126,11 +189,13 @@ class Task {
};
let { data: result } = await this.request(options);
if (result.code == 0) {
await this.getPosts()
await this.getGoods()
for (let task of result.data) {
await this.getPosts()
if (task.status == false) {
// console.log(`${task.taskName}[${task.code}]--${task.annotation} -- ${task.finishNum}`)
if (task.code == 'BROWSE_PRODUC1TS') {
console.log(`${task.taskName}[${task.code}]--${task.annotation} -- ${task.finishNum}`)
if (task.code == 'BROWSE_PRODUCTS') {
await this.browseGoods()
}
if (task.code == 'COMMENT_POSTS') {
@@ -140,10 +205,29 @@ class Task {
await this.likePosts(this.posts[0].id)
}
if (task.code == 'FOCUS_USER') {
await this.followUser(this.posts[0].publisherId)
let _posts = "";
while (true) {
_posts = this.posts.filter(item => item.concernSign == 1)
if (_posts) {
break
}
await $.wait(2000)
this.pageNum++;
if (this.pageNum > 100) {
}
await this.getPosts()
}
if (_posts) {
await this.followUser(_posts[0].publisherId)
} else {
}
}
if (task.code == 'WANT_GOODS') {
await this.likeGoods()
var good_id = this.goods[1].id;
await this.getGoodDetail(good_id)
await this.likeGoods(this.goodDetail.outerId)
}
if (task.code == 'SHARE') {
await this.share()
@@ -195,55 +279,103 @@ class Task {
async getPosts() {
let options = {
method: 'GET',
url: `https://api.xinc818.com/mini/community/home/posts?pageNum=1&pageSize=10&queryType=3&position=2`,
url: `https://api.xinc818.com/mini/community/home/posts?pageNum=${this.pageNum}&pageSize=100&queryType=3&position=2`,
headers: {}
};
let { data: result } = await this.request(options);
if (result.code == 0) {
this.posts = result.data.list
// console.log(this.posts)
}
}
async getGoods() {
let options = {
method: 'GET',
url: `https://cdn-api.xinc818.com/mini/integralGoods?miniIs=1&orderField=sort&orderScheme=DESC&pageSize=50&pageNum=1`,
headers: {}
};
let { data: result } = await this.request(options);
if (result.code == 0) {
this.goods = result.data.list
}
}
async getGoodDetail(id) {
let options = {
method: 'GET',
url: `https://api.xinc818.com/mini/integralGoods/${id}`,
headers: {}
};
let { data: result } = await this.request(options);
if (result.code == 0) {
//用户商品详情的outerId点赞商品
this.goodDetail = result.data
}
}
async likePosts() {
//找到posts里面liked为false的
let posts = this.posts.filter(item => item.liked == false)
let options = {
method: 'PUT',
url: `https://api.xinc818.com/mini/posts/like`,
headers: {
"Content-Type": "application/json",
},
data: { "postsId": posts[0].id, "decision": true }
try {
let posts = this.posts.filter(item => item.liked == false)
let options = {
method: 'PUT',
url: `https://api.xinc818.com/mini/posts/like`,
headers: {
"Content-Type": "application/json",
},
data: { "postsId": posts[0].id, "decision": true }
};
};
let { data: result } = await this.request(options);
if (result.code == 0) {
// console.log(result);
$.log(`✅账号[${this.index}] 【点赞帖子】成功 获得积分【${result.data.singleReward}】🎉`)
}else{
$.log(`❎账号[${this.index}] 【点赞帖子】失败,原因【${result.msg}】🎉`)
let { data: result } = await this.request(options);
if (result.code == 0) {
// console.log(result);
$.log(`✅账号[${this.index}] 【点赞帖子】成功 获得积分【${result.data.singleReward}】🎉`)
} else {
$.log(`❎账号[${this.index}] 【点赞帖子】失败,原因【${result.msg}】🎉`)
}
} catch (err) {
$.log(`❎账号[${this.index}] 【点赞帖子】失败:${err}`)
}
}
async followUser(publisherId) {
let options = {
method: 'PUT',
url: `https://api.xinc818.com/mini/user/follow`,
headers: {
"Content-Type": "application/json",
},
data: { "followUserId": publisherId, "decision": true }
async followUser(publisherId, decision = true) {
try {
let options = {
method: 'PUT',
url: `https://api.xinc818.com/mini/user/follow`,
headers: {
"Content-Type": "application/json",
},
data: { "followUserId": publisherId, "decision": decision }
};
let { data: result } = await this.request(options);
if (result.code == 0) {
$.log(`✅账号[${this.index}] 【关注用户】成功 获得积分【${result.data.singleReward}】🎉`)
}else{
$.log(`❎账号[${this.index}] 【关注用户】失败,原因【${result.msg}】🎉`)
};
let { data: result } = await this.request(options);
// console.log(result)
if (result.code == 0) {
if (decision) {
$.log(`✅账号[${this.index}] 【关注用户】成功 获得积分【${result.data.singleReward}】🎉`)
//await $.wait(3000)
//await this.followUser(publisherId, false)
} else {
$.log(`✅账号[${this.index}] 【取消关注用户】成功 `)
}
} else {
$.log(`❎账号[${this.index}] 【关注用户】失败,原因【${result.msg}】🎉`)
if (result.msg.match("重复")) {
//await this.followUser(publisherId, false)
}
}
} catch (err) {
$.log(`❎账号[${this.index}] 【关注用户】失败:${err}`)
}
}
async likeGoods(goodsId = "210000904376") {
async likeGoods(goodsId = "210000904376", isLike = true) {
try {
let options = {
method: 'POST',
@@ -251,12 +383,23 @@ class Task {
headers: {
"Content-Type": "application/json",
},
data: { "isLike": true, "dailyTaskId": 20, "productId": goodsId }
data: { "isLike": isLike, "dailyTaskId": 20, "productId": goodsId }
};
// console.log(options)
let { data: result } = await this.request(options);
// console.log(result)
if (result.code == 0) {
$.log(`✅账号[${this.index}] 【点赞商品】成功 获得积分【${result.data.singleReward}】🎉`)
if (isLike) {
$.log(`✅账号[${this.index}] 【点赞商品】成功 获得积分【${result.data.singleReward}】🎉`)
await $.wait(3000)
await this.likeGoods(goodsId, false)
} else {
$.log(`✅账号[${this.index}] 【点赞商品】取消成功🎉`)
}
} else {
$.log(`❎账号[${this.index}] 【点赞商品】失败,原因【${result.msg}】🎉`)
}
} catch (err) {
$.log(`❎账号[${this.index}] 【点赞商品】失败:${err}`)
+43 -12
View File
@@ -43,8 +43,9 @@ const USER_AGENT =
const EP_LOGIN = "/api/index/get_openid";
const EP_HOME = "/api/checkin/home";
const EP_PREPARE = "/api/checkin/prepare";
const EP_PREPARE = "/api/checkin/ad/prepare";
const EP_SIGN = "/api/checkin/sign";
const EP_AD_SIGN = "/api/checkin/ad/sign";
const wechat = new WeChatServer({
url: process.env.wx_server_url || "http://192.168.31.196:8787",
@@ -134,12 +135,8 @@ class Task {
if (Number(res?.errno) !== 0) throw new Error(`home失败: ${res?.errmsg || short(res)}`);
return res.data || {};
}
async prepareAndSign() {
const prepared = await this.request("POST", EP_PREPARE);
if (Number(prepared?.errno) !== 0) return this.log(`❌ 普通签到 prepare 失败: ${short(prepared)}`);
const adToken = String((prepared.data || {}).ad_token || "");
if (!adToken) return this.log("❌ 普通签到 prepare 未返回 ad_token");
const signed = await this.request("POST", EP_SIGN, { ad_token: adToken });
async sign() {
const signed = await this.request("POST", EP_SIGN, {});
if (Number(signed?.errno) === 0) {
const d = signed.data || {};
return this.log(`✅ 签到成功${d.score !== undefined ? `,获得 ${d.score} 积分` : ""}${d.integral !== undefined ? `,积分 ${d.integral}` : ""}`);
@@ -147,7 +144,24 @@ class Task {
if (/已签|签到过|重复|已完成/.test(String(signed?.errmsg || signed?.msg || ""))) return this.log(`✅ 今日已签到(${signed.errmsg || signed.msg})`);
this.log(`❌ 签到失败: ${signed?.errmsg || signed?.msg || short(signed)}`);
}
async sign() {
async prepareAndSign() {
const prepared = await this.request("POST", EP_PREPARE);
if (Number(prepared?.errno) !== 0) return this.log(`❌ 广告签到 prepare 失败: ${short(prepared)}`);
const adToken = String((prepared.data || {}).ad_token || "");
if (!adToken) return this.log("❌ 广告签到 prepare 未返回 ad_token");
await $.wait(10 * 1000)
const signed = await this.request("POST", EP_AD_SIGN, { ad_token: adToken });
if (Number(signed?.errno) === 0) {
const d = signed.data || {};
this.log(`✅ 广告签到成功${d.score !== undefined ? `,获得 ${d.score} 积分` : ""}${d.integral !== undefined ? `,积分 ${d.integral}` : ""}`);
await $.wait(30 * 1000)
await this.checkin_sign('ad');
return
}
if (/已签|签到过|重复|已完成/.test(String(signed?.errmsg || signed?.msg || ""))) return this.log(`✅ 今日已签到(${signed.errmsg || signed.msg})`);
this.log(`❌ 广告签到失败: ${signed?.errmsg || signed?.msg || short(signed)}`);
}
async checkin_sign(type) {
let home;
try {
home = await this.home();
@@ -158,9 +172,26 @@ class Task {
home = await this.home();
} else throw e;
}
if (!home.enabled) return this.log("普通签到未开启");
if (home.today_signed || !home.can_sign) return this.log("✅ 今日已签到或不可签");
await this.prepareAndSign();
if (type == 'ad') {
if (home.ad && home.ad.today_count < home.ad.daily_limit) {
await this.prepareAndSign();
} else {
this.log("✅ 今日广告签到已完成签到或不可签")
}
} else {
if (!home.enabled) return this.log("普通签到未开启");
if (home.today_signed || !home.can_sign) {
this.log("✅ 今日普通签到已签到或不可签")
} else {
await this.sign();
}
if (home.ad && home.ad.today_count < home.ad.daily_limit) {
await this.prepareAndSign();
} else {
this.log("✅ 今日广告签到已完成签到或不可签")
}
}
}
async ensureLogin() {
const cached = readCache()[this.account.openid] || {};
@@ -171,7 +202,7 @@ class Task {
if (!this.account.openid) { this.log("跳过:变量值里没有 openid"); return; }
try {
await this.ensureLogin();
await this.sign();
await this.checkin_sign();
} catch (e) {
this.log(`执行失败: ${e.message || e}`);
}