feat: Popi 提问箱 (#5178)

This commit is contained in:
AgFlore
2020-07-28 19:40:29 +01:00
committed by GitHub
parent 5877ccf8af
commit 2dbb75800f
4 changed files with 65 additions and 0 deletions
+15
View File
@@ -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: [
+6
View File
@@ -386,6 +386,12 @@ Tiny Tiny RSS 会给所有 iframe 元素添加 `sandbox="allow-scripts"` 属性
:::
</Route>
## Popi 提问箱
### 提问箱新回答
<Route author="AgFlore" example="/popiask/popi6666" path="/popiask/:sharecode/:pagesize?" :paramsDesc="['提问箱 ID', '查看条数(默认为 20']" radar="1"/>
## Soul
### 瞬间更新
+3
View File
@@ -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'));
+41
View File
@@ -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}<br>(${item.created_at})<br><br><b>答:</b><br>${item.answer.txt_content}<br>(${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}`,
})),
};
};