From d4c74fda83416e5db8c3de30c84de7481fa617ed Mon Sep 17 00:00:00 2001 From: zhiyu1998 <542716863@qq.com> Date: Thu, 22 Aug 2024 12:02:27 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=A6=84=20reactor:=20=E9=87=8D=E6=9E=84`ti?= =?UTF-8?q?eba`=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/tools.js | 52 ++++++++++++++++++++++++++++++++++++++++++++-- constants/tools.js | 8 ++++++- 2 files changed, 57 insertions(+), 3 deletions(-) diff --git a/apps/tools.js b/apps/tools.js index 9487c04..7e6d707 100644 --- a/apps/tools.js +++ b/apps/tools.js @@ -34,7 +34,7 @@ import { DY_COMMENT, DY_INFO, DY_TOUTIAO_INFO, - GENERAL_REQ_LINK, + GENERAL_REQ_LINK, HIBI_API_SERVICE, MIYOUSHE_ARTICLE, NETEASE_API_CN, NETEASE_SONG_DOWNLOAD, @@ -157,7 +157,7 @@ export class tools extends plugin { fnc: "bodianMusic", }, { - reg: "(kuaishou.com|ixigua.com|h5.pipix.com|h5.pipigx.com|tieba.baidu.com|s.xsj.qq.com|m.okjike.com)", + reg: "(kuaishou.com|ixigua.com|h5.pipix.com|h5.pipigx.com|s.xsj.qq.com|m.okjike.com)", fnc: "general", }, { @@ -207,6 +207,10 @@ export class tools extends plugin { { reg: "https:\\/\\/t\\.me\\/(?:c\\/\\d+\\/\\d+\\/\\d+|c\\/\\d+\\/\\d+|\\w+\\/\\d+\\/\\d+|\\w+\\/\\d+\\?\\w+=\\d+|\\w+\\/\\d+)", fnc: "aircraft" + }, + { + reg: "tieba.baidu.com", + fnc: "tieba" } ], }); @@ -1889,6 +1893,50 @@ export class tools extends plugin { return true; } + async tieba(e) { + const msg = /https:\/\/tieba\.baidu\.com\/p\/[A-Za-z0-9]+/.exec(e.msg)?.[0]; + const id = /\/p\/([A-Za-z0-9]+)/.exec(msg)?.[1]; + const hibi = HIBI_API_SERVICE + `/tieba/post_detail?tid=${ id }`; + const hibiResp = await fetch(hibi, { + headers: { + "User-Agent": COMMON_USER_AGENT, + } + }); + const postList = (await hibiResp.json()).post_list; + const top = postList[0]; + const { title, content } = top; + let sendContent = `${this.identifyPrefix}识别:贴吧,${ title }` + if (content?.[0]?.cdn_src !== undefined) { + sendContent = [sendContent] + for (let contentElement of content) { + if (contentElement?.cdn_src !== undefined) { + sendContent.unshift(segment.image(contentElement.cdn_src)); + } else if (contentElement?.text !== undefined) { + sendContent.push(`\n\n📝 简介:${contentElement.text}`); + } + } + } + e.reply(sendContent, true); + const others = postList.slice(1); + const reply = others.map(item => { + if (item?.content?.[0]?.cdn_src !== undefined) { + return { + message: segment.image(item?.content?.[0]?.cdn_src), + nickname: e.sender.card || e.user_id, + user_id: e.user_id, + } + } else if (item?.content?.[0]?.text !== undefined) { + return { + message: { type: 'text', text: item?.content?.[0].text || '-'}, + nickname: e.sender.card || e.user_id, + user_id: e.user_id, + } + } + }); + e.reply(await Bot.makeForwardMsg(reply)); + return true; + } + /** * 哔哩哔哩下载 * @param title diff --git a/constants/tools.js b/constants/tools.js index 81179a5..0941102 100644 --- a/constants/tools.js +++ b/constants/tools.js @@ -198,4 +198,10 @@ export const ANIME_SERIES_SEARCH_LINK = "https://ylu.cc/so.php?wd=" * 番剧搜索链接2 * @type {string} */ -export const ANIME_SERIES_SEARCH_LINK2 = "https://yhdm.one/search?q=" \ No newline at end of file +export const ANIME_SERIES_SEARCH_LINK2 = "https://yhdm.one/search?q=" + +/** + * HIBI API + * @type {string} + */ +export const HIBI_API_SERVICE = "https://hibi.moecube.com/api"; \ No newline at end of file