From 2dbb75800f73ff8f9b29ddaac3d5406ca6d39a98 Mon Sep 17 00:00:00 2001 From: AgFlore Date: Wed, 29 Jul 2020 02:40:29 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20Popi=20=E6=8F=90=E9=97=AE=E7=AE=B1=20(#?= =?UTF-8?q?5178)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/radar-rules.js | 15 ++++++++++++ docs/social-media.md | 6 +++++ lib/router.js | 3 +++ lib/routes/popiask/questions.js | 41 +++++++++++++++++++++++++++++++++ 4 files changed, 65 insertions(+) create mode 100644 lib/routes/popiask/questions.js diff --git a/assets/radar-rules.js b/assets/radar-rules.js index 4e03e3e5bf..a3fc338da3 100644 --- a/assets/radar-rules.js +++ b/assets/radar-rules.js @@ -2092,6 +2092,21 @@ }, ], }, + 'popiask.cn': { + _name: 'Popi 提问箱', + www: [ + { + title: '提问箱新回答', + docs: 'https://docs.rsshub.app/social-media.html#popi-ti-wen-xiang', + source: '/:id', + target: (params) => { + if (params.id) { + return '/popiask/:id'; + } + }, + }, + ], + }, 'nppa.gov.cn': { _name: '国家新闻出版署', www: [ diff --git a/docs/social-media.md b/docs/social-media.md index c783fd618e..5201c3cba8 100644 --- a/docs/social-media.md +++ b/docs/social-media.md @@ -386,6 +386,12 @@ Tiny Tiny RSS 会给所有 iframe 元素添加 `sandbox="allow-scripts"` 属性 ::: +## Popi 提问箱 + +### 提问箱新回答 + + + ## Soul ### 瞬间更新 diff --git a/lib/router.js b/lib/router.js index 69c1a12709..df2496eec1 100644 --- a/lib/router.js +++ b/lib/router.js @@ -2928,6 +2928,9 @@ router.get('/missevan/drama/:id', require('./routes/missevan/drama')); // Go语言爱好者周刊 router.get('/go-weekly', require('./routes/go-weekly')); +// popiask提问箱 +router.get('/popiask/:sharecode/:pagesize?', require('./routes/popiask/questions')); + // AMD router.get('/amd/graphicsdrivers/:id/:rid?', require('./routes/amd/graphicsdrivers')); diff --git a/lib/routes/popiask/questions.js b/lib/routes/popiask/questions.js new file mode 100644 index 0000000000..754c2daa96 --- /dev/null +++ b/lib/routes/popiask/questions.js @@ -0,0 +1,41 @@ +const got = require('@/utils/got'); + +module.exports = async (ctx) => { + const sharecode = ctx.params.sharecode; + const pagesize = ctx.params.pagesize || 20; + + const getUserInfo = await got({ + method: 'get', + url: `https://apiv3.popiask.cn/unuser/user/${sharecode}`, + headers: { + Referer: `https://www.popiask.cn/${sharecode}`, + }, + }); + + const nickname = getUserInfo.data.content.nickName; + const production = getUserInfo.data.content.production; + const description = getUserInfo.data.content.selfDescription; + + const getQuestionFromUser = await got({ + method: 'get', + url: `https://apiv3.popiask.cn/unuser/getQuestionFromUser/${sharecode}?pageSize=${pagesize}`, + headers: { + Referer: `https://www.popiask.cn/${sharecode}`, + }, + }); + + const data = getQuestionFromUser.data.content.data; + + ctx.state.data = { + title: `${nickname} 的 popiask 提问箱`, + link: `https://www.popiask.cn/${sharecode}`, + description: `${production} ${description}`, + item: data.map((item) => ({ + title: item.title, + description: `${item.title}
(${item.created_at})

答:
${item.answer.txt_content}
(${new Date(item.answer_at * 1000).toLocaleString()})`, + guid: item.answer_at, + pubDate: new Date(item.answer_at * 1000).toUTCString(), + link: `https://www.popiask.cn/answered.html?sharecode=${sharecode}&dynamicId=${item.visit_code}`, + })), + }; +};