From 21428b5a407f9dea6f1353d43afb2ace440fc77a Mon Sep 17 00:00:00 2001 From: Hex Date: Wed, 19 Apr 2023 21:41:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=82=B9=E8=B5=9E=E5=92=8C?= =?UTF-8?q?=E6=94=B6=E8=97=8F=E4=BB=BB=E5=8A=A1BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- smzdm_task.js | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/smzdm_task.js b/smzdm_task.js index 93993b4..8ba679b 100644 --- a/smzdm_task.js +++ b/smzdm_task.js @@ -228,6 +228,18 @@ class SmzdmTaskBot extends SmzdmBot { article = this.getOneByRandom(articles); } + else if (task.task_redirect_url.link_val == '0' || !task.task_redirect_url.link_val) { + // 随机选一篇文章 + const articles = await this.getArticleList(20); + + if (articles.length < 1) { + return { + isSuccess: false + }; + } + + article = this.getOneByRandom(articles); + } else { $.log('尚未支持'); @@ -323,12 +335,20 @@ class SmzdmTaskBot extends SmzdmBot { articleId = article.article_id; channelId = article.article_channel_id; } - else if (task.task_redirect_url.link_val == '0') { - $.log('尚未支持'); + else if (task.task_redirect_url.link_val == '0' || !task.task_redirect_url.link_val) { + // 随机选一篇文章 + const articles = await this.getArticleList(20); - return { - isSuccess: false - }; + if (articles.length < 1) { + return { + isSuccess: false + }; + } + + const article = this.getOneByRandom(articles); + + articleId = article.article_id; + channelId = article.article_channel_id; } else { articleId = task.task_redirect_url.link_val; @@ -1037,7 +1057,7 @@ class SmzdmTaskBot extends SmzdmBot { } } - // 获取 Web 文章列表 + // 获取文章列表 async getArticleList(num = 1) { const { isSuccess, data, response } = await requestApi('https://article-api.smzdm.com/ranking_list/articles', { headers: this.getHeaders(),