From f79b0252f7b3d1fcf5fe59c31544bc25effe940e Mon Sep 17 00:00:00 2001 From: AgFlore Date: Mon, 30 Nov 2020 02:54:46 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20Tapechat=20=E5=B0=8F=E7=BA=B8=E6=9D=A1?= =?UTF-8?q?=E6=8F=90=E9=97=AE=E7=AE=B1=20(#6217)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/social-media.md | 6 ++++ lib/router.js | 3 ++ lib/routes/popiask/tapechat_questions.js | 43 ++++++++++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 lib/routes/popiask/tapechat_questions.js diff --git a/docs/social-media.md b/docs/social-media.md index efbc3f9a30..00d05c7b9b 100644 --- a/docs/social-media.md +++ b/docs/social-media.md @@ -465,6 +465,12 @@ Tiny Tiny RSS 会给所有 iframe 元素添加 `sandbox="allow-scripts"` 属性 +## Tape 小纸条 + +### 提问箱新回答 + + + ## Telegram ### 频道 diff --git a/lib/router.js b/lib/router.js index af1d796342..e1a930ac61 100644 --- a/lib/router.js +++ b/lib/router.js @@ -3077,6 +3077,9 @@ router.get('/go-weekly', require('./routes/go-weekly')); // popiask提问箱 router.get('/popiask/:sharecode/:pagesize?', require('./routes/popiask/questions')); +// Tapechat提问箱 +router.get('/tapechat/questionbox/:sharecode/:pagesize?', require('./routes/popiask/tapechat_questions')); + // AMD router.get('/amd/graphicsdrivers/:id/:rid?', require('./routes/amd/graphicsdrivers')); diff --git a/lib/routes/popiask/tapechat_questions.js b/lib/routes/popiask/tapechat_questions.js new file mode 100644 index 0000000000..2b1e883bfd --- /dev/null +++ b/lib/routes/popiask/tapechat_questions.js @@ -0,0 +1,43 @@ +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://apiv4.tapechat.net/unuser/userBox/${sharecode}`, + headers: { + Referer: `https://www.tapechat.net/${sharecode}`, + }, + }); + + const nickname = getUserInfo.data.content.nickName; + const production = getUserInfo.data.content.production; + const avatar = getUserInfo.data.content.customPic; + // const description = getUserInfo.data.content.selfDescription; + + const getQuestionFromUser = await got({ + method: 'get', + url: `https://apiv4.tapechat.net/unuser/getQuestionFromUser/${sharecode}?pageSize=${pagesize}`, + headers: { + Referer: `https://www.tapeask.net/${sharecode}`, + }, + }); + + const data = getQuestionFromUser.data.content.data; + + ctx.state.data = { + title: `${nickname} 的 Tape 提问箱`, + link: `https://www.tapechat.net/${sharecode}`, + image: `${avatar}`, + description: `${production}`, + item: data.map((item) => ({ + title: item.title, + description: `${item.title}
(${item.createdAt})

答:
${item.answer.txtContent}
(${new Date(item.answerAt * 1000).toLocaleString()})`, + guid: item.visitCode, + pubDate: new Date(item.answerAt * 1000).toUTCString(), + link: `https://www.tapechat.net/answeredDetail.html?sharecode=${sharecode}&dynamicId=${item.visitCode}`, + })), + }; +};