mirror of
https://github.com/hex-ci/smzdm_script.git
synced 2026-11-02 05:34:43 +08:00
修复点赞任务
This commit is contained in:
4
bot.js
4
bot.js
@@ -191,6 +191,10 @@ class SmzdmBot {
|
|||||||
Cookie: this.androidCookie
|
Cookie: this.androidCookie
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getOneByRandom(listing) {
|
||||||
|
return listing[Math.floor(Math.random() * listing.length)];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|||||||
@@ -214,12 +214,11 @@ class SmzdmTaskBot extends SmzdmBot {
|
|||||||
async doRatingTask(task) {
|
async doRatingTask(task) {
|
||||||
$.log(`开始任务: ${task.task_name}`);
|
$.log(`开始任务: ${task.task_name}`);
|
||||||
|
|
||||||
let articleId = '';
|
let article;
|
||||||
let channelId = '';
|
|
||||||
|
|
||||||
if (task.task_redirect_url.link_type === 'lanmu') {
|
if (task.task_redirect_url.link_type === 'lanmu') {
|
||||||
// 从栏目获取文章
|
// 从栏目获取文章
|
||||||
const articles = await this.getArticleListFromLanmu(task.task_redirect_url.link_val);
|
const articles = await this.getArticleListFromLanmu(task.task_redirect_url.link_val, 20);
|
||||||
|
|
||||||
if (articles.length < 1) {
|
if (articles.length < 1) {
|
||||||
return {
|
return {
|
||||||
@@ -227,8 +226,7 @@ class SmzdmTaskBot extends SmzdmBot {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
articleId = articles[0].article_id;
|
article = this.getOneByRandom(articles);
|
||||||
channelId = articles[0].article_channel_id;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$.log('尚未支持');
|
$.log('尚未支持');
|
||||||
@@ -241,32 +239,61 @@ class SmzdmTaskBot extends SmzdmBot {
|
|||||||
$.log('等候 3 秒');
|
$.log('等候 3 秒');
|
||||||
await $.wait(3000);
|
await $.wait(3000);
|
||||||
|
|
||||||
await this.rating({
|
if (article.article_price) {
|
||||||
method: 'worth_cancel',
|
// 点值
|
||||||
type: 3,
|
await this.rating({
|
||||||
id: articleId,
|
method: 'worth_cancel',
|
||||||
channelId
|
type: 3,
|
||||||
});
|
id: article.article_id,
|
||||||
|
channelId: article.article_channel_id
|
||||||
|
});
|
||||||
|
|
||||||
$.log('等候 3 秒');
|
$.log('等候 3 秒');
|
||||||
await $.wait(3000);
|
await $.wait(3000);
|
||||||
|
|
||||||
await this.rating({
|
await this.rating({
|
||||||
method: 'worth_create',
|
method: 'worth_create',
|
||||||
type: 1,
|
type: 1,
|
||||||
id: articleId,
|
id: article.article_id,
|
||||||
channelId
|
channelId: article.article_channel_id
|
||||||
});
|
});
|
||||||
|
|
||||||
$.log('等候 3 秒');
|
$.log('等候 3 秒');
|
||||||
await $.wait(3000);
|
await $.wait(3000);
|
||||||
|
|
||||||
await this.rating({
|
await this.rating({
|
||||||
method: 'worth_cancel',
|
method: 'worth_cancel',
|
||||||
type: 3,
|
type: 3,
|
||||||
id: articleId,
|
id: article.article_id,
|
||||||
channelId
|
channelId: article.article_channel_id
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// 点赞
|
||||||
|
await this.rating({
|
||||||
|
method: 'like_cancel',
|
||||||
|
id: article.article_id,
|
||||||
|
channelId: article.article_channel_id
|
||||||
|
});
|
||||||
|
|
||||||
|
$.log('等候 3 秒');
|
||||||
|
await $.wait(3000);
|
||||||
|
|
||||||
|
await this.rating({
|
||||||
|
method: 'like_create',
|
||||||
|
id: article.article_id,
|
||||||
|
channelId: article.article_channel_id
|
||||||
|
});
|
||||||
|
|
||||||
|
$.log('等候 3 秒');
|
||||||
|
await $.wait(3000);
|
||||||
|
|
||||||
|
await this.rating({
|
||||||
|
method: 'like_cancel',
|
||||||
|
id: article.article_id,
|
||||||
|
channelId: article.article_channel_id
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
$.log('延迟 5 秒领取奖励');
|
$.log('延迟 5 秒领取奖励');
|
||||||
await $.wait(5000);
|
await $.wait(5000);
|
||||||
@@ -283,7 +310,7 @@ class SmzdmTaskBot extends SmzdmBot {
|
|||||||
|
|
||||||
if (task.task_redirect_url.link_type === 'lanmu') {
|
if (task.task_redirect_url.link_type === 'lanmu') {
|
||||||
// 从栏目获取文章
|
// 从栏目获取文章
|
||||||
const articles = await this.getArticleListFromLanmu(task.task_redirect_url.link_val);
|
const articles = await this.getArticleListFromLanmu(task.task_redirect_url.link_val, 20);
|
||||||
|
|
||||||
if (articles.length < 1) {
|
if (articles.length < 1) {
|
||||||
return {
|
return {
|
||||||
@@ -291,8 +318,10 @@ class SmzdmTaskBot extends SmzdmBot {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
articleId = articles[0].article_id;
|
const article = this.getOneByRandom(articles);
|
||||||
channelId = articles[0].article_channel_id;
|
|
||||||
|
articleId = article.article_id;
|
||||||
|
channelId = article.article_channel_id;
|
||||||
}
|
}
|
||||||
else if (task.task_redirect_url.link_val == '0') {
|
else if (task.task_redirect_url.link_val == '0') {
|
||||||
$.log('尚未支持');
|
$.log('尚未支持');
|
||||||
@@ -1338,9 +1367,9 @@ class SmzdmTaskBot extends SmzdmBot {
|
|||||||
cid: channelId,
|
cid: channelId,
|
||||||
is_detail: true
|
is_detail: true
|
||||||
},
|
},
|
||||||
sourceMode: '栏目页_热门好价',
|
sourceMode: '栏目页',
|
||||||
sourcePage: `Android/好价/P/${id}/`,
|
sourcePage: `Android//P/${id}/`,
|
||||||
upperLevel_url: '栏目页/攒机爱好者//'
|
upperLevel_url: '栏目页///'
|
||||||
}),
|
}),
|
||||||
token: this.token,
|
token: this.token,
|
||||||
id,
|
id,
|
||||||
|
|||||||
Reference in New Issue
Block a user