koishi-plugin-kkk 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +57 -0
- package/LICENSE +674 -0
- package/README.md +98 -0
- package/assets/web/assets/CronEditor-CYgFpX-g.js +1 -0
- package/assets/web/assets/DesktopLayout-iI43ij11.js +1 -0
- package/assets/web/assets/MobileLayout-CziU8MCR.js +1 -0
- package/assets/web/assets/ThemeSwitch-DFohhwd9.js +1 -0
- package/assets/web/assets/index-BRROK0vh.js +47 -0
- package/assets/web/assets/index-Dj-StEiS.css +2 -0
- package/assets/web/assets/separator-CxcFlCzz.js +1 -0
- package/assets/web/favicon.svg +1 -0
- package/assets/web/icons.svg +24 -0
- package/assets/web/index.html +15 -0
- package/assets/webui.html +115 -0
- package/client/index.ts +63 -0
- package/config/default_config/app.yaml +64 -0
- package/config/default_config/bilibili.yaml +116 -0
- package/config/default_config/config.json +157 -0
- package/config/default_config/cookies.yaml +11 -0
- package/config/default_config/douyin.yaml +99 -0
- package/config/default_config/kuaishou.yaml +8 -0
- package/config/default_config/pushlist.yaml +37 -0
- package/config/default_config/request.yaml +22 -0
- package/config/default_config/upload.yaml +50 -0
- package/config/default_config/xiaohongshu.yaml +23 -0
- package/dist/index.js +1 -0
- package/lib/compat/axios.js +23 -0
- package/lib/compat/cron.js +77 -0
- package/lib/compat/esm.js +15 -0
- package/lib/compat/express.js +23 -0
- package/lib/compat/heroui.js +12 -0
- package/lib/compat/lodash.js +33 -0
- package/lib/compat/logger.js +118 -0
- package/lib/compat/node-karin.js +1053 -0
- package/lib/compat/phosphor-icons.js +27 -0
- package/lib/compat/qqcard.js +256 -0
- package/lib/compat/root.js +44 -0
- package/lib/compat/runtime.js +87 -0
- package/lib/compat/segment.js +167 -0
- package/lib/compat/sqlite3.js +117 -0
- package/lib/compat/start.js +7 -0
- package/lib/compat/syncConfig.js +65 -0
- package/lib/compat/template-react.js +30 -0
- package/lib/compat/text.js +65 -0
- package/lib/compat/yaml.js +13 -0
- package/lib/configBridge.js +91 -0
- package/lib/index.js +775 -0
- package/lib/karin/app.js +34 -0
- package/lib/karin/apps/__ready.js +9 -0
- package/lib/karin/apps/admin.js +136 -0
- package/lib/karin/apps/help.js +233 -0
- package/lib/karin/apps/push.js +291 -0
- package/lib/karin/apps/qrlogin.js +176 -0
- package/lib/karin/apps/statistics.js +209 -0
- package/lib/karin/apps/testPush.js +247 -0
- package/lib/karin/apps/tools.js +473 -0
- package/lib/karin/apps/update.js +252 -0
- package/lib/karin/index.js +37 -0
- package/lib/karin/module/db/bilibili.js +831 -0
- package/lib/karin/module/db/douyin.js +918 -0
- package/lib/karin/module/db/index.js +165 -0
- package/lib/karin/module/db/migration.js +199 -0
- package/lib/karin/module/db/statistics.js +559 -0
- package/lib/karin/module/index.js +94 -0
- package/lib/karin/module/server/constants/routes.js +48 -0
- package/lib/karin/module/server/controllers/bots.js +230 -0
- package/lib/karin/module/server/controllers/config.js +75 -0
- package/lib/karin/module/server/controllers/video.js +208 -0
- package/lib/karin/module/server/index.js +26 -0
- package/lib/karin/module/server/middlewares/auth.js +133 -0
- package/lib/karin/module/server/routes/amagi.js +57 -0
- package/lib/karin/module/server/routes/api.js +40 -0
- package/lib/karin/module/server/routes/index.js +97 -0
- package/lib/karin/module/server/routes/ssr.js +16 -0
- package/lib/karin/module/server/routes/static.js +43 -0
- package/lib/karin/module/utils/Base.js +403 -0
- package/lib/karin/module/utils/CardParser.js +487 -0
- package/lib/karin/module/utils/Common.js +418 -0
- package/lib/karin/module/utils/Config.js +434 -0
- package/lib/karin/module/utils/EmojiReaction.js +242 -0
- package/lib/karin/module/utils/ErrorHandler/handler.js +114 -0
- package/lib/karin/module/utils/ErrorHandler/index.js +55 -0
- package/lib/karin/module/utils/ErrorHandler/render.js +182 -0
- package/lib/karin/module/utils/ErrorHandler/sender.js +206 -0
- package/lib/karin/module/utils/ErrorHandler/strategy.js +41 -0
- package/lib/karin/module/utils/ErrorHandler/types.js +2 -0
- package/lib/karin/module/utils/ErrorHandler/utils.js +108 -0
- package/lib/karin/module/utils/FFmpeg.js +298 -0
- package/lib/karin/module/utils/ImageHelper.js +91 -0
- package/lib/karin/module/utils/ImageSlice.js +429 -0
- package/lib/karin/module/utils/MotionPhoto.js +250 -0
- package/lib/karin/module/utils/Network/Downloader.js +413 -0
- package/lib/karin/module/utils/Network/ImageDownloader.js +250 -0
- package/lib/karin/module/utils/Network/Network.js +332 -0
- package/lib/karin/module/utils/Network/ThrottleStream.js +71 -0
- package/lib/karin/module/utils/Network/constants.js +129 -0
- package/lib/karin/module/utils/Network/helpers.js +174 -0
- package/lib/karin/module/utils/Network/index.js +34 -0
- package/lib/karin/module/utils/Network/types.js +12 -0
- package/lib/karin/module/utils/Networks.js +17 -0
- package/lib/karin/module/utils/ParseLock.js +34 -0
- package/lib/karin/module/utils/ParseOverride.js +88 -0
- package/lib/karin/module/utils/QqCardResolve.js +114 -0
- package/lib/karin/module/utils/QqPanel.js +879 -0
- package/lib/karin/module/utils/Render/coverTheme.js +256 -0
- package/lib/karin/module/utils/Render/index.js +582 -0
- package/lib/karin/module/utils/amagiClient.js +338 -0
- package/lib/karin/module/utils/avatar.js +201 -0
- package/lib/karin/module/utils/bot.js +141 -0
- package/lib/karin/module/utils/build-metadata.js +50 -0
- package/lib/karin/module/utils/changelog.js +166 -0
- package/lib/karin/module/utils/index.js +26 -0
- package/lib/karin/module/utils/loginSession.js +259 -0
- package/lib/karin/module/utils/parseTip.js +93 -0
- package/lib/karin/module/utils/runtime-report.js +140 -0
- package/lib/karin/module/utils/semver.js +72 -0
- package/lib/karin/module/utils/statisticsAggregate.js +415 -0
- package/lib/karin/platform/bilibili/bilibili.js +1805 -0
- package/lib/karin/platform/bilibili/comments.js +294 -0
- package/lib/karin/platform/bilibili/danmaku.js +555 -0
- package/lib/karin/platform/bilibili/dynamic-text.js +827 -0
- package/lib/karin/platform/bilibili/genParams.js +37 -0
- package/lib/karin/platform/bilibili/getID.js +159 -0
- package/lib/karin/platform/bilibili/index.js +24 -0
- package/lib/karin/platform/bilibili/live-status.js +40 -0
- package/lib/karin/platform/bilibili/login.js +132 -0
- package/lib/karin/platform/bilibili/push.js +1397 -0
- package/lib/karin/platform/bilibili/riskControl.js +133 -0
- package/lib/karin/platform/bilibili/search.js +299 -0
- package/lib/karin/platform/common/danmaku-types.js +12 -0
- package/lib/karin/platform/douyin/comments.js +310 -0
- package/lib/karin/platform/douyin/danmaku.js +893 -0
- package/lib/karin/platform/douyin/douyin.js +1145 -0
- package/lib/karin/platform/douyin/getID.js +94 -0
- package/lib/karin/platform/douyin/index.js +24 -0
- package/lib/karin/platform/douyin/login.js +230 -0
- package/lib/karin/platform/douyin/push/favorite.js +75 -0
- package/lib/karin/platform/douyin/push/index.js +21 -0
- package/lib/karin/platform/douyin/push/live.js +69 -0
- package/lib/karin/platform/douyin/push/post.js +60 -0
- package/lib/karin/platform/douyin/push/recommend.js +74 -0
- package/lib/karin/platform/douyin/push/render.js +621 -0
- package/lib/karin/platform/douyin/push/types.js +2 -0
- package/lib/karin/platform/douyin/push.js +1128 -0
- package/lib/karin/platform/douyin/types.js +13 -0
- package/lib/karin/platform/douyin/videoQuality.js +222 -0
- package/lib/karin/platform/douyin/workType.js +182 -0
- package/lib/karin/platform/index.js +20 -0
- package/lib/karin/platform/kuaishou/comments.js +91 -0
- package/lib/karin/platform/kuaishou/getID.js +43 -0
- package/lib/karin/platform/kuaishou/getdata.js +41 -0
- package/lib/karin/platform/kuaishou/index.js +20 -0
- package/lib/karin/platform/kuaishou/kuaishou.js +122 -0
- package/lib/karin/platform/xiaohongshu/comments.js +162 -0
- package/lib/karin/platform/xiaohongshu/getID.js +129 -0
- package/lib/karin/platform/xiaohongshu/index.js +18 -0
- package/lib/karin/platform/xiaohongshu/xiaohongshu.js +643 -0
- package/lib/karin/root.js +73 -0
- package/lib/karin/setup.js +99 -0
- package/lib/karin/types/config/amagi.js +2 -0
- package/lib/karin/types/config/app.js +2 -0
- package/lib/karin/types/config/bilibili.js +2 -0
- package/lib/karin/types/config/cookies.js +2 -0
- package/lib/karin/types/config/douyin.js +2 -0
- package/lib/karin/types/config/index.js +2 -0
- package/lib/karin/types/config/kuaishou.js +2 -0
- package/lib/karin/types/config/pushlist.js +2 -0
- package/lib/karin/types/config/request.js +2 -0
- package/lib/karin/types/config/upload.js +2 -0
- package/lib/karin/types/config/xiaohongshu.js +2 -0
- package/lib/karin/types/datatypes.js +2 -0
- package/lib/karin/types/index.js +18 -0
- package/lib/karin/types/netrorks/NetworksConfigType.js +2 -0
- package/lib/karin/types/netrorks/index.js +17 -0
- package/lib/karin/web.config.js +49 -0
- package/lib/ktr/registry.js +82 -0
- package/lib/ktr/template/_preview/components/PreviewInfoCard.js +10 -0
- package/lib/ktr/template/_preview/components/PreviewLayout.js +10 -0
- package/lib/ktr/template/_preview/components/PreviewVideoCard.js +8 -0
- package/lib/ktr/template/_preview/render.js +142 -0
- package/lib/ktr/template/_preview/types.js +2 -0
- package/lib/ktr/template/_preview/utils/status.js +31 -0
- package/lib/ktr/template/_preview/utils/time.js +12 -0
- package/lib/ktr/template/bilibili/bangumi/components/bangumi.js +127 -0
- package/lib/ktr/template/bilibili/bangumi/components/types.js +2 -0
- package/lib/ktr/template/bilibili/bangumi/index.js +12 -0
- package/lib/ktr/template/bilibili/comment/components/Comment.js +193 -0
- package/lib/ktr/template/bilibili/comment/components/types.js +2 -0
- package/lib/ktr/template/bilibili/comment/index.js +10 -0
- package/lib/ktr/template/bilibili/components/Icons.js +66 -0
- package/lib/ktr/template/bilibili/components/shared.js +93 -0
- package/lib/ktr/template/bilibili/components/types.js +2 -0
- package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_ARTICLE/components/DYNAMIC_TYPE_ARTICLE.js +66 -0
- package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_ARTICLE/components/types.js +2 -0
- package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_ARTICLE/index.js +10 -0
- package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_AV/components/DYNAMIC_TYPE_AV.js +87 -0
- package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_AV/components/types.js +2 -0
- package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_AV/index.js +10 -0
- package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_DRAW/components/DYNAMIC_TYPE_DRAW.js +93 -0
- package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_DRAW/components/types.js +2 -0
- package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_DRAW/index.js +10 -0
- package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_FORWARD/components/DYNAMIC_TYPE_FORWARD.js +132 -0
- package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_FORWARD/components/types.js +2 -0
- package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_FORWARD/index.js +10 -0
- package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_LIVE_RCMD/components/DYNAMIC_TYPE_LIVE_RCMD.js +84 -0
- package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_LIVE_RCMD/components/types.js +2 -0
- package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_LIVE_RCMD/index.js +10 -0
- package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_WORD/components/DYNAMIC_TYPE_WORD.js +38 -0
- package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_WORD/components/types.js +2 -0
- package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_WORD/index.js +10 -0
- package/lib/ktr/template/bilibili/dynamic/components/AdditionalCard.js +59 -0
- package/lib/ktr/template/bilibili/dynamic/components/CommonComponents.js +30 -0
- package/lib/ktr/template/bilibili/dynamic/types.js +2 -0
- package/lib/ktr/template/bilibili/qrcodeImg/components/qrcodeImg.js +48 -0
- package/lib/ktr/template/bilibili/qrcodeImg/components/types.js +3 -0
- package/lib/ktr/template/bilibili/qrcodeImg/index.js +10 -0
- package/lib/ktr/template/bilibili/userlist/components/UserList.js +53 -0
- package/lib/ktr/template/bilibili/userlist/components/types.js +3 -0
- package/lib/ktr/template/bilibili/userlist/index.js +13 -0
- package/lib/ktr/template/bilibili/videoInfo/components/types.js +2 -0
- package/lib/ktr/template/bilibili/videoInfo/components/videoInfo.js +62 -0
- package/lib/ktr/template/bilibili/videoInfo/index.js +10 -0
- package/lib/ktr/template/components/AmbientCover.js +36 -0
- package/lib/ktr/template/components/DefaultLayout.js +33 -0
- package/lib/ktr/template/components/GlowImage.js +276 -0
- package/lib/ktr/template/components/QRCodeWithAvatar.js +34 -0
- package/lib/ktr/template/components/RolldownLogo.js +6 -0
- package/lib/ktr/template/components/ViteLogo.js +6 -0
- package/lib/ktr/template/components/iconRegistry.js +173 -0
- package/lib/ktr/template/douyin/article-work/components/ArticleWork.js +99 -0
- package/lib/ktr/template/douyin/article-work/components/types.js +3 -0
- package/lib/ktr/template/douyin/article-work/index.js +10 -0
- package/lib/ktr/template/douyin/comment/components/Comment.js +189 -0
- package/lib/ktr/template/douyin/comment/components/types.js +2 -0
- package/lib/ktr/template/douyin/comment/index.js +10 -0
- package/lib/ktr/template/douyin/components/Icons.js +29 -0
- package/lib/ktr/template/douyin/components/types.js +3 -0
- package/lib/ktr/template/douyin/dynamic/components/Dynamic.js +90 -0
- package/lib/ktr/template/douyin/dynamic/components/types.js +3 -0
- package/lib/ktr/template/douyin/dynamic/index.js +10 -0
- package/lib/ktr/template/douyin/favorite-list/components/FavoriteList.js +30 -0
- package/lib/ktr/template/douyin/favorite-list/components/types.js +3 -0
- package/lib/ktr/template/douyin/favorite-list/index.js +10 -0
- package/lib/ktr/template/douyin/image-work/components/ImageWork.js +136 -0
- package/lib/ktr/template/douyin/image-work/components/types.js +2 -0
- package/lib/ktr/template/douyin/image-work/index.js +10 -0
- package/lib/ktr/template/douyin/live/components/Live.js +51 -0
- package/lib/ktr/template/douyin/live/components/types.js +3 -0
- package/lib/ktr/template/douyin/live/index.js +10 -0
- package/lib/ktr/template/douyin/musicinfo/components/MusicInfo.js +60 -0
- package/lib/ktr/template/douyin/musicinfo/components/types.js +3 -0
- package/lib/ktr/template/douyin/musicinfo/index.js +10 -0
- package/lib/ktr/template/douyin/qrcodeImg/components/qrcodeImg.js +39 -0
- package/lib/ktr/template/douyin/qrcodeImg/components/types.js +3 -0
- package/lib/ktr/template/douyin/qrcodeImg/index.js +9 -0
- package/lib/ktr/template/douyin/recommend-list/components/RecommendList.js +30 -0
- package/lib/ktr/template/douyin/recommend-list/components/types.js +3 -0
- package/lib/ktr/template/douyin/recommend-list/index.js +10 -0
- package/lib/ktr/template/douyin/user_profile/components/UserVideoList.js +54 -0
- package/lib/ktr/template/douyin/user_profile/components/types.js +3 -0
- package/lib/ktr/template/douyin/user_profile/index.js +9 -0
- package/lib/ktr/template/douyin/userlist/components/UserList.js +50 -0
- package/lib/ktr/template/douyin/userlist/components/types.js +3 -0
- package/lib/ktr/template/douyin/userlist/index.js +13 -0
- package/lib/ktr/template/douyin/video-work/components/VideoWork.js +127 -0
- package/lib/ktr/template/douyin/video-work/components/types.js +2 -0
- package/lib/ktr/template/douyin/video-work/index.js +10 -0
- package/lib/ktr/template/kuaishou/comment/components/Comment.js +88 -0
- package/lib/ktr/template/kuaishou/comment/components/types.js +2 -0
- package/lib/ktr/template/kuaishou/comment/index.js +10 -0
- package/lib/ktr/template/other/changelog/components/changelog.js +117 -0
- package/lib/ktr/template/other/changelog/components/types.js +3 -0
- package/lib/ktr/template/other/changelog/index.js +9 -0
- package/lib/ktr/template/other/handlerError/components/errorTitles.js +227 -0
- package/lib/ktr/template/other/handlerError/components/handlerError.js +392 -0
- package/lib/ktr/template/other/handlerError/components/stackHighlight.js +109 -0
- package/lib/ktr/template/other/handlerError/components/types.js +2 -0
- package/lib/ktr/template/other/handlerError/index.js +9 -0
- package/lib/ktr/template/other/help/components/Help.js +79 -0
- package/lib/ktr/template/other/help/components/types.js +3 -0
- package/lib/ktr/template/other/help/index.js +12 -0
- package/lib/ktr/template/other/live-photo-tip/components/LivePhotoTip.js +80 -0
- package/lib/ktr/template/other/live-photo-tip/components/types.js +3 -0
- package/lib/ktr/template/other/live-photo-tip/index.js +9 -0
- package/lib/ktr/template/other/qrlogin/components/qrlogin.js +58 -0
- package/lib/ktr/template/other/qrlogin/components/types.js +3 -0
- package/lib/ktr/template/other/qrlogin/index.js +9 -0
- package/lib/ktr/template/other/runtime/components/runtime.js +101 -0
- package/lib/ktr/template/other/runtime/components/types.js +3 -0
- package/lib/ktr/template/other/runtime/index.js +9 -0
- package/lib/ktr/template/other/version_warning/components/VersionWarning.js +38 -0
- package/lib/ktr/template/other/version_warning/components/types.js +3 -0
- package/lib/ktr/template/other/version_warning/index.js +9 -0
- package/lib/ktr/template/statistics/components/BoxplotGuide.js +17 -0
- package/lib/ktr/template/statistics/components/ChartCard.js +15 -0
- package/lib/ktr/template/statistics/components/KpiCard.js +14 -0
- package/lib/ktr/template/statistics/components/PlatformTable.js +20 -0
- package/lib/ktr/template/statistics/components/RankList.js +61 -0
- package/lib/ktr/template/statistics/components/SSRChart.js +22 -0
- package/lib/ktr/template/statistics/components/chartPresets.js +630 -0
- package/lib/ktr/template/statistics/components/chartTheme.js +226 -0
- package/lib/ktr/template/statistics/components/format.js +38 -0
- package/lib/ktr/template/statistics/components/types.js +9 -0
- package/lib/ktr/template/statistics/global/components/GlobalStatistics.js +246 -0
- package/lib/ktr/template/statistics/global/components/types.js +3 -0
- package/lib/ktr/template/statistics/global/index.js +9 -0
- package/lib/ktr/template/statistics/group/components/GroupStatistics.js +181 -0
- package/lib/ktr/template/statistics/group/components/types.js +3 -0
- package/lib/ktr/template/statistics/group/index.js +9 -0
- package/lib/ktr/template/types/ctx.js +2 -0
- package/lib/ktr/template/xiaohongshu/comment/components/Comment.js +99 -0
- package/lib/ktr/template/xiaohongshu/comment/components/types.js +3 -0
- package/lib/ktr/template/xiaohongshu/comment/index.js +9 -0
- package/lib/ktr/template/xiaohongshu/noteInfo/components/noteInfo.js +93 -0
- package/lib/ktr/template/xiaohongshu/noteInfo/components/types.js +2 -0
- package/lib/ktr/template/xiaohongshu/noteInfo/index.js +9 -0
- package/lib/ktr/utils/QRCodeAvatar.js +99 -0
- package/lib/ktr/utils/QRcode.js +56 -0
- package/lib/ktr/utils/avatarProxy.js +45 -0
- package/lib/ktr/utils/cn.js +11 -0
- package/lib/ktr/utils/theme.js +12 -0
- package/lib/qqFields.json +75 -0
- package/lib/qqOptions.js +44 -0
- package/lib/richtext/index.js +25 -0
- package/lib/richtext/parse/index.js +232 -0
- package/lib/richtext/react/cn.js +11 -0
- package/lib/richtext/react/index.js +221 -0
- package/lib/richtext/types.js +2 -0
- package/lib/schema.js +352 -0
- package/lib/webui.js +341 -0
- package/package.json +88 -0
- package/resources/image/bilibili/RICH_TEXT_NODE_TYPE/RICH_TEXT_NODE_TYPE_BV.svg +1 -0
- package/resources/image/bilibili/RICH_TEXT_NODE_TYPE/RICH_TEXT_NODE_TYPE_GOODS.svg +1 -0
- package/resources/image/bilibili/RICH_TEXT_NODE_TYPE/RICH_TEXT_NODE_TYPE_LOTTERY.svg +1 -0
- package/resources/image/bilibili/RICH_TEXT_NODE_TYPE/RICH_TEXT_NODE_TYPE_VIEW_PICTURE.svg +1 -0
- package/resources/image/bilibili/RICH_TEXT_NODE_TYPE/RICH_TEXT_NODE_TYPE_VOTE.svg +1 -0
- package/resources/image/bilibili/RICH_TEXT_NODE_TYPE/RICH_TEXT_NODE_TYPE_WEB.svg +1 -0
- package/resources/image/bilibili/bilibili-dark.png +0 -0
- package/resources/image/bilibili/bilibili-light.png +0 -0
- package/resources/image/bilibili/bilibili.png +0 -0
- package/resources/image/bilibili/id-dark.svg +1 -0
- package/resources/image/bilibili/id-light.svg +1 -0
- package/resources/image/bilibili/level/lv0.svg +1 -0
- package/resources/image/bilibili/level/lv1.svg +1 -0
- package/resources/image/bilibili/level/lv2.svg +1 -0
- package/resources/image/bilibili/level/lv3.svg +1 -0
- package/resources/image/bilibili/level/lv4.svg +1 -0
- package/resources/image/bilibili/level/lv5.svg +1 -0
- package/resources/image/bilibili/level/lv6.svg +1 -0
- package/resources/image/bilibili/level/lv7.svg +1 -0
- package/resources/image/bilibili/like-dark.svg +6 -0
- package/resources/image/bilibili/like-light.svg +6 -0
- package/resources/image/bilibili/play.svg +28 -0
- package/resources/image/bilibili/res-local1.png +0 -0
- package/resources/image/bilibili/up_pb.svg +1 -0
- package/resources/image/bilibili//347/233/264/346/222/255/344/270/255.png +0 -0
- package/resources/image/douyin/douyin.png +0 -0
- package/resources/image/douyin/dylogo-dark.svg +23 -0
- package/resources/image/douyin/dylogo-light.svg +38 -0
- package/resources/image/douyin/search-dark.svg +1 -0
- package/resources/image/douyin/search-light.svg +3 -0
- package/resources/image/douyin//346/212/226/351/237/263-/347/233/264/346/222/255/344/270/255.png +0 -0
- package/resources/image/frame-logo.png +0 -0
- package/resources/image/kuaishou/logo.png +0 -0
- package/resources/image/other/handlerError/Milky.png +0 -0
- package/resources/image/other/handlerError/chronocat.svg +43 -0
- package/resources/image/other/handlerError/conwechat.webp +0 -0
- package/resources/image/other/handlerError/gocq-http.webp +0 -0
- package/resources/image/other/handlerError/lagrange.webp +0 -0
- package/resources/image/other/handlerError/llonebot.webp +0 -0
- package/resources/image/other/handlerError/napcat.webp +0 -0
- package/resources/image/other/handlerError/onebot.png +0 -0
- package/resources/image/other/handlerError/satori.png +0 -0
- package/resources/image/xiaohongshu/logo.png +0 -0
- package/resources/template/style.css +23708 -0
- package/resources/vite.svg +130 -0
- package/scripts/build.mjs +129 -0
- package/scripts/check-schema.cjs +55 -0
- package/scripts/deploy.mjs +78 -0
- package/scripts/make-demo-placeholders.mjs +112 -0
- package/scripts/patch-deps.mjs +46 -0
- package/scripts/patch-webui.mjs +112 -0
- package/scripts/smoke-commands.cjs +39 -0
- package/scripts/smoke-config.cjs +122 -0
- package/scripts/smoke-douyin.cjs +170 -0
- package/scripts/smoke-koishi-commands.cjs +210 -0
- package/scripts/smoke-login.cjs +110 -0
- package/scripts/smoke-parse.cjs +54 -0
- package/scripts/smoke-push-mock.cjs +114 -0
- package/scripts/smoke-push.cjs +104 -0
- package/scripts/smoke-qq.cjs +147 -0
- package/scripts/smoke-qqcard.cjs +108 -0
- package/scripts/smoke-qqpanel.cjs +205 -0
- package/scripts/smoke-render.cjs +106 -0
- package/scripts/smoke-server.cjs +94 -0
- package/src/compat/axios.ts +5 -0
- package/src/compat/cron.ts +86 -0
- package/src/compat/esm.ts +13 -0
- package/src/compat/express.ts +5 -0
- package/src/compat/heroui.tsx +53 -0
- package/src/compat/lodash.ts +32 -0
- package/src/compat/logger.ts +121 -0
- package/src/compat/node-karin.ts +1064 -0
- package/src/compat/phosphor-icons.tsx +25 -0
- package/src/compat/qqcard.ts +251 -0
- package/src/compat/root.ts +44 -0
- package/src/compat/runtime.ts +120 -0
- package/src/compat/segment.ts +161 -0
- package/src/compat/sqlite3.ts +123 -0
- package/src/compat/start.ts +3 -0
- package/src/compat/syncConfig.ts +64 -0
- package/src/compat/template-react.ts +54 -0
- package/src/compat/text.ts +58 -0
- package/src/compat/yaml.ts +6 -0
- package/src/configBridge.ts +94 -0
- package/src/index.ts +769 -0
- package/src/karin/app.ts +1 -0
- package/src/karin/apps/__ready.ts +14 -0
- package/src/karin/apps/admin.ts +127 -0
- package/src/karin/apps/help.ts +228 -0
- package/src/karin/apps/push.ts +327 -0
- package/src/karin/apps/qrlogin.ts +160 -0
- package/src/karin/apps/statistics.ts +203 -0
- package/src/karin/apps/testPush.ts +226 -0
- package/src/karin/apps/tools.ts +510 -0
- package/src/karin/apps/update.ts +239 -0
- package/src/karin/index.ts +9 -0
- package/src/karin/module/db/bilibili.ts +1089 -0
- package/src/karin/module/db/douyin.ts +1218 -0
- package/src/karin/module/db/index.ts +159 -0
- package/src/karin/module/db/migration.ts +249 -0
- package/src/karin/module/db/statistics.ts +817 -0
- package/src/karin/module/index.ts +37 -0
- package/src/karin/module/server/constants/routes.ts +53 -0
- package/src/karin/module/server/controllers/bots.ts +289 -0
- package/src/karin/module/server/controllers/config.ts +85 -0
- package/src/karin/module/server/controllers/video.ts +212 -0
- package/src/karin/module/server/index.ts +11 -0
- package/src/karin/module/server/middlewares/auth.ts +147 -0
- package/src/karin/module/server/routes/amagi.ts +57 -0
- package/src/karin/module/server/routes/api.ts +42 -0
- package/src/karin/module/server/routes/index.ts +68 -0
- package/src/karin/module/server/routes/ssr.ts +14 -0
- package/src/karin/module/server/routes/static.ts +43 -0
- package/src/karin/module/utils/Base.ts +497 -0
- package/src/karin/module/utils/CardParser.ts +503 -0
- package/src/karin/module/utils/Common.ts +448 -0
- package/src/karin/module/utils/Config.ts +443 -0
- package/src/karin/module/utils/EmojiReaction.ts +268 -0
- package/src/karin/module/utils/ErrorHandler/handler.ts +124 -0
- package/src/karin/module/utils/ErrorHandler/index.ts +48 -0
- package/src/karin/module/utils/ErrorHandler/render.ts +180 -0
- package/src/karin/module/utils/ErrorHandler/sender.ts +192 -0
- package/src/karin/module/utils/ErrorHandler/strategy.ts +41 -0
- package/src/karin/module/utils/ErrorHandler/types.ts +122 -0
- package/src/karin/module/utils/ErrorHandler/utils.ts +108 -0
- package/src/karin/module/utils/FFmpeg.ts +357 -0
- package/src/karin/module/utils/ImageHelper.ts +90 -0
- package/src/karin/module/utils/ImageSlice.ts +383 -0
- package/src/karin/module/utils/MotionPhoto.ts +297 -0
- package/src/karin/module/utils/Network/Downloader.ts +481 -0
- package/src/karin/module/utils/Network/ImageDownloader.ts +291 -0
- package/src/karin/module/utils/Network/Network.ts +344 -0
- package/src/karin/module/utils/Network/ThrottleStream.ts +76 -0
- package/src/karin/module/utils/Network/constants.ts +135 -0
- package/src/karin/module/utils/Network/helpers.ts +183 -0
- package/src/karin/module/utils/Network/index.ts +28 -0
- package/src/karin/module/utils/Network/types.ts +46 -0
- package/src/karin/module/utils/Networks.ts +20 -0
- package/src/karin/module/utils/ParseLock.ts +33 -0
- package/src/karin/module/utils/ParseOverride.ts +128 -0
- package/src/karin/module/utils/QqCardResolve.ts +116 -0
- package/src/karin/module/utils/QqPanel.ts +880 -0
- package/src/karin/module/utils/Render/coverTheme.ts +294 -0
- package/src/karin/module/utils/Render/index.ts +574 -0
- package/src/karin/module/utils/amagiClient.ts +368 -0
- package/src/karin/module/utils/avatar.ts +220 -0
- package/src/karin/module/utils/bot.ts +115 -0
- package/src/karin/module/utils/build-metadata.ts +60 -0
- package/src/karin/module/utils/changelog.ts +175 -0
- package/src/karin/module/utils/index.ts +10 -0
- package/src/karin/module/utils/loginSession.ts +291 -0
- package/src/karin/module/utils/parseTip.ts +59 -0
- package/src/karin/module/utils/runtime-report.ts +142 -0
- package/src/karin/module/utils/semver.ts +60 -0
- package/src/karin/module/utils/statisticsAggregate.ts +507 -0
- package/src/karin/platform/bilibili/bilibili.ts +2004 -0
- package/src/karin/platform/bilibili/comments.ts +397 -0
- package/src/karin/platform/bilibili/danmaku.ts +653 -0
- package/src/karin/platform/bilibili/dynamic-text.ts +926 -0
- package/src/karin/platform/bilibili/genParams.ts +30 -0
- package/src/karin/platform/bilibili/getID.ts +163 -0
- package/src/karin/platform/bilibili/index.ts +8 -0
- package/src/karin/platform/bilibili/live-status.ts +36 -0
- package/src/karin/platform/bilibili/login.ts +130 -0
- package/src/karin/platform/bilibili/push.ts +1615 -0
- package/src/karin/platform/bilibili/riskControl.ts +114 -0
- package/src/karin/platform/bilibili/search.ts +305 -0
- package/src/karin/platform/common/danmaku-types.ts +18 -0
- package/src/karin/platform/douyin/comments.ts +404 -0
- package/src/karin/platform/douyin/danmaku.ts +1187 -0
- package/src/karin/platform/douyin/douyin.ts +1244 -0
- package/src/karin/platform/douyin/getID.ts +101 -0
- package/src/karin/platform/douyin/index.ts +8 -0
- package/src/karin/platform/douyin/login.ts +251 -0
- package/src/karin/platform/douyin/push/favorite.ts +97 -0
- package/src/karin/platform/douyin/push/index.ts +5 -0
- package/src/karin/platform/douyin/push/live.ts +86 -0
- package/src/karin/platform/douyin/push/post.ts +75 -0
- package/src/karin/platform/douyin/push/recommend.ts +96 -0
- package/src/karin/platform/douyin/push/render.ts +768 -0
- package/src/karin/platform/douyin/push/types.ts +41 -0
- package/src/karin/platform/douyin/push.ts +1241 -0
- package/src/karin/platform/douyin/types.ts +151 -0
- package/src/karin/platform/douyin/videoQuality.ts +234 -0
- package/src/karin/platform/douyin/workType.ts +238 -0
- package/src/karin/platform/index.ts +4 -0
- package/src/karin/platform/kuaishou/comments.ts +114 -0
- package/src/karin/platform/kuaishou/getID.ts +48 -0
- package/src/karin/platform/kuaishou/getdata.ts +78 -0
- package/src/karin/platform/kuaishou/index.ts +4 -0
- package/src/karin/platform/kuaishou/kuaishou.ts +130 -0
- package/src/karin/platform/xiaohongshu/comments.ts +227 -0
- package/src/karin/platform/xiaohongshu/getID.ts +127 -0
- package/src/karin/platform/xiaohongshu/index.ts +2 -0
- package/src/karin/platform/xiaohongshu/xiaohongshu.ts +733 -0
- package/src/karin/root.ts +78 -0
- package/src/karin/setup.ts +77 -0
- package/src/karin/types/config/amagi.ts +46 -0
- package/src/karin/types/config/app.ts +129 -0
- package/src/karin/types/config/bilibili.ts +121 -0
- package/src/karin/types/config/cookies.ts +11 -0
- package/src/karin/types/config/douyin.ts +93 -0
- package/src/karin/types/config/index.ts +41 -0
- package/src/karin/types/config/kuaishou.ts +10 -0
- package/src/karin/types/config/pushlist.ts +55 -0
- package/src/karin/types/config/request.ts +27 -0
- package/src/karin/types/config/upload.ts +49 -0
- package/src/karin/types/config/xiaohongshu.ts +24 -0
- package/src/karin/types/datatypes.ts +42 -0
- package/src/karin/types/index.ts +4 -0
- package/src/karin/types/netrorks/NetworksConfigType.ts +61 -0
- package/src/karin/types/netrorks/index.ts +1 -0
- package/src/karin/web.config.ts +48 -0
- package/src/ktr/registry.ts +55 -0
- package/src/ktr/template/_preview/components/PreviewInfoCard.tsx +33 -0
- package/src/ktr/template/_preview/components/PreviewLayout.tsx +65 -0
- package/src/ktr/template/_preview/components/PreviewVideoCard.tsx +22 -0
- package/src/ktr/template/_preview/render.ts +158 -0
- package/src/ktr/template/_preview/types.ts +15 -0
- package/src/ktr/template/_preview/utils/status.ts +29 -0
- package/src/ktr/template/_preview/utils/time.ts +8 -0
- package/src/ktr/template/bilibili/bangumi/components/bangumi.tsx +462 -0
- package/src/ktr/template/bilibili/bangumi/components/types.ts +36 -0
- package/src/ktr/template/bilibili/bangumi/index.tsx +9 -0
- package/src/ktr/template/bilibili/comment/components/Comment.tsx +657 -0
- package/src/ktr/template/bilibili/comment/components/types.ts +26 -0
- package/src/ktr/template/bilibili/comment/index.tsx +11 -0
- package/src/ktr/template/bilibili/components/Icons.tsx +209 -0
- package/src/ktr/template/bilibili/components/shared.tsx +162 -0
- package/src/ktr/template/bilibili/components/types.ts +388 -0
- package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_ARTICLE/components/DYNAMIC_TYPE_ARTICLE.tsx +251 -0
- package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_ARTICLE/components/types.ts +67 -0
- package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_ARTICLE/index.tsx +12 -0
- package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_AV/components/DYNAMIC_TYPE_AV.tsx +238 -0
- package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_AV/components/types.ts +39 -0
- package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_AV/index.tsx +12 -0
- package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_DRAW/components/DYNAMIC_TYPE_DRAW.tsx +205 -0
- package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_DRAW/components/types.ts +20 -0
- package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_DRAW/index.tsx +11 -0
- package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_FORWARD/components/DYNAMIC_TYPE_FORWARD.tsx +348 -0
- package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_FORWARD/components/types.ts +16 -0
- package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_FORWARD/index.tsx +12 -0
- package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_LIVE_RCMD/components/DYNAMIC_TYPE_LIVE_RCMD.tsx +264 -0
- package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_LIVE_RCMD/components/types.ts +32 -0
- package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_LIVE_RCMD/index.tsx +12 -0
- package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_WORD/components/DYNAMIC_TYPE_WORD.tsx +68 -0
- package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_WORD/components/types.ts +14 -0
- package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_WORD/index.tsx +12 -0
- package/src/ktr/template/bilibili/dynamic/components/AdditionalCard.tsx +165 -0
- package/src/ktr/template/bilibili/dynamic/components/CommonComponents.tsx +142 -0
- package/src/ktr/template/bilibili/dynamic/types.ts +382 -0
- package/src/ktr/template/bilibili/qrcodeImg/components/qrcodeImg.tsx +179 -0
- package/src/ktr/template/bilibili/qrcodeImg/components/types.ts +9 -0
- package/src/ktr/template/bilibili/qrcodeImg/index.tsx +12 -0
- package/src/ktr/template/bilibili/userlist/components/UserList.tsx +246 -0
- package/src/ktr/template/bilibili/userlist/components/types.ts +35 -0
- package/src/ktr/template/bilibili/userlist/index.tsx +11 -0
- package/src/ktr/template/bilibili/videoInfo/components/types.ts +28 -0
- package/src/ktr/template/bilibili/videoInfo/components/videoInfo.tsx +217 -0
- package/src/ktr/template/bilibili/videoInfo/index.tsx +12 -0
- package/src/ktr/template/components/AmbientCover.tsx +50 -0
- package/src/ktr/template/components/DefaultLayout.tsx +166 -0
- package/src/ktr/template/components/GlowImage.tsx +572 -0
- package/src/ktr/template/components/QRCodeWithAvatar.tsx +52 -0
- package/src/ktr/template/components/RolldownLogo.tsx +110 -0
- package/src/ktr/template/components/ViteLogo.tsx +134 -0
- package/src/ktr/template/components/iconRegistry.ts +294 -0
- package/src/ktr/template/douyin/article-work/components/ArticleWork.tsx +301 -0
- package/src/ktr/template/douyin/article-work/components/types.ts +53 -0
- package/src/ktr/template/douyin/article-work/index.tsx +12 -0
- package/src/ktr/template/douyin/comment/components/Comment.tsx +612 -0
- package/src/ktr/template/douyin/comment/components/types.ts +85 -0
- package/src/ktr/template/douyin/comment/index.tsx +11 -0
- package/src/ktr/template/douyin/components/Icons.tsx +75 -0
- package/src/ktr/template/douyin/components/types.ts +83 -0
- package/src/ktr/template/douyin/dynamic/components/Dynamic.tsx +283 -0
- package/src/ktr/template/douyin/dynamic/components/types.ts +46 -0
- package/src/ktr/template/douyin/dynamic/index.tsx +11 -0
- package/src/ktr/template/douyin/favorite-list/components/FavoriteList.tsx +201 -0
- package/src/ktr/template/douyin/favorite-list/components/types.ts +38 -0
- package/src/ktr/template/douyin/favorite-list/index.tsx +12 -0
- package/src/ktr/template/douyin/image-work/components/ImageWork.tsx +437 -0
- package/src/ktr/template/douyin/image-work/components/types.ts +78 -0
- package/src/ktr/template/douyin/image-work/index.tsx +11 -0
- package/src/ktr/template/douyin/live/components/Live.tsx +229 -0
- package/src/ktr/template/douyin/live/components/types.ts +47 -0
- package/src/ktr/template/douyin/live/index.tsx +11 -0
- package/src/ktr/template/douyin/musicinfo/components/MusicInfo.tsx +187 -0
- package/src/ktr/template/douyin/musicinfo/components/types.ts +31 -0
- package/src/ktr/template/douyin/musicinfo/index.tsx +11 -0
- package/src/ktr/template/douyin/qrcodeImg/components/qrcodeImg.tsx +170 -0
- package/src/ktr/template/douyin/qrcodeImg/components/types.ts +9 -0
- package/src/ktr/template/douyin/qrcodeImg/index.tsx +9 -0
- package/src/ktr/template/douyin/recommend-list/components/RecommendList.tsx +201 -0
- package/src/ktr/template/douyin/recommend-list/components/types.ts +37 -0
- package/src/ktr/template/douyin/recommend-list/index.tsx +12 -0
- package/src/ktr/template/douyin/user_profile/components/UserVideoList.tsx +225 -0
- package/src/ktr/template/douyin/user_profile/components/types.ts +71 -0
- package/src/ktr/template/douyin/user_profile/index.tsx +9 -0
- package/src/ktr/template/douyin/userlist/components/UserList.tsx +229 -0
- package/src/ktr/template/douyin/userlist/components/types.ts +35 -0
- package/src/ktr/template/douyin/userlist/index.tsx +11 -0
- package/src/ktr/template/douyin/video-work/components/VideoWork.tsx +398 -0
- package/src/ktr/template/douyin/video-work/components/types.ts +80 -0
- package/src/ktr/template/douyin/video-work/index.tsx +11 -0
- package/src/ktr/template/font.css +6071 -0
- package/src/ktr/template/global.d.ts +69 -0
- package/src/ktr/template/kuaishou/comment/components/Comment.tsx +207 -0
- package/src/ktr/template/kuaishou/comment/components/types.ts +47 -0
- package/src/ktr/template/kuaishou/comment/index.tsx +11 -0
- package/src/ktr/template/other/changelog/components/changelog.tsx +411 -0
- package/src/ktr/template/other/changelog/components/types.ts +21 -0
- package/src/ktr/template/other/changelog/index.tsx +9 -0
- package/src/ktr/template/other/handlerError/components/errorTitles.ts +224 -0
- package/src/ktr/template/other/handlerError/components/handlerError.tsx +1076 -0
- package/src/ktr/template/other/handlerError/components/stackHighlight.ts +127 -0
- package/src/ktr/template/other/handlerError/components/types.ts +124 -0
- package/src/ktr/template/other/handlerError/index.tsx +9 -0
- package/src/ktr/template/other/help/components/Help.tsx +249 -0
- package/src/ktr/template/other/help/components/types.ts +47 -0
- package/src/ktr/template/other/help/index.tsx +9 -0
- package/src/ktr/template/other/live-photo-tip/components/LivePhotoTip.tsx +295 -0
- package/src/ktr/template/other/live-photo-tip/components/types.ts +8 -0
- package/src/ktr/template/other/live-photo-tip/index.tsx +9 -0
- package/src/ktr/template/other/qrlogin/components/qrlogin.tsx +295 -0
- package/src/ktr/template/other/qrlogin/components/types.ts +11 -0
- package/src/ktr/template/other/qrlogin/index.tsx +9 -0
- package/src/ktr/template/other/runtime/components/runtime.tsx +347 -0
- package/src/ktr/template/other/runtime/components/types.ts +75 -0
- package/src/ktr/template/other/runtime/index.tsx +9 -0
- package/src/ktr/template/other/version_warning/components/VersionWarning.tsx +392 -0
- package/src/ktr/template/other/version_warning/components/types.ts +8 -0
- package/src/ktr/template/other/version_warning/index.tsx +9 -0
- package/src/ktr/template/statistics/components/BoxplotGuide.tsx +57 -0
- package/src/ktr/template/statistics/components/ChartCard.tsx +40 -0
- package/src/ktr/template/statistics/components/KpiCard.tsx +39 -0
- package/src/ktr/template/statistics/components/PlatformTable.tsx +83 -0
- package/src/ktr/template/statistics/components/RankList.tsx +127 -0
- package/src/ktr/template/statistics/components/SSRChart.tsx +41 -0
- package/src/ktr/template/statistics/components/chartPresets.ts +700 -0
- package/src/ktr/template/statistics/components/chartTheme.ts +234 -0
- package/src/ktr/template/statistics/components/format.ts +33 -0
- package/src/ktr/template/statistics/components/types.ts +92 -0
- package/src/ktr/template/statistics/global/components/GlobalStatistics.tsx +597 -0
- package/src/ktr/template/statistics/global/components/types.ts +138 -0
- package/src/ktr/template/statistics/global/index.tsx +9 -0
- package/src/ktr/template/statistics/group/components/GroupStatistics.tsx +468 -0
- package/src/ktr/template/statistics/group/components/types.ts +113 -0
- package/src/ktr/template/statistics/group/index.tsx +9 -0
- package/src/ktr/template/style.css +65 -0
- package/src/ktr/template/types/ctx.ts +42 -0
- package/src/ktr/template/xiaohongshu/comment/components/Comment.tsx +264 -0
- package/src/ktr/template/xiaohongshu/comment/components/types.ts +119 -0
- package/src/ktr/template/xiaohongshu/comment/index.tsx +9 -0
- package/src/ktr/template/xiaohongshu/noteInfo/components/noteInfo.tsx +271 -0
- package/src/ktr/template/xiaohongshu/noteInfo/components/types.ts +66 -0
- package/src/ktr/template/xiaohongshu/noteInfo/index.tsx +9 -0
- package/src/ktr/utils/QRCodeAvatar.ts +102 -0
- package/src/ktr/utils/QRcode.ts +65 -0
- package/src/ktr/utils/avatarProxy.ts +42 -0
- package/src/ktr/utils/cn.ts +6 -0
- package/src/ktr/utils/theme.ts +10 -0
- package/src/qqFields.json +75 -0
- package/src/qqOptions.ts +64 -0
- package/src/richtext/index.ts +9 -0
- package/src/richtext/parse/index.ts +271 -0
- package/src/richtext/react/cn.ts +6 -0
- package/src/richtext/react/index.tsx +582 -0
- package/src/richtext/types.ts +320 -0
- package/src/schema.ts +372 -0
- package/src/webui.ts +352 -0
|
@@ -0,0 +1,1397 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.Bilibilipush = void 0;
|
|
40
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
41
|
+
const amagi_1 = require("@ikenxuan/amagi");
|
|
42
|
+
const node_karin_1 = __importStar(require("../../../compat/node-karin.js"));
|
|
43
|
+
const module_1 = require("../../module");
|
|
44
|
+
const amagiClient_1 = require("../../module/utils/amagiClient");
|
|
45
|
+
const Config_1 = require("../../module/utils/Config");
|
|
46
|
+
const bilibili_1 = require("../../platform/bilibili");
|
|
47
|
+
const dynamic_text_1 = require("../../platform/bilibili/dynamic-text");
|
|
48
|
+
const live_status_1 = require("../../platform/bilibili/live-status");
|
|
49
|
+
/** BilibiliPushType 到 DynamicType 的映射 */
|
|
50
|
+
const pushTypeToDynamicType = {
|
|
51
|
+
video: amagi_1.DynamicType.AV,
|
|
52
|
+
draw: amagi_1.DynamicType.DRAW,
|
|
53
|
+
word: amagi_1.DynamicType.WORD,
|
|
54
|
+
live: amagi_1.DynamicType.LIVE_RCMD,
|
|
55
|
+
forward: amagi_1.DynamicType.FORWARD,
|
|
56
|
+
article: amagi_1.DynamicType.ARTICLE
|
|
57
|
+
};
|
|
58
|
+
/** 所有支持的 BilibiliPushType */
|
|
59
|
+
const allBilibiliPushTypes = ['video', 'draw', 'word', 'live', 'forward', 'article'];
|
|
60
|
+
const bilibiliBaseHeaders = {
|
|
61
|
+
...module_1.baseHeaders,
|
|
62
|
+
Referer: 'https://www.bilibili.com',
|
|
63
|
+
Cookie: Config_1.Config.amagi.cookies.bilibili
|
|
64
|
+
};
|
|
65
|
+
class Bilibilipush extends module_1.Base {
|
|
66
|
+
force = false;
|
|
67
|
+
constructor(e = {}, force = false) {
|
|
68
|
+
super(e);
|
|
69
|
+
this.force = force;
|
|
70
|
+
}
|
|
71
|
+
injectBotToEventForRender(targets) {
|
|
72
|
+
const targetBotId = targets.find((item) => item.botId)?.botId;
|
|
73
|
+
if (!targetBotId)
|
|
74
|
+
return;
|
|
75
|
+
const bot = node_karin_1.default.getBot(targetBotId);
|
|
76
|
+
if (!bot)
|
|
77
|
+
return;
|
|
78
|
+
const eventWithBot = this.e;
|
|
79
|
+
eventWithBot.bot = bot;
|
|
80
|
+
eventWithBot.selfId = eventWithBot.selfId ?? targetBotId;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* 检查并补全配置文件中缺失的字段
|
|
84
|
+
* @param pushList 推送配置列表
|
|
85
|
+
*/
|
|
86
|
+
ensureConfigFields(pushList) {
|
|
87
|
+
if (!pushList || pushList.length === 0)
|
|
88
|
+
return;
|
|
89
|
+
let hasChanges = false;
|
|
90
|
+
for (const item of pushList) {
|
|
91
|
+
// 检查并补全 pushTypes 字段
|
|
92
|
+
if (!item.pushTypes?.length) {
|
|
93
|
+
item.pushTypes = [...allBilibiliPushTypes];
|
|
94
|
+
hasChanges = true;
|
|
95
|
+
node_karin_1.logger.info(`[koishi-plugin-kkk][v2.28.0] 为UP主 ${item.remark ?? item.host_mid} 自动补全推送类型:投稿视频、图文动态、纯文动态、直播动态、转发动态、投稿专栏`);
|
|
96
|
+
}
|
|
97
|
+
// 检查并补全 switch 字段
|
|
98
|
+
if (item.switch === undefined) {
|
|
99
|
+
item.switch = true;
|
|
100
|
+
hasChanges = true;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
// 如果有修改,保存到配置文件
|
|
104
|
+
if (hasChanges) {
|
|
105
|
+
Config_1.Config.Modify('pushlist', 'bilibili', pushList);
|
|
106
|
+
node_karin_1.logger.info('已自动补全B站推送配置文件中缺失的字段并保存');
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* 执行主要的操作流程
|
|
111
|
+
*/
|
|
112
|
+
async action() {
|
|
113
|
+
await this.syncConfigToDatabase();
|
|
114
|
+
// 检查并补全配置文件中缺失的字段
|
|
115
|
+
this.ensureConfigFields(Config_1.Config.pushlist.bilibili);
|
|
116
|
+
// 清理旧的动态缓存记录
|
|
117
|
+
const deletedCount = await (0, module_1.cleanOldDynamicCache)('bilibili');
|
|
118
|
+
if (deletedCount > 0) {
|
|
119
|
+
node_karin_1.logger.info(`已清理 ${deletedCount} 条过期的B站动态缓存记录`);
|
|
120
|
+
}
|
|
121
|
+
// 获取已注册的 bot 列表,过滤未注册的 bot
|
|
122
|
+
const registeredBotIds = node_karin_1.default.getAllBotID();
|
|
123
|
+
const filteredPushList = this.filterPushListByRegisteredBots(Config_1.Config.pushlist.bilibili, registeredBotIds);
|
|
124
|
+
if (filteredPushList.length === 0) {
|
|
125
|
+
// 推送列表本来就是空的属正常情况,别刷 warn(用户反馈日志一直被它刷屏)
|
|
126
|
+
if (Config_1.Config.pushlist.bilibili?.length) {
|
|
127
|
+
node_karin_1.logger.warn('推送列表里的机器人都不在线,本次跳过B站推送');
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
node_karin_1.logger.debug('B站推送列表为空,跳过');
|
|
131
|
+
}
|
|
132
|
+
return true;
|
|
133
|
+
}
|
|
134
|
+
const data = await this.getDynamicList(filteredPushList);
|
|
135
|
+
const pushdata = await this.excludeAlreadyPushed(data.willbepushlist);
|
|
136
|
+
if (Object.keys(pushdata).length === 0)
|
|
137
|
+
return true;
|
|
138
|
+
if (this.force) {
|
|
139
|
+
return await this.forcepush(pushdata);
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
return await this.getdata(pushdata);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* 根据已注册的 bot 列表过滤推送配置
|
|
147
|
+
* @param pushList 原始推送配置列表
|
|
148
|
+
* @param registeredBotIds 已注册的 bot ID 列表
|
|
149
|
+
* @returns 过滤后的推送配置列表
|
|
150
|
+
*/
|
|
151
|
+
filterPushListByRegisteredBots(pushList, registeredBotIds) {
|
|
152
|
+
if (!pushList || pushList.length === 0)
|
|
153
|
+
return [];
|
|
154
|
+
const registeredSet = new Set(registeredBotIds);
|
|
155
|
+
const filteredList = [];
|
|
156
|
+
for (const item of pushList) {
|
|
157
|
+
// 过滤 group_id 中未注册的 bot
|
|
158
|
+
const filteredGroupIds = item.group_id.filter((groupWithBot) => {
|
|
159
|
+
const botId = groupWithBot.split(':')[1];
|
|
160
|
+
const isRegistered = registeredSet.has(botId);
|
|
161
|
+
if (!isRegistered) {
|
|
162
|
+
node_karin_1.logger.debug(`Bot ${botId} 未注册,跳过群组 ${groupWithBot.split(':')[0]} 的推送`);
|
|
163
|
+
}
|
|
164
|
+
return isRegistered;
|
|
165
|
+
});
|
|
166
|
+
// 如果过滤后还有有效的群组,则保留该订阅项
|
|
167
|
+
if (filteredGroupIds.length > 0) {
|
|
168
|
+
filteredList.push({
|
|
169
|
+
...item,
|
|
170
|
+
group_id: filteredGroupIds
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
node_karin_1.logger.debug(`UP主 ${item.remark ?? item.host_mid} 的所有推送目标 bot 均未注册,跳过`);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return filteredList;
|
|
178
|
+
}
|
|
179
|
+
/** 将 UID 直播状态接口的结果接入原有动态推送列表。 */
|
|
180
|
+
async getDirectLivePushItems(userList) {
|
|
181
|
+
const handledUids = new Set();
|
|
182
|
+
const willBePushList = {};
|
|
183
|
+
const liveSubscriptions = userList.filter((item) => item.switch !== false && (item.pushTypes || allBilibiliPushTypes).includes('live'));
|
|
184
|
+
for (const item of liveSubscriptions) {
|
|
185
|
+
let liveStatus;
|
|
186
|
+
try {
|
|
187
|
+
const liveStatusResult = await this.amagi.bilibili.fetcher.fetchUserLiveStatus({
|
|
188
|
+
host_mid: item.host_mid
|
|
189
|
+
});
|
|
190
|
+
liveStatus = liveStatusResult.data.data;
|
|
191
|
+
}
|
|
192
|
+
catch (error) {
|
|
193
|
+
node_karin_1.logger.warn(`[Bilibili 推送] UP主 ${item.remark}(${item.host_mid})直播状态直查失败,本轮停止直查并让剩余订阅回退到直播动态检测:${formatErrorMessage(error)}`);
|
|
194
|
+
break;
|
|
195
|
+
}
|
|
196
|
+
if (liveStatus.roomStatus !== 1 || liveStatus.liveStatus !== 1 || liveStatus.roomid <= 0) {
|
|
197
|
+
handledUids.add(item.host_mid);
|
|
198
|
+
continue;
|
|
199
|
+
}
|
|
200
|
+
try {
|
|
201
|
+
const liveInfoResult = await this.amagi.bilibili.fetcher.fetchLiveRoomInfo({
|
|
202
|
+
room_id: String(liveStatus.roomid)
|
|
203
|
+
});
|
|
204
|
+
const liveInfo = liveInfoResult.data.data;
|
|
205
|
+
/** 两个直播接口状态不一致时,以直播间详情为准。 */
|
|
206
|
+
if (liveInfo.live_status !== 1) {
|
|
207
|
+
handledUids.add(item.host_mid);
|
|
208
|
+
continue;
|
|
209
|
+
}
|
|
210
|
+
const sessionId = (0, live_status_1.buildBilibiliLiveSessionId)(item.host_mid, liveInfo.room_id, liveInfo.live_time);
|
|
211
|
+
const liveStartedAt = (0, live_status_1.parseBilibiliLiveStartedAt)(liveInfo.live_time);
|
|
212
|
+
if (!sessionId || !liveStartedAt) {
|
|
213
|
+
throw new Error(`直播间 ${liveInfo.room_id} 未返回可用于场次去重的开播时间`);
|
|
214
|
+
}
|
|
215
|
+
const dynamic = createLiveDynamicItem(sessionId, liveStartedAt, liveInfo, liveStatus);
|
|
216
|
+
willBePushList[sessionId] = {
|
|
217
|
+
remark: item.remark,
|
|
218
|
+
host_mid: item.host_mid,
|
|
219
|
+
create_time: dynamic.modules.module_author.pub_ts,
|
|
220
|
+
targets: item.group_id.map((groupWithBot) => {
|
|
221
|
+
const [groupId, botId] = groupWithBot.split(':');
|
|
222
|
+
return { groupId, botId };
|
|
223
|
+
}),
|
|
224
|
+
Dynamic_Data: dynamic,
|
|
225
|
+
avatar_img: '',
|
|
226
|
+
dynamic_type: amagi_1.DynamicType.LIVE_RCMD
|
|
227
|
+
};
|
|
228
|
+
handledUids.add(item.host_mid);
|
|
229
|
+
}
|
|
230
|
+
catch (error) {
|
|
231
|
+
node_karin_1.logger.warn(`[Bilibili 推送] UP主 ${item.remark}(${item.host_mid})直播场次信息不完整,本轮回退到直播动态检测:${formatErrorMessage(error)}`);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
return { handledUids, willBePushList };
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* 为降级路径中的直播动态解析与直查路径一致的场次缓存键。
|
|
238
|
+
*
|
|
239
|
+
* @param dynamic B站空间动态中的直播推荐项。
|
|
240
|
+
* @param hostMid UP 主 UID。
|
|
241
|
+
* @returns 可用时返回直播场次键,否则退回原始动态ID。
|
|
242
|
+
*/
|
|
243
|
+
async resolveLiveDynamicCacheId(dynamic, hostMid) {
|
|
244
|
+
try {
|
|
245
|
+
const liveData = JSON.parse(dynamic.modules.module_dynamic.major.live_rcmd.content);
|
|
246
|
+
const roomId = Number(liveData.live_play_info.room_id);
|
|
247
|
+
const liveInfo = await this.amagi.bilibili.fetcher.fetchLiveRoomInfo({
|
|
248
|
+
room_id: String(roomId)
|
|
249
|
+
});
|
|
250
|
+
const cacheId = (0, live_status_1.buildBilibiliLiveSessionId)(hostMid, liveInfo.data.data.room_id, liveInfo.data.data.live_time);
|
|
251
|
+
return cacheId || dynamic.id_str;
|
|
252
|
+
}
|
|
253
|
+
catch (error) {
|
|
254
|
+
node_karin_1.logger.warn(`[Bilibili 推送] 直播动态 ${dynamic.id_str} 无法解析统一场次键,将使用动态ID去重:${formatErrorMessage(error)}`);
|
|
255
|
+
return dynamic.id_str;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* 同步配置文件中的订阅信息到数据库
|
|
260
|
+
*/
|
|
261
|
+
async syncConfigToDatabase() {
|
|
262
|
+
// 如果配置文件中没有B站推送列表,直接返回
|
|
263
|
+
if (!Config_1.Config.pushlist.bilibili || Config_1.Config.pushlist.bilibili.length === 0) {
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
await module_1.bilibiliDB.syncConfigSubscriptions(Config_1.Config.pushlist.bilibili);
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* 异步获取数据并根据动态类型处理和发送动态信息。
|
|
270
|
+
* @param data 包含动态相关信息的对象。
|
|
271
|
+
*/
|
|
272
|
+
async getdata(data) {
|
|
273
|
+
for (const dynamicId in data) {
|
|
274
|
+
node_karin_1.logger.mark(`
|
|
275
|
+
${node_karin_1.logger.blue('开始处理并渲染B站动态图片')}
|
|
276
|
+
${node_karin_1.logger.cyan('UP')}: ${node_karin_1.logger.green(data[dynamicId].remark)}
|
|
277
|
+
${node_karin_1.logger.cyan('动态id')}:${node_karin_1.logger.yellow(dynamicId)}
|
|
278
|
+
${node_karin_1.logger.cyan('访问地址')}:${node_karin_1.logger.green('https://t.bilibili.com/' + dynamicId)}`);
|
|
279
|
+
let skip = await skipDynamic(data[dynamicId]);
|
|
280
|
+
if (skip) {
|
|
281
|
+
node_karin_1.logger.warn(`动态 https://t.bilibili.com/${dynamicId} 已被处理,跳过`);
|
|
282
|
+
}
|
|
283
|
+
let send_video = true;
|
|
284
|
+
let img = [];
|
|
285
|
+
let articleForwardPayload = null;
|
|
286
|
+
this.injectBotToEventForRender(data[dynamicId].targets);
|
|
287
|
+
if (!skip) {
|
|
288
|
+
const userINFO = await this.amagi.bilibili.fetcher.fetchUserCard({
|
|
289
|
+
host_mid: data[dynamicId].host_mid
|
|
290
|
+
});
|
|
291
|
+
switch (data[dynamicId].dynamic_type) {
|
|
292
|
+
/** 处理图文动态 */
|
|
293
|
+
case amagi_1.DynamicType.DRAW: {
|
|
294
|
+
if (data[dynamicId].Dynamic_Data.modules.module_dynamic.topic !== null &&
|
|
295
|
+
data[dynamicId].Dynamic_Data.modules.module_dynamic &&
|
|
296
|
+
data[dynamicId].Dynamic_Data.modules.module_dynamic.topic !== null) {
|
|
297
|
+
const name = data[dynamicId].Dynamic_Data.modules.module_dynamic.topic.name;
|
|
298
|
+
data[dynamicId].Dynamic_Data.modules.module_dynamic.major?.opus.summary.rich_text_nodes.unshift({
|
|
299
|
+
orig_text: name,
|
|
300
|
+
text: name,
|
|
301
|
+
type: 'topic',
|
|
302
|
+
rid: data[dynamicId].Dynamic_Data.modules.module_dynamic.topic.id.toString()
|
|
303
|
+
});
|
|
304
|
+
data[dynamicId].Dynamic_Data.modules.module_dynamic.major.opus.summary.text =
|
|
305
|
+
`${name}\n\n` + data[dynamicId].Dynamic_Data.modules.module_dynamic.major?.opus?.summary?.text;
|
|
306
|
+
}
|
|
307
|
+
img = await (0, module_1.Render)(this.e, 'bilibili/dynamic/DYNAMIC_TYPE_DRAW', {
|
|
308
|
+
image_url: Object.values(data[dynamicId].Dynamic_Data.modules.module_dynamic.major?.opus?.pics ?? [])
|
|
309
|
+
.filter((item) => typeof item?.url === 'string')
|
|
310
|
+
.map((item) => ({ image_src: item.url })),
|
|
311
|
+
title: data[dynamicId].Dynamic_Data.modules.module_dynamic.major?.opus?.title ?? undefined,
|
|
312
|
+
text: (0, dynamic_text_1.buildBilibiliDynamicRichText)(data[dynamicId].Dynamic_Data.modules.module_dynamic.major?.opus?.summary?.text ?? '', data[dynamicId].Dynamic_Data.modules.module_dynamic.major?.opus?.summary?.rich_text_nodes ?? []),
|
|
313
|
+
dianzan: (0, module_1.Count)(data[dynamicId].Dynamic_Data.modules.module_stat.like.count),
|
|
314
|
+
pinglun: (0, module_1.Count)(data[dynamicId].Dynamic_Data.modules.module_stat.comment.count),
|
|
315
|
+
share: (0, module_1.Count)(data[dynamicId].Dynamic_Data.modules.module_stat.forward.count),
|
|
316
|
+
create_time: bilibili_1.TimeFormatter.toDateTime(data[dynamicId].Dynamic_Data.modules.module_author.pub_ts),
|
|
317
|
+
avatar_url: data[dynamicId].Dynamic_Data.modules.module_author.face,
|
|
318
|
+
frame: data[dynamicId].Dynamic_Data.modules.module_author.pendant.image,
|
|
319
|
+
share_url: 'https://t.bilibili.com/' + data[dynamicId].Dynamic_Data.id_str,
|
|
320
|
+
usernameMeta: (0, dynamic_text_1.getUsernameMetadata)(userINFO.data.data.card),
|
|
321
|
+
fans: (0, module_1.Count)(userINFO.data.data.follower),
|
|
322
|
+
user_shortid: data[dynamicId].host_mid,
|
|
323
|
+
total_favorited: (0, module_1.Count)(userINFO.data.data.like_num),
|
|
324
|
+
following_count: (0, module_1.Count)(userINFO.data.data.card.attention),
|
|
325
|
+
decoration_card: (0, bilibili_1.generateDecorationCard)(data[dynamicId].Dynamic_Data.modules.module_author.decorate_card),
|
|
326
|
+
render_time: bilibili_1.TimeFormatter.now(),
|
|
327
|
+
imageLayout: Config_1.Config.bilibili.imageLayout,
|
|
328
|
+
additional: (0, bilibili_1.parseAdditionalCard)(data[dynamicId].Dynamic_Data.modules.module_dynamic.additional),
|
|
329
|
+
dynamicTYPE: '图文动态推送',
|
|
330
|
+
dynamic_id: dynamicId
|
|
331
|
+
});
|
|
332
|
+
break;
|
|
333
|
+
}
|
|
334
|
+
/** 处理纯文动态 */
|
|
335
|
+
case amagi_1.DynamicType.WORD: {
|
|
336
|
+
// 处理话题
|
|
337
|
+
// Koishi 移植修正:原实现这里读的是 `Dynamic_Data.orig.modules...`,
|
|
338
|
+
// 但纯文动态没有 orig(那是转发动态才有的字段),一旦命中就抛
|
|
339
|
+
// "Cannot read properties of undefined (reading 'modules')"。
|
|
340
|
+
// 按原意改为检查主动态自身的话题结构。
|
|
341
|
+
if (data[dynamicId].Dynamic_Data.modules.module_dynamic.topic != null &&
|
|
342
|
+
data[dynamicId].Dynamic_Data.modules.module_dynamic.major?.opus?.summary != null) {
|
|
343
|
+
const md = data[dynamicId].Dynamic_Data.modules.module_dynamic;
|
|
344
|
+
const { name } = md.topic;
|
|
345
|
+
const summary = md.major.opus.summary;
|
|
346
|
+
summary.rich_text_nodes ??= [];
|
|
347
|
+
summary.rich_text_nodes.unshift({
|
|
348
|
+
orig_text: name,
|
|
349
|
+
text: name,
|
|
350
|
+
type: 'topic',
|
|
351
|
+
rid: md.topic.id.toString()
|
|
352
|
+
});
|
|
353
|
+
summary.text = summary.text ? `${name}\n\n${summary.text}` : name;
|
|
354
|
+
}
|
|
355
|
+
const text = (0, dynamic_text_1.buildBilibiliDynamicRichText)(data[dynamicId].Dynamic_Data.modules.module_dynamic.major?.opus?.summary?.text ?? '', data[dynamicId].Dynamic_Data.modules.module_dynamic.major?.opus?.summary?.rich_text_nodes ?? []);
|
|
356
|
+
img = await (0, module_1.Render)(this.e, 'bilibili/dynamic/DYNAMIC_TYPE_WORD', {
|
|
357
|
+
text,
|
|
358
|
+
dianzan: (0, module_1.Count)(data[dynamicId].Dynamic_Data.modules.module_stat.like.count),
|
|
359
|
+
pinglun: (0, module_1.Count)(data[dynamicId].Dynamic_Data.modules.module_stat.comment.count),
|
|
360
|
+
share: (0, module_1.Count)(data[dynamicId].Dynamic_Data.modules.module_stat.forward.count),
|
|
361
|
+
create_time: bilibili_1.TimeFormatter.toDateTime(data[dynamicId].Dynamic_Data.modules.module_author.pub_ts),
|
|
362
|
+
avatar_url: data[dynamicId].Dynamic_Data.modules.module_author.face,
|
|
363
|
+
frame: data[dynamicId].Dynamic_Data.modules.module_author.pendant.image,
|
|
364
|
+
share_url: 'https://t.bilibili.com/' + data[dynamicId].Dynamic_Data.id_str,
|
|
365
|
+
usernameMeta: (0, dynamic_text_1.getUsernameMetadata)(userINFO.data.data.card),
|
|
366
|
+
fans: (0, module_1.Count)(userINFO.data.data.follower),
|
|
367
|
+
user_shortid: data[dynamicId].host_mid,
|
|
368
|
+
total_favorited: (0, module_1.Count)(userINFO.data.data.like_num),
|
|
369
|
+
following_count: (0, module_1.Count)(userINFO.data.data.card.attention),
|
|
370
|
+
decoration_card: (0, bilibili_1.generateDecorationCard)(data[dynamicId].Dynamic_Data.modules.module_author.decorate_card),
|
|
371
|
+
render_time: bilibili_1.TimeFormatter.now(),
|
|
372
|
+
additional: (0, bilibili_1.parseAdditionalCard)(data[dynamicId].Dynamic_Data.modules.module_dynamic.additional),
|
|
373
|
+
dynamicTYPE: '纯文动态推送',
|
|
374
|
+
dynamic_id: dynamicId
|
|
375
|
+
});
|
|
376
|
+
break;
|
|
377
|
+
}
|
|
378
|
+
/** 处理视频动态 */
|
|
379
|
+
case amagi_1.DynamicType.AV: {
|
|
380
|
+
if (data[dynamicId].Dynamic_Data.modules.module_dynamic.major?.type === 'MAJOR_TYPE_ARCHIVE') {
|
|
381
|
+
const bvid = data[dynamicId].Dynamic_Data?.modules.module_dynamic.major?.archive?.bvid ?? '';
|
|
382
|
+
const INFODATA = await amagiClient_1.bilibiliFetcher.fetchVideoInfo({ bvid });
|
|
383
|
+
/** 特殊字段,只有番剧和影视才会有,如果是该类型视频,默认不发送 */
|
|
384
|
+
if (INFODATA.data.data.redirect_url) {
|
|
385
|
+
send_video = false;
|
|
386
|
+
node_karin_1.logger.debug(`UP主:${INFODATA.data.data.owner.name} 的该动态类型为${node_karin_1.logger.yellow('番剧或影视')},默认跳过不下载,直达:${node_karin_1.logger.green(INFODATA.data.data.redirect_url)}`);
|
|
387
|
+
}
|
|
388
|
+
else {
|
|
389
|
+
// const noCkData = await getBilibiliData('单个视频下载信息数据', { avid: Number(aid), cid: INFODATA.data.data.cid })
|
|
390
|
+
}
|
|
391
|
+
// 处理共创者信息
|
|
392
|
+
let staff = undefined;
|
|
393
|
+
if (INFODATA.data.data.staff && Array.isArray(INFODATA.data.data.staff)) {
|
|
394
|
+
const currentMid = data[dynamicId].host_mid;
|
|
395
|
+
// 提取共创者信息
|
|
396
|
+
staff = INFODATA.data.data.staff.map((member) => ({
|
|
397
|
+
mid: member.mid,
|
|
398
|
+
title: member.title,
|
|
399
|
+
name: member.name,
|
|
400
|
+
face: member.face,
|
|
401
|
+
follower: member.follower
|
|
402
|
+
}));
|
|
403
|
+
// 如果当前动态发布者是共创者之一,将其排到最前面
|
|
404
|
+
const currentUserIndex = staff.findIndex((member) => member.mid === currentMid);
|
|
405
|
+
if (currentUserIndex > 0) {
|
|
406
|
+
const currentUser = staff.splice(currentUserIndex, 1)[0];
|
|
407
|
+
staff.unshift(currentUser);
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
// 处理话题
|
|
411
|
+
const md = data[dynamicId].Dynamic_Data.modules.module_dynamic;
|
|
412
|
+
if (md.topic) {
|
|
413
|
+
const { name } = md.topic;
|
|
414
|
+
md.desc ??= { rich_text_nodes: [], text: '' };
|
|
415
|
+
md.desc.rich_text_nodes.unshift({ orig_text: name, jump_url: '', text: name, type: 'topic' });
|
|
416
|
+
md.desc.text = md.desc.text ? `${name}\n\n${md.desc.text}` : name;
|
|
417
|
+
}
|
|
418
|
+
const dynamicText = (0, dynamic_text_1.buildBilibiliDynamicRichText)(data[dynamicId].Dynamic_Data.modules.module_dynamic.desc?.text ?? '', data[dynamicId].Dynamic_Data.modules.module_dynamic.desc?.rich_text_nodes ?? []);
|
|
419
|
+
img = await (0, module_1.Render)(this.e, 'bilibili/dynamic/DYNAMIC_TYPE_AV', {
|
|
420
|
+
image_url: INFODATA.data.data.pic,
|
|
421
|
+
text: (0, dynamic_text_1.buildBilibiliDynamicRichText)(INFODATA.data.data.title, []),
|
|
422
|
+
desc: INFODATA.data.data.desc_v2?.length
|
|
423
|
+
? (0, dynamic_text_1.buildBilibiliVideoDescRichText)(INFODATA.data.data.desc_v2)
|
|
424
|
+
: (0, dynamic_text_1.buildBilibiliDynamicRichText)(INFODATA.data.data.desc || '', []),
|
|
425
|
+
dynamic_text: dynamicText,
|
|
426
|
+
dianzan: (0, module_1.Count)(INFODATA.data.data.stat.like),
|
|
427
|
+
pinglun: (0, module_1.Count)(INFODATA.data.data.stat.reply),
|
|
428
|
+
share: (0, module_1.Count)(INFODATA.data.data.stat.share),
|
|
429
|
+
view: (0, module_1.Count)(INFODATA.data.data.stat.view),
|
|
430
|
+
coin: (0, module_1.Count)(INFODATA.data.data.stat.coin),
|
|
431
|
+
duration_text: data[dynamicId].Dynamic_Data.modules.module_dynamic.major?.archive?.duration_text ?? '0:00',
|
|
432
|
+
page_length: INFODATA.data.data.pages.length,
|
|
433
|
+
create_time: bilibili_1.TimeFormatter.toDateTime(data[dynamicId].Dynamic_Data.modules.module_author.pub_ts),
|
|
434
|
+
avatar_url: userINFO.data.data.card.face,
|
|
435
|
+
frame: data[dynamicId].Dynamic_Data.modules.module_author.pendant.image,
|
|
436
|
+
share_url: 'https://www.bilibili.com/video/' + bvid,
|
|
437
|
+
usernameMeta: (0, dynamic_text_1.getUsernameMetadata)(userINFO.data.data.card),
|
|
438
|
+
fans: (0, module_1.Count)(userINFO.data.data.follower),
|
|
439
|
+
user_shortid: data[dynamicId].host_mid,
|
|
440
|
+
total_favorited: (0, module_1.Count)(userINFO.data.data.like_num),
|
|
441
|
+
following_count: (0, module_1.Count)(userINFO.data.data.card.attention),
|
|
442
|
+
render_time: bilibili_1.TimeFormatter.now(),
|
|
443
|
+
dynamicTYPE: '视频动态推送',
|
|
444
|
+
dynamic_id: dynamicId,
|
|
445
|
+
staff
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
break;
|
|
449
|
+
}
|
|
450
|
+
/** 处理直播动态 */
|
|
451
|
+
case amagi_1.DynamicType.LIVE_RCMD: {
|
|
452
|
+
const liveInfo = JSON.parse(data[dynamicId].Dynamic_Data.modules.module_dynamic.major.live_rcmd.content);
|
|
453
|
+
img = await (0, module_1.Render)(this.e, 'bilibili/dynamic/DYNAMIC_TYPE_LIVE_RCMD', {
|
|
454
|
+
image_url: liveInfo.live_play_info.cover,
|
|
455
|
+
text: (0, dynamic_text_1.buildBilibiliDynamicRichText)(liveInfo.live_play_info.title, []),
|
|
456
|
+
liveinf: br(`${liveInfo.live_play_info.area_name} | 房间号: ${liveInfo.live_play_info.room_id}`),
|
|
457
|
+
usernameMeta: (0, dynamic_text_1.getUsernameMetadata)(userINFO.data.data.card),
|
|
458
|
+
avatar_url: userINFO.data.data.card.face,
|
|
459
|
+
frame: data[dynamicId].Dynamic_Data.modules.module_author.pendant.image,
|
|
460
|
+
fans: (0, module_1.Count)(userINFO.data.data.follower),
|
|
461
|
+
create_time: bilibili_1.TimeFormatter.toDateTime(data[dynamicId].Dynamic_Data.modules.module_author.pub_ts),
|
|
462
|
+
now_time: bilibili_1.TimeFormatter.now(),
|
|
463
|
+
share_url: 'https://live.bilibili.com/' + liveInfo.live_play_info.room_id,
|
|
464
|
+
dynamicTYPE: '直播动态推送'
|
|
465
|
+
});
|
|
466
|
+
break;
|
|
467
|
+
}
|
|
468
|
+
/** 处理转发动态 */
|
|
469
|
+
case amagi_1.DynamicType.FORWARD: {
|
|
470
|
+
// 处理话题
|
|
471
|
+
const md = data[dynamicId].Dynamic_Data.modules.module_dynamic;
|
|
472
|
+
if (md.topic) {
|
|
473
|
+
const { name } = md.topic;
|
|
474
|
+
const desc = md.desc;
|
|
475
|
+
desc.rich_text_nodes ??= [];
|
|
476
|
+
desc.rich_text_nodes.unshift({ orig_text: name, jump_url: '', text: name, type: 'topic' });
|
|
477
|
+
desc.text = desc.text ? `${name}\n\n${desc.text}` : name;
|
|
478
|
+
}
|
|
479
|
+
const text = (0, dynamic_text_1.buildBilibiliDynamicRichText)(data[dynamicId].Dynamic_Data.modules.module_dynamic.desc.text, data[dynamicId].Dynamic_Data.modules.module_dynamic.desc.rich_text_nodes);
|
|
480
|
+
/** 富文本节点:查看图片 */
|
|
481
|
+
const imgList = [];
|
|
482
|
+
if (data[dynamicId].Dynamic_Data.modules.module_dynamic.desc) {
|
|
483
|
+
for (const richTxtItem of data[dynamicId].Dynamic_Data.modules.module_dynamic.desc.rich_text_nodes) {
|
|
484
|
+
if (richTxtItem.type === 'RICH_TEXT_NODE_TYPE_VIEW_PICTURE') {
|
|
485
|
+
for (const pic of richTxtItem.pics) {
|
|
486
|
+
imgList.push(pic.src);
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
let original_content = {};
|
|
492
|
+
switch (data[dynamicId].Dynamic_Data.orig.type) {
|
|
493
|
+
case amagi_1.DynamicType.AV: {
|
|
494
|
+
const desc = data[dynamicId].Dynamic_Data.orig.modules.module_dynamic?.desc || {
|
|
495
|
+
text: '',
|
|
496
|
+
rich_text_nodes: []
|
|
497
|
+
};
|
|
498
|
+
original_content = {
|
|
499
|
+
DYNAMIC_TYPE_AV: {
|
|
500
|
+
usernameMeta: (0, dynamic_text_1.getUsernameMetadata)(data[dynamicId].Dynamic_Data.orig.modules.module_author),
|
|
501
|
+
avatar_url: data[dynamicId].Dynamic_Data.orig.modules.module_author.face,
|
|
502
|
+
duration_text: data[dynamicId].Dynamic_Data.orig.modules.module_dynamic.major.archive?.duration_text,
|
|
503
|
+
text: (0, dynamic_text_1.buildBilibiliDynamicRichText)(desc.text, desc.rich_text_nodes),
|
|
504
|
+
title: (0, dynamic_text_1.buildBilibiliDynamicRichText)(data[dynamicId].Dynamic_Data.orig.modules.module_dynamic.major.archive?.title ?? '', []),
|
|
505
|
+
danmaku: data[dynamicId].Dynamic_Data.orig.modules.module_dynamic.major.archive?.stat.danmaku,
|
|
506
|
+
play: data[dynamicId].Dynamic_Data.orig.modules.module_dynamic.major.archive?.stat.play,
|
|
507
|
+
cover: data[dynamicId].Dynamic_Data.orig.modules.module_dynamic.major.archive?.cover,
|
|
508
|
+
create_time: bilibili_1.TimeFormatter.toDateTime(data[dynamicId].Dynamic_Data.orig.modules.module_author.pub_ts),
|
|
509
|
+
decoration_card: (0, bilibili_1.generateDecorationCard)(data[dynamicId].Dynamic_Data.orig.modules.module_author.decorate_card),
|
|
510
|
+
frame: data[dynamicId].Dynamic_Data.orig.modules.module_author.pendant.image
|
|
511
|
+
}
|
|
512
|
+
};
|
|
513
|
+
break;
|
|
514
|
+
}
|
|
515
|
+
case amagi_1.DynamicType.DRAW: {
|
|
516
|
+
// 处理话题
|
|
517
|
+
const origMd = data[dynamicId].Dynamic_Data.orig.modules.module_dynamic;
|
|
518
|
+
if (origMd.topic) {
|
|
519
|
+
const { name } = origMd.topic;
|
|
520
|
+
const summary = origMd.major?.opus?.summary;
|
|
521
|
+
if (summary) {
|
|
522
|
+
summary.rich_text_nodes ??= [];
|
|
523
|
+
summary.rich_text_nodes.unshift({
|
|
524
|
+
orig_text: name,
|
|
525
|
+
text: name,
|
|
526
|
+
type: 'topic',
|
|
527
|
+
rid: origMd.topic.id.toString(),
|
|
528
|
+
jump_url: '114514',
|
|
529
|
+
style: { '114514': '1919810' }
|
|
530
|
+
});
|
|
531
|
+
summary.text = summary.text ? `${name}\n${summary.text}` : name;
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
original_content = {
|
|
535
|
+
DYNAMIC_TYPE_DRAW: {
|
|
536
|
+
title: data[dynamicId].Dynamic_Data.orig.modules.module_dynamic.major?.opus?.title ?? undefined,
|
|
537
|
+
usernameMeta: (0, dynamic_text_1.getUsernameMetadata)(data[dynamicId].Dynamic_Data.orig.modules.module_author),
|
|
538
|
+
create_time: bilibili_1.TimeFormatter.toDateTime(data[dynamicId].Dynamic_Data.orig.modules.module_author.pub_ts),
|
|
539
|
+
avatar_url: data[dynamicId].Dynamic_Data.orig.modules.module_author.face,
|
|
540
|
+
text: (0, dynamic_text_1.buildBilibiliDynamicRichText)(data[dynamicId].Dynamic_Data.orig.modules.module_dynamic.major.opus.summary.text, data[dynamicId].Dynamic_Data.orig.modules.module_dynamic.major.opus.summary.rich_text_nodes),
|
|
541
|
+
image_url: Object.values(data[dynamicId].Dynamic_Data.orig.modules.module_dynamic.major.opus.pics)
|
|
542
|
+
.filter((item) => typeof item?.url === 'string')
|
|
543
|
+
.map((item) => ({ image_src: item.url })),
|
|
544
|
+
decoration_card: (0, bilibili_1.generateDecorationCard)(data[dynamicId].Dynamic_Data.orig.modules.module_author.decorate_card),
|
|
545
|
+
frame: data[dynamicId].Dynamic_Data.orig.modules.module_author.pendant.image
|
|
546
|
+
}
|
|
547
|
+
};
|
|
548
|
+
break;
|
|
549
|
+
}
|
|
550
|
+
case amagi_1.DynamicType.WORD: {
|
|
551
|
+
// 处理话题
|
|
552
|
+
const origMd = data[dynamicId].Dynamic_Data.orig.modules.module_dynamic;
|
|
553
|
+
if (origMd.topic) {
|
|
554
|
+
const { name } = origMd.topic;
|
|
555
|
+
const summary = origMd.major?.opus?.summary;
|
|
556
|
+
if (summary) {
|
|
557
|
+
summary.rich_text_nodes ??= [];
|
|
558
|
+
summary.rich_text_nodes.unshift({
|
|
559
|
+
orig_text: name,
|
|
560
|
+
text: name,
|
|
561
|
+
type: 'topic',
|
|
562
|
+
rid: origMd.topic.id.toString()
|
|
563
|
+
});
|
|
564
|
+
summary.text = summary.text ? `${name}\n${summary.text}` : name;
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
original_content = {
|
|
568
|
+
DYNAMIC_TYPE_WORD: {
|
|
569
|
+
usernameMeta: (0, dynamic_text_1.getUsernameMetadata)(data[dynamicId].Dynamic_Data.orig.modules.module_author),
|
|
570
|
+
create_time: bilibili_1.TimeFormatter.toDateTime(data[dynamicId].Dynamic_Data.orig.modules.module_author.pub_ts),
|
|
571
|
+
avatar_url: data[dynamicId].Dynamic_Data.orig.modules.module_author.face,
|
|
572
|
+
text: (0, dynamic_text_1.buildBilibiliDynamicRichText)(data[dynamicId].Dynamic_Data.orig.modules.module_dynamic.major.opus.summary.text, data[dynamicId].Dynamic_Data.orig.modules.module_dynamic.major.opus.summary.rich_text_nodes),
|
|
573
|
+
decoration_card: (0, bilibili_1.generateDecorationCard)(data[dynamicId].Dynamic_Data.orig.modules.module_author.decorate_card),
|
|
574
|
+
frame: data[dynamicId].Dynamic_Data.orig.modules.module_author.pendant.image
|
|
575
|
+
}
|
|
576
|
+
};
|
|
577
|
+
break;
|
|
578
|
+
}
|
|
579
|
+
case amagi_1.DynamicType.LIVE_RCMD: {
|
|
580
|
+
const liveData = JSON.parse(data[dynamicId].Dynamic_Data.orig.modules.module_dynamic.major.live_rcmd.content);
|
|
581
|
+
original_content = {
|
|
582
|
+
DYNAMIC_TYPE_LIVE_RCMD: {
|
|
583
|
+
usernameMeta: (0, dynamic_text_1.getUsernameMetadata)(data[dynamicId].Dynamic_Data.orig.modules.module_author),
|
|
584
|
+
create_time: bilibili_1.TimeFormatter.toDateTime(data[dynamicId].Dynamic_Data.orig.modules.module_author.pub_ts),
|
|
585
|
+
avatar_url: data[dynamicId].Dynamic_Data.orig.modules.module_author.face,
|
|
586
|
+
decoration_card: (0, bilibili_1.generateDecorationCard)(data[dynamicId].Dynamic_Data.orig.modules.module_author.decorate_card),
|
|
587
|
+
frame: data[dynamicId].Dynamic_Data.orig.modules.module_author.pendant.image,
|
|
588
|
+
cover: liveData.live_play_info.cover,
|
|
589
|
+
text_large: liveData.live_play_info.watched_show.text_large,
|
|
590
|
+
area_name: liveData.live_play_info.area_name,
|
|
591
|
+
title: (0, dynamic_text_1.buildBilibiliDynamicRichText)(liveData.live_play_info.title, []),
|
|
592
|
+
online: liveData.live_play_info.online
|
|
593
|
+
}
|
|
594
|
+
};
|
|
595
|
+
break;
|
|
596
|
+
}
|
|
597
|
+
default: {
|
|
598
|
+
const key = dynamicId;
|
|
599
|
+
node_karin_1.logger.warn(`UP主:${data[key].remark}的${node_karin_1.logger.green('转发动态')}转发的原动态类型为「${node_karin_1.logger.yellow(data[key].Dynamic_Data.orig?.type)}」暂未支持解析`);
|
|
600
|
+
break;
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
img = await (0, module_1.Render)(this.e, 'bilibili/dynamic/DYNAMIC_TYPE_FORWARD', {
|
|
604
|
+
text,
|
|
605
|
+
dianzan: (0, module_1.Count)(data[dynamicId].Dynamic_Data.modules.module_stat.like.count),
|
|
606
|
+
pinglun: (0, module_1.Count)(data[dynamicId].Dynamic_Data.modules.module_stat.comment.count),
|
|
607
|
+
share: (0, module_1.Count)(data[dynamicId].Dynamic_Data.modules.module_stat.forward.count),
|
|
608
|
+
create_time: bilibili_1.TimeFormatter.toDateTime(data[dynamicId].Dynamic_Data.modules.module_author.pub_ts),
|
|
609
|
+
avatar_url: data[dynamicId].Dynamic_Data.modules.module_author.face,
|
|
610
|
+
frame: data[dynamicId].Dynamic_Data.modules.module_author.pendant.image,
|
|
611
|
+
share_url: 'https://t.bilibili.com/' + data[dynamicId].Dynamic_Data.id_str,
|
|
612
|
+
usernameMeta: (0, dynamic_text_1.getUsernameMetadata)(userINFO.data.data.card),
|
|
613
|
+
fans: (0, module_1.Count)(userINFO.data.data.follower),
|
|
614
|
+
user_shortid: data[dynamicId].Dynamic_Data.modules.module_author.mid,
|
|
615
|
+
total_favorited: (0, module_1.Count)(userINFO.data.data.like_num),
|
|
616
|
+
following_count: (0, module_1.Count)(userINFO.data.data.card.attention),
|
|
617
|
+
dynamicTYPE: '转发动态推送',
|
|
618
|
+
decoration_card: (0, bilibili_1.generateDecorationCard)(data[dynamicId].Dynamic_Data.modules.module_author.decorate_card),
|
|
619
|
+
render_time: bilibili_1.TimeFormatter.now(),
|
|
620
|
+
original_content,
|
|
621
|
+
imgList: imgList.length > 0 ? imgList : null,
|
|
622
|
+
dynamic_id: dynamicId
|
|
623
|
+
});
|
|
624
|
+
break;
|
|
625
|
+
}
|
|
626
|
+
/** 文章/专栏动态 */
|
|
627
|
+
case amagi_1.DynamicType.ARTICLE: {
|
|
628
|
+
const articleInfoBase = await this.amagi.bilibili.fetcher.fetchArticleInfo({
|
|
629
|
+
id: data[dynamicId].Dynamic_Data.basic.rid_str
|
|
630
|
+
});
|
|
631
|
+
const articleInfo = await this.amagi.bilibili.fetcher.fetchArticleContent({
|
|
632
|
+
id: data[dynamicId].Dynamic_Data.basic.rid_str
|
|
633
|
+
});
|
|
634
|
+
// 提取专栏基本信息
|
|
635
|
+
const articleData = articleInfoBase.data.data;
|
|
636
|
+
// 提取专栏正文内容(生成类型里 `data` 可空:拿不到正文就没东西可推,按未支持类型一样跳过)
|
|
637
|
+
const articleContent = articleInfo.data.data;
|
|
638
|
+
if (!articleContent) {
|
|
639
|
+
skip = true;
|
|
640
|
+
node_karin_1.logger.warn(`UP主:${data[dynamicId].remark} 的专栏 ${data[dynamicId].Dynamic_Data.basic.rid_str} 未返回正文,跳过本次推送`);
|
|
641
|
+
break;
|
|
642
|
+
}
|
|
643
|
+
const body = (0, dynamic_text_1.buildBilibiliArticleRichText)(articleContent.opus, articleContent.content, module_1.Common.useDarkTheme());
|
|
644
|
+
const shareUrl = articleContent.dyn_id_str
|
|
645
|
+
? `https://www.bilibili.com/opus/${articleContent.dyn_id_str}`
|
|
646
|
+
: `https://www.bilibili.com/read/cv${articleContent.id}`;
|
|
647
|
+
articleForwardPayload = {
|
|
648
|
+
body,
|
|
649
|
+
title: articleData.title,
|
|
650
|
+
summary: articleData.summary,
|
|
651
|
+
shareUrl
|
|
652
|
+
};
|
|
653
|
+
// 构建渲染数据
|
|
654
|
+
img = await (0, module_1.Render)(this.e, 'bilibili/dynamic/DYNAMIC_TYPE_ARTICLE', {
|
|
655
|
+
// 用户信息
|
|
656
|
+
usernameMeta: (0, dynamic_text_1.getUsernameMetadata)(data[dynamicId].Dynamic_Data.modules.module_author),
|
|
657
|
+
avatar_url: data[dynamicId].Dynamic_Data.modules.module_author.face,
|
|
658
|
+
frame: data[dynamicId].Dynamic_Data.modules.module_author.pendant.image,
|
|
659
|
+
create_time: bilibili_1.TimeFormatter.toDateTime(data[dynamicId].Dynamic_Data.modules.module_author.pub_ts),
|
|
660
|
+
user_shortid: data[dynamicId].host_mid,
|
|
661
|
+
fans: (0, module_1.Count)(userINFO.data.data.follower),
|
|
662
|
+
total_favorited: (0, module_1.Count)(userINFO.data.data.like_num),
|
|
663
|
+
following_count: (0, module_1.Count)(userINFO.data.data.card.attention),
|
|
664
|
+
// 专栏内容信息
|
|
665
|
+
title: articleData.title,
|
|
666
|
+
summary: articleData.summary,
|
|
667
|
+
banner_url: articleData.banner_url || (articleData.image_urls && articleData.image_urls[0]) || '',
|
|
668
|
+
categories: articleData.categories || [],
|
|
669
|
+
words: articleData.words || 0,
|
|
670
|
+
// 专栏正文内容(richtext 格式)
|
|
671
|
+
body,
|
|
672
|
+
// 统计信息
|
|
673
|
+
stats: articleData.stats,
|
|
674
|
+
render_time: bilibili_1.TimeFormatter.now(),
|
|
675
|
+
// 分享链接
|
|
676
|
+
share_url: shareUrl,
|
|
677
|
+
dynamicTYPE: '专栏动态推送'
|
|
678
|
+
});
|
|
679
|
+
break;
|
|
680
|
+
}
|
|
681
|
+
/** 未处理的动态类型 */
|
|
682
|
+
default: {
|
|
683
|
+
skip = true;
|
|
684
|
+
const key = dynamicId;
|
|
685
|
+
node_karin_1.logger.warn(`UP主:${data[key].remark}「${data[key].dynamic_type}」动态类型的暂未支持推送\n动态地址:${'https://t.bilibili.com/' + data[key].Dynamic_Data.id_str}\n可通过 https://github.com/ikenxuan/karin-plugin-kkk/issues/new/choose 提交反馈`);
|
|
686
|
+
break;
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
// 遍历 targets 数组,并发送消息
|
|
691
|
+
for (const target of data[dynamicId].targets) {
|
|
692
|
+
let status = null;
|
|
693
|
+
if (!skip) {
|
|
694
|
+
const { groupId, botId } = target;
|
|
695
|
+
const bot = node_karin_1.default.getBot(botId);
|
|
696
|
+
const Contact = node_karin_1.default.contactGroup(groupId);
|
|
697
|
+
// 为当前目标注入 bot,后续解析下载沿用该 bot 身份
|
|
698
|
+
const eventWithBot = this.e;
|
|
699
|
+
eventWithBot.bot = bot;
|
|
700
|
+
eventWithBot.selfId = botId;
|
|
701
|
+
const pushImg = img ?? [];
|
|
702
|
+
// 仅 QQ 官方机器人支持按钮:非直播动态在卡片末尾追加「解析」回调按钮,点击后下发 #解析 + 动态/视频地址
|
|
703
|
+
const parseUrl = buildParseUrl(data[dynamicId]);
|
|
704
|
+
const parseButton = bot?.adapter?.name === 'QQ Official Bot' && parseUrl
|
|
705
|
+
? [
|
|
706
|
+
node_karin_1.segment.button([
|
|
707
|
+
{ text: '解析', callback: true, data: `#解析${parseUrl}` },
|
|
708
|
+
{ text: '帮助', callback: true, data: `#kkk帮助` }
|
|
709
|
+
])
|
|
710
|
+
]
|
|
711
|
+
: [];
|
|
712
|
+
status = await node_karin_1.default.sendMsg(botId, Contact, [...pushImg, ...parseButton]);
|
|
713
|
+
const shouldParseDynamic = Config_1.Config.bilibili.push.parsedynamic &&
|
|
714
|
+
Config_1.Config.bilibili.push.parseDynamicTypes.includes(data[dynamicId].dynamic_type);
|
|
715
|
+
if (shouldParseDynamic && status.messageId) {
|
|
716
|
+
switch (data[dynamicId].dynamic_type) {
|
|
717
|
+
case 'DYNAMIC_TYPE_AV': {
|
|
718
|
+
if (send_video) {
|
|
719
|
+
let correctList;
|
|
720
|
+
let videoSize = '';
|
|
721
|
+
const videoInfo = await this.amagi.bilibili.fetcher.fetchVideoInfo({
|
|
722
|
+
bvid: data[dynamicId].Dynamic_Data.modules.module_dynamic.major.archive.bvid
|
|
723
|
+
});
|
|
724
|
+
const playUrlData = await this.amagi.bilibili.fetcher.fetchVideoStreamUrl({
|
|
725
|
+
avid: parseInt(data[dynamicId].Dynamic_Data.modules.module_dynamic.major.archive.aid),
|
|
726
|
+
cid: videoInfo.data.data.cid
|
|
727
|
+
});
|
|
728
|
+
/** 提取出视频流信息对象,并排除清晰度重复的视频流 */
|
|
729
|
+
const simplify = playUrlData.data.data.dash.video.filter((item, index, self) => {
|
|
730
|
+
return (self.findIndex((t) => {
|
|
731
|
+
return t.id === item.id;
|
|
732
|
+
}) === index);
|
|
733
|
+
});
|
|
734
|
+
/** 替换原始的视频信息对象 */
|
|
735
|
+
playUrlData.data.data.dash.video = simplify;
|
|
736
|
+
/** 没有音频流(如纯视频稿件)时拿不到音频地址,按只统计视频流大小处理 */
|
|
737
|
+
const audioUrl = playUrlData.data.data.dash.audio?.[0]?.base_url;
|
|
738
|
+
/** 给视频信息对象删除不符合条件的视频流 */
|
|
739
|
+
correctList = await (0, bilibili_1.bilibiliProcessVideos)({
|
|
740
|
+
accept_description: playUrlData.data.data.accept_description,
|
|
741
|
+
bvid: data[dynamicId].Dynamic_Data.modules.module_dynamic.major.archive.bvid,
|
|
742
|
+
qn: Config_1.Config.bilibili.push.pushVideoQuality,
|
|
743
|
+
maxAutoVideoSize: Config_1.Config.bilibili.push.pushMaxAutoVideoSize
|
|
744
|
+
}, simplify, audioUrl);
|
|
745
|
+
playUrlData.data.data.dash.video = correctList.videoList;
|
|
746
|
+
playUrlData.data.data.accept_description = correctList.accept_description;
|
|
747
|
+
/** 获取第一个视频流的大小 */
|
|
748
|
+
videoSize = await (0, bilibili_1.getvideosize)(correctList.videoList[0].base_url, audioUrl, data[dynamicId].Dynamic_Data.modules.module_dynamic.major.archive.bvid);
|
|
749
|
+
if (Config_1.Config.app.usefilelimit && Number(videoSize) > Number(Config_1.Config.app.filelimit) && !Config_1.Config.app.compress) {
|
|
750
|
+
await node_karin_1.default.sendMsg(botId, Contact, [
|
|
751
|
+
node_karin_1.segment.text(`设定的最大上传大小为 ${Config_1.Config.app.filelimit}MB\n当前解析到的视频大小为 ${Number(videoSize)}MB\n视频太大了,还是去B站看吧~`),
|
|
752
|
+
node_karin_1.segment.reply(status.messageId)
|
|
753
|
+
]);
|
|
754
|
+
break;
|
|
755
|
+
}
|
|
756
|
+
node_karin_1.logger.mark(`当前处于自动推送状态,解析到的视频大小为 ${node_karin_1.logger.yellow(Number(videoSize))} MB`);
|
|
757
|
+
const infoData = await this.amagi.bilibili.fetcher.fetchVideoInfo({
|
|
758
|
+
bvid: data[dynamicId].Dynamic_Data.modules.module_dynamic.major.archive.bvid
|
|
759
|
+
});
|
|
760
|
+
const mp4File = await (0, module_1.downloadFile)(playUrlData.data?.data?.dash?.video[0].base_url, {
|
|
761
|
+
title: `Bil_V_${infoData.data.data.bvid}.mp4`,
|
|
762
|
+
headers: bilibiliBaseHeaders
|
|
763
|
+
});
|
|
764
|
+
const mp3File = audioUrl
|
|
765
|
+
? await (0, module_1.downloadFile)(audioUrl, {
|
|
766
|
+
title: `Bil_A_${infoData.data.data.bvid}.mp3`,
|
|
767
|
+
headers: bilibiliBaseHeaders
|
|
768
|
+
})
|
|
769
|
+
: undefined;
|
|
770
|
+
if (mp4File.filepath && (!mp3File || mp3File.filepath)) {
|
|
771
|
+
/** 没有音频流时无从合成,直接发送视频流 */
|
|
772
|
+
const resultPath = mp3File ? module_1.Common.tempDri.video + `Bil_Result_${infoData.data.data.bvid}.mp4` : mp4File.filepath;
|
|
773
|
+
const success = mp3File ? await (0, module_1.mergeVideoAudio)(mp4File.filepath, mp3File.filepath, resultPath) : true;
|
|
774
|
+
if (success) {
|
|
775
|
+
const filePath = module_1.Common.tempDri.video + `tmp_${Date.now()}.mp4`;
|
|
776
|
+
node_fs_1.default.renameSync(resultPath, filePath);
|
|
777
|
+
node_karin_1.logger.mark(`视频文件重命名完成: ${resultPath.split('/').pop()} -> ${filePath.split('/').pop()}`);
|
|
778
|
+
node_karin_1.logger.mark('正在尝试删除缓存文件');
|
|
779
|
+
if (node_fs_1.default.existsSync(mp4File.filepath))
|
|
780
|
+
await module_1.Common.removeFile(mp4File.filepath, true);
|
|
781
|
+
if (mp3File)
|
|
782
|
+
await module_1.Common.removeFile(mp3File.filepath, true);
|
|
783
|
+
const stats = node_fs_1.default.statSync(filePath);
|
|
784
|
+
const fileSizeInMB = Number((stats.size / (1024 * 1024)).toFixed(2));
|
|
785
|
+
if (fileSizeInMB > Config_1.Config.app.groupfilevalue) {
|
|
786
|
+
// 使用文件上传
|
|
787
|
+
await (0, module_1.uploadFile)(this.e, {
|
|
788
|
+
filepath: filePath,
|
|
789
|
+
totalBytes: fileSizeInMB,
|
|
790
|
+
originTitle: `${infoData.data.data.desc.substring(0, 50).replace(/[\\/:\\*\\?"<>\\|\r\n\s]/g, ' ')}`
|
|
791
|
+
}, '', { useGroupFile: true, active: true, activeOption: { group_id: groupId, uin: botId } });
|
|
792
|
+
}
|
|
793
|
+
else {
|
|
794
|
+
/** 因为本地合成,没有视频直链 */
|
|
795
|
+
await (0, module_1.uploadFile)(this.e, { filepath: filePath, totalBytes: fileSizeInMB }, '', {
|
|
796
|
+
active: true,
|
|
797
|
+
activeOption: { group_id: groupId, uin: botId }
|
|
798
|
+
});
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
else {
|
|
802
|
+
await module_1.Common.removeFile(mp4File.filepath, true);
|
|
803
|
+
if (mp3File)
|
|
804
|
+
await module_1.Common.removeFile(mp3File.filepath, true);
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
break;
|
|
809
|
+
}
|
|
810
|
+
case 'DYNAMIC_TYPE_DRAW': {
|
|
811
|
+
const imgArray = [];
|
|
812
|
+
const temp = [];
|
|
813
|
+
let hasGeneratedLivePhoto = false; // 标记是否生成了实况图
|
|
814
|
+
const title = data[dynamicId].Dynamic_Data.modules.module_dynamic.major?.opus?.title || 'bilibili_dynamic';
|
|
815
|
+
const images = (data[dynamicId].Dynamic_Data.modules.module_dynamic.major &&
|
|
816
|
+
data[dynamicId].Dynamic_Data.modules.module_dynamic?.major?.draw?.items) ||
|
|
817
|
+
data[dynamicId].Dynamic_Data.modules.module_dynamic?.major?.opus.pics;
|
|
818
|
+
if (images.length === 0)
|
|
819
|
+
break;
|
|
820
|
+
for (const [index, img2] of images.entries()) {
|
|
821
|
+
const imageSrc = img2.src ?? img2.url;
|
|
822
|
+
if (img2.live_url && imageSrc) {
|
|
823
|
+
const livePhoto = await (0, module_1.downloadFile)(img2.live_url, {
|
|
824
|
+
title: `Bilibili_tmp_V_${Date.now()}_${index}.mp4`,
|
|
825
|
+
headers: bilibiliBaseHeaders
|
|
826
|
+
});
|
|
827
|
+
if (livePhoto.filepath) {
|
|
828
|
+
const outputPath = module_1.Common.tempDri.video + `Bilibili_Live_${Date.now()}_${index}.mp4`;
|
|
829
|
+
const staticImg = await (0, module_1.downloadFile)(imageSrc, {
|
|
830
|
+
title: `Bilibili_static_${Date.now()}_${index}.jpg`,
|
|
831
|
+
headers: bilibiliBaseHeaders,
|
|
832
|
+
filepath: module_1.Common.tempDri.images + `Bilibili_static_${Date.now()}_${index}.jpg`
|
|
833
|
+
});
|
|
834
|
+
if (staticImg.filepath) {
|
|
835
|
+
temp.push({ filepath: staticImg.filepath, totalBytes: 0 });
|
|
836
|
+
}
|
|
837
|
+
// 根据 livePhotoMode 配置决定处理方式
|
|
838
|
+
const livePhotoMode = Config_1.Config.app.livePhotoMode ?? 'video_and_livephoto';
|
|
839
|
+
const shouldGenerateVideo = livePhotoMode === 'video_and_livephoto' || livePhotoMode === 'video_only';
|
|
840
|
+
const shouldGenerateLivePhoto = livePhotoMode === 'video_and_livephoto' || livePhotoMode === 'livephoto_only';
|
|
841
|
+
const loopCount = 3;
|
|
842
|
+
if (!staticImg.filepath) {
|
|
843
|
+
await module_1.Common.removeFile(livePhoto.filepath, true);
|
|
844
|
+
continue;
|
|
845
|
+
}
|
|
846
|
+
// 生成视频
|
|
847
|
+
if (shouldGenerateVideo) {
|
|
848
|
+
const result = await (0, module_1.loopVideoWithTransition)({
|
|
849
|
+
inputPath: livePhoto.filepath,
|
|
850
|
+
outputPath,
|
|
851
|
+
loopCount,
|
|
852
|
+
staticImagePath: staticImg.filepath,
|
|
853
|
+
transitionEnabled: loopCount > 1
|
|
854
|
+
});
|
|
855
|
+
const success = result.success;
|
|
856
|
+
if (success) {
|
|
857
|
+
const filePath = module_1.Common.tempDri.video + `tmp_${Date.now()}.mp4`;
|
|
858
|
+
node_fs_1.default.renameSync(outputPath, filePath);
|
|
859
|
+
node_karin_1.logger.mark(`视频文件重命名完成: ${outputPath.split('/').pop()} -> ${filePath.split('/').pop()}`);
|
|
860
|
+
temp.push({ filepath: filePath, totalBytes: 0 });
|
|
861
|
+
const videoPath = Config_1.Config.app.videoSendMode === 'base64'
|
|
862
|
+
? `base64://${node_fs_1.default.readFileSync(filePath).toString('base64')}`
|
|
863
|
+
: `file://${filePath}`;
|
|
864
|
+
imgArray.push(node_karin_1.segment.video(videoPath));
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
// 生成实况图
|
|
868
|
+
if (shouldGenerateLivePhoto) {
|
|
869
|
+
let hasPushedMotionPhotoCover = false;
|
|
870
|
+
if (staticImg.filepath) {
|
|
871
|
+
const motionPhotoCoverPath = module_1.Common.tempDri.images + `MVIMG_${Date.now()}_${index}.jpg`;
|
|
872
|
+
const motionPhotoCreated = await (0, module_1.buildGoogleMotionPhoto)({
|
|
873
|
+
imagePath: staticImg.filepath,
|
|
874
|
+
videoPath: livePhoto.filepath,
|
|
875
|
+
outputPath: motionPhotoCoverPath
|
|
876
|
+
});
|
|
877
|
+
if (motionPhotoCreated) {
|
|
878
|
+
temp.push({ filepath: motionPhotoCoverPath, totalBytes: 0 });
|
|
879
|
+
const motionPhotoCover = (0, module_1.processLocalImageFile)(motionPhotoCoverPath);
|
|
880
|
+
imgArray.push(node_karin_1.segment.image(motionPhotoCover));
|
|
881
|
+
hasPushedMotionPhotoCover = true;
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
if (!hasPushedMotionPhotoCover) {
|
|
885
|
+
const imageUrl = await (0, module_1.processImageUrl)(imageSrc, title, index);
|
|
886
|
+
imgArray.push(node_karin_1.segment.image(imageUrl));
|
|
887
|
+
}
|
|
888
|
+
else {
|
|
889
|
+
hasGeneratedLivePhoto = true; // 标记已生成实况图
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
node_karin_1.logger.mark('正在尝试删除缓存文件');
|
|
893
|
+
await module_1.Common.removeFile(livePhoto.filepath, true);
|
|
894
|
+
continue;
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
if (imageSrc) {
|
|
898
|
+
const imageUrl = await (0, module_1.processImageUrl)(imageSrc, title, index);
|
|
899
|
+
imgArray.push(node_karin_1.segment.image(imageUrl));
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
// 如果生成了实况图,添加提示文字
|
|
903
|
+
if (hasGeneratedLivePhoto) {
|
|
904
|
+
const tipImg = await (0, module_1.Render)(this.e, 'other/live-photo-tip', {
|
|
905
|
+
title: '实况照片已生成',
|
|
906
|
+
description: '保存原图到相册即可识别为实况图'
|
|
907
|
+
});
|
|
908
|
+
imgArray.push(...tipImg);
|
|
909
|
+
}
|
|
910
|
+
const forwardMsg = node_karin_1.common.makeForward(imgArray, botId, bot.account.name);
|
|
911
|
+
try {
|
|
912
|
+
await bot.sendForwardMsg(Contact, forwardMsg, {
|
|
913
|
+
source: '图片合集',
|
|
914
|
+
summary: `查看${imgArray.length}张图片消息`,
|
|
915
|
+
prompt: 'B站图文动态解析结果',
|
|
916
|
+
news: [{ text: '点击查看解析结果' }]
|
|
917
|
+
});
|
|
918
|
+
}
|
|
919
|
+
finally {
|
|
920
|
+
for (const item of temp) {
|
|
921
|
+
await module_1.Common.removeFile(item.filepath, true);
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
break;
|
|
925
|
+
}
|
|
926
|
+
case 'DYNAMIC_TYPE_ARTICLE': {
|
|
927
|
+
let payload = articleForwardPayload;
|
|
928
|
+
if (!payload) {
|
|
929
|
+
const articleInfoBase = await this.amagi.bilibili.fetcher.fetchArticleInfo({
|
|
930
|
+
id: data[dynamicId].Dynamic_Data.basic.rid_str
|
|
931
|
+
});
|
|
932
|
+
const articleInfo = await this.amagi.bilibili.fetcher.fetchArticleContent({
|
|
933
|
+
id: data[dynamicId].Dynamic_Data.basic.rid_str
|
|
934
|
+
});
|
|
935
|
+
// 生成类型里 `data` 可空,没正文就没什么可转发的
|
|
936
|
+
const articleContent = articleInfo.data.data;
|
|
937
|
+
if (!articleContent) {
|
|
938
|
+
node_karin_1.logger.warn(`专栏 ${data[dynamicId].Dynamic_Data.basic.rid_str} 未返回正文,跳过解析`);
|
|
939
|
+
break;
|
|
940
|
+
}
|
|
941
|
+
payload = {
|
|
942
|
+
body: (0, dynamic_text_1.buildBilibiliArticleRichText)(articleContent.opus, articleContent.content, module_1.Common.useDarkTheme()),
|
|
943
|
+
title: articleInfoBase.data.data.title,
|
|
944
|
+
summary: articleInfoBase.data.data.summary,
|
|
945
|
+
shareUrl: articleContent.dyn_id_str
|
|
946
|
+
? `https://www.bilibili.com/opus/${articleContent.dyn_id_str}`
|
|
947
|
+
: `https://www.bilibili.com/read/cv${articleContent.id}`
|
|
948
|
+
};
|
|
949
|
+
}
|
|
950
|
+
const title = payload.title || 'bilibili_article';
|
|
951
|
+
const messageElements = await (0, dynamic_text_1.buildBilibiliRichTextForwardMessage)(payload.body, {
|
|
952
|
+
title: payload.title,
|
|
953
|
+
summary: payload.summary,
|
|
954
|
+
shareUrl: payload.shareUrl,
|
|
955
|
+
imageResolver: (src, index) => (0, module_1.processImageUrl)(src, title, index)
|
|
956
|
+
});
|
|
957
|
+
if (messageElements.length > 0) {
|
|
958
|
+
const forwardMsg = node_karin_1.common.makeForward(messageElements, botId, bot.account.name);
|
|
959
|
+
await bot.sendForwardMsg(Contact, forwardMsg, {
|
|
960
|
+
source: '专栏内容',
|
|
961
|
+
summary: `查看${messageElements.length}条专栏内容`,
|
|
962
|
+
prompt: 'B站专栏动态解析结果',
|
|
963
|
+
news: [{ text: '点击查看解析结果' }]
|
|
964
|
+
});
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
if (skip || (status && status?.messageId)) {
|
|
971
|
+
// 使用新的数据库API添加动态缓存
|
|
972
|
+
await module_1.bilibiliDB.addDynamicCache(dynamicId, data[dynamicId].host_mid, target.groupId, data[dynamicId].dynamic_type);
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
}
|
|
977
|
+
/**
|
|
978
|
+
* 根据配置文件获取UP当天的动态列表。
|
|
979
|
+
* @param userList B站订阅列表。
|
|
980
|
+
* @returns
|
|
981
|
+
*/
|
|
982
|
+
async getDynamicList(userList) {
|
|
983
|
+
const directLiveItems = await this.getDirectLivePushItems(userList);
|
|
984
|
+
const willbepushlist = { ...directLiveItems.willBePushList };
|
|
985
|
+
try {
|
|
986
|
+
/** 过滤掉不启用的订阅项 */
|
|
987
|
+
const filteredUserList = userList.filter((item) => item.switch !== false);
|
|
988
|
+
for (const item of filteredUserList) {
|
|
989
|
+
const pushTypes = item.pushTypes || allBilibiliPushTypes;
|
|
990
|
+
const allowedDynamicTypes = new Set(pushTypes.map((pt) => pushTypeToDynamicType[pt]));
|
|
991
|
+
if (directLiveItems.handledUids.has(item.host_mid)) {
|
|
992
|
+
allowedDynamicTypes.delete(amagi_1.DynamicType.LIVE_RCMD);
|
|
993
|
+
}
|
|
994
|
+
if (allowedDynamicTypes.size === 0)
|
|
995
|
+
continue;
|
|
996
|
+
await node_karin_1.common.sleep(2000);
|
|
997
|
+
node_karin_1.logger.debug(`[Bilibili 推送] 开始获取UP: ${item.remark}(${item.host_mid}) 的动态列表`);
|
|
998
|
+
const dynamic_list = await this.amagi.bilibili.fetcher.fetchUserDynamicList({
|
|
999
|
+
host_mid: item.host_mid
|
|
1000
|
+
});
|
|
1001
|
+
// 生成树这条响应没按动态类型分形状,推送链路要的是判别联合(见 DataItem 的说明),这里换一次
|
|
1002
|
+
const dynamicItems = dynamic_list.data.data.items;
|
|
1003
|
+
if (dynamicItems.length > 0) {
|
|
1004
|
+
// 遍历接口返回的视频列表
|
|
1005
|
+
for (const dynamic of dynamicItems) {
|
|
1006
|
+
const nowSeconds = Math.floor(Date.now() / 1000); // 当前时间戳(秒)
|
|
1007
|
+
const createTime = dynamic.modules.module_author.pub_ts; // 发布时间戳(秒)
|
|
1008
|
+
const timeDifference = nowSeconds - createTime; // 时间差(秒)
|
|
1009
|
+
const is_top = dynamic.modules.module_tag?.text === '置顶'; // 是否为置顶
|
|
1010
|
+
let shouldPush = false; // 是否列入推送数组
|
|
1011
|
+
const timeDiffHours = Math.round((timeDifference / 3600) * 100) / 100; // 保留2位小数
|
|
1012
|
+
// 条件判断,以下任何一项成立都将进行推送:如果是置顶且发布时间在一天内 || 如果是置顶作品且有新的群组且发布时间在一天内 || 如果有新的群组且发布时间在一天内
|
|
1013
|
+
node_karin_1.logger.trace(`
|
|
1014
|
+
前期获取该动态基本信息:
|
|
1015
|
+
UP主:${dynamic.modules.module_author.name}
|
|
1016
|
+
动态ID:${dynamic.id_str}
|
|
1017
|
+
发布时间:${bilibili_1.TimeFormatter.toDateTime(createTime)}
|
|
1018
|
+
发布时间戳(s):${createTime}
|
|
1019
|
+
当前时间戳(s):${nowSeconds}
|
|
1020
|
+
时间差(s):${timeDifference}s (${timeDiffHours}h)
|
|
1021
|
+
是否置顶:${is_top}
|
|
1022
|
+
是否在一天内:${timeDifference < 86400 ? node_karin_1.logger.green('true') : node_karin_1.logger.red('false')}
|
|
1023
|
+
`);
|
|
1024
|
+
if ((is_top && timeDifference < 86400) || timeDifference < 86400) {
|
|
1025
|
+
shouldPush = true;
|
|
1026
|
+
node_karin_1.logger.trace(node_karin_1.logger.green(`根据以上判断,shoulPush 为 true,将对该动态纳入当天推送列表:https://t.bilibili.com/${dynamic.id_str}\n`));
|
|
1027
|
+
}
|
|
1028
|
+
else
|
|
1029
|
+
node_karin_1.logger.trace(node_karin_1.logger.yellow(`根据以上判断,shoulPush 为 false,跳过该动态:https://t.bilibili.com/${dynamic.id_str}\n`));
|
|
1030
|
+
// 如果 shouldPush 为 true,或该作品距现在的时间差小于一天,则将该动态添加到 willbepushlist 中
|
|
1031
|
+
if (timeDifference < 86400 || shouldPush) {
|
|
1032
|
+
// 根据推送类型过滤
|
|
1033
|
+
if (!allowedDynamicTypes.has(dynamic.type)) {
|
|
1034
|
+
node_karin_1.logger.debug(`UP主 ${item.remark}(${item.host_mid})的动态 ${dynamic.id_str} 类型为「${dynamic.type}」,不在推送类型配置中,跳过`);
|
|
1035
|
+
continue;
|
|
1036
|
+
}
|
|
1037
|
+
// 将群组ID和机器人ID分离
|
|
1038
|
+
const targets = item.group_id.map((groupWithBot) => {
|
|
1039
|
+
const [groupId, botId] = groupWithBot.split(':');
|
|
1040
|
+
return { groupId, botId };
|
|
1041
|
+
});
|
|
1042
|
+
const pushId = dynamic.type === amagi_1.DynamicType.LIVE_RCMD
|
|
1043
|
+
? await this.resolveLiveDynamicCacheId(dynamic, item.host_mid)
|
|
1044
|
+
: dynamic.id_str;
|
|
1045
|
+
// 确保 willbepushlist[pushId] 是一个对象
|
|
1046
|
+
if (!willbepushlist[pushId]) {
|
|
1047
|
+
willbepushlist[pushId] = {
|
|
1048
|
+
remark: item.remark,
|
|
1049
|
+
host_mid: item.host_mid,
|
|
1050
|
+
create_time: dynamic.modules.module_author.pub_ts,
|
|
1051
|
+
targets,
|
|
1052
|
+
Dynamic_Data: dynamic, // 存储 dynamic 对象
|
|
1053
|
+
avatar_img: dynamic.modules.module_author.face,
|
|
1054
|
+
dynamic_type: dynamic.type
|
|
1055
|
+
};
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
}
|
|
1060
|
+
else {
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
catch (error) {
|
|
1065
|
+
throw new Error(`获取动态列表失败: ${error}`);
|
|
1066
|
+
}
|
|
1067
|
+
return { willbepushlist };
|
|
1068
|
+
}
|
|
1069
|
+
/**
|
|
1070
|
+
* 排除已推送过的群组并返回更新后的推送列表
|
|
1071
|
+
* @param willBePushList 将要推送的列表
|
|
1072
|
+
* @returns 更新后的推送列表
|
|
1073
|
+
*/
|
|
1074
|
+
async excludeAlreadyPushed(willBePushList) {
|
|
1075
|
+
// 遍历推送列表中的作品ID
|
|
1076
|
+
for (const dynamicId in willBePushList) {
|
|
1077
|
+
const pushItem = willBePushList[dynamicId];
|
|
1078
|
+
const newTargets = [];
|
|
1079
|
+
// 遍历作品对应的目标群组
|
|
1080
|
+
for (const target of pushItem.targets) {
|
|
1081
|
+
// 检查该动态是否已经推送给该群组
|
|
1082
|
+
const isPushed = await module_1.bilibiliDB.isDynamicPushed(dynamicId, pushItem.host_mid, target.groupId);
|
|
1083
|
+
// 如果未被推送过,则保留此目标
|
|
1084
|
+
if (!isPushed) {
|
|
1085
|
+
newTargets.push(target);
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1088
|
+
// 更新作品的目标数组
|
|
1089
|
+
if (newTargets.length > 0) {
|
|
1090
|
+
pushItem.targets = newTargets;
|
|
1091
|
+
}
|
|
1092
|
+
else {
|
|
1093
|
+
// 如果没有剩余目标,移除该作品
|
|
1094
|
+
delete willBePushList[dynamicId];
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
return willBePushList;
|
|
1098
|
+
}
|
|
1099
|
+
/**
|
|
1100
|
+
* 设置或更新特定 host_mid 的群组信息。
|
|
1101
|
+
* @param data 包含 card 对象。
|
|
1102
|
+
* @returns 操作成功或失败的消息字符串。
|
|
1103
|
+
*/
|
|
1104
|
+
async setting(data) {
|
|
1105
|
+
const groupInfo = await this.e.bot.getGroupInfo('groupId' in this.e && this.e.groupId ? this.e.groupId : '');
|
|
1106
|
+
const host_mid = Number(data.data.card.mid);
|
|
1107
|
+
const config = Config_1.Config.pushlist; // 读取配置文件
|
|
1108
|
+
const groupId = 'groupId' in this.e && this.e.groupId ? this.e.groupId : '';
|
|
1109
|
+
const botId = this.e.selfId;
|
|
1110
|
+
// 初始化或确保 bilibilipushlist 数组存在
|
|
1111
|
+
if (!config.bilibili) {
|
|
1112
|
+
config.bilibili = [];
|
|
1113
|
+
}
|
|
1114
|
+
// 检查是否存在相同的 host_mid
|
|
1115
|
+
const existingItem = config.bilibili.find((item) => item.host_mid === host_mid);
|
|
1116
|
+
// 检查该群组是否已订阅该UP主
|
|
1117
|
+
const isSubscribed = await module_1.bilibiliDB.isSubscribed(host_mid, groupId);
|
|
1118
|
+
if (existingItem) {
|
|
1119
|
+
// 如果已经存在相同的 host_mid,则检查是否存在相同的 group_id
|
|
1120
|
+
let has = false;
|
|
1121
|
+
let groupIndexToRemove = -1; // 用于记录要删除的 group_id 对象的索引
|
|
1122
|
+
for (let index = 0; index < existingItem.group_id.length; index++) {
|
|
1123
|
+
const item = existingItem.group_id[index];
|
|
1124
|
+
const existingGroupId = item.split(':')[0];
|
|
1125
|
+
if (existingGroupId === String(groupId)) {
|
|
1126
|
+
has = true;
|
|
1127
|
+
groupIndexToRemove = index;
|
|
1128
|
+
break;
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1131
|
+
if (has) {
|
|
1132
|
+
// 如果已存在相同的 group_id,则删除它
|
|
1133
|
+
existingItem.group_id.splice(groupIndexToRemove, 1);
|
|
1134
|
+
// 在数据库中取消订阅
|
|
1135
|
+
if (isSubscribed) {
|
|
1136
|
+
await module_1.bilibiliDB.unsubscribeBilibiliUser(groupId, host_mid);
|
|
1137
|
+
}
|
|
1138
|
+
// 如果删除后 group_id 数组为空,则删除整个属性
|
|
1139
|
+
if (existingItem.group_id.length === 0) {
|
|
1140
|
+
const index = config.bilibili.indexOf(existingItem);
|
|
1141
|
+
config.bilibili.splice(index, 1);
|
|
1142
|
+
}
|
|
1143
|
+
// 保存配置到文件
|
|
1144
|
+
Config_1.Config.Modify('pushlist', 'bilibili', config.bilibili);
|
|
1145
|
+
await this.e.reply(`群:${groupInfo.groupName}(${groupId})\n删除成功!${data.data.card.name}\nUID:${host_mid}`);
|
|
1146
|
+
node_karin_1.logger.info(`\n删除成功!${data.data.card.name}\nUID:${host_mid}`);
|
|
1147
|
+
}
|
|
1148
|
+
else {
|
|
1149
|
+
// 在数据库中添加订阅
|
|
1150
|
+
await module_1.bilibiliDB.subscribeBilibiliUser(groupId, botId, host_mid, data.data.card.name);
|
|
1151
|
+
// 将新的 group_id 添加到该 host_mid 对应的数组中
|
|
1152
|
+
existingItem.group_id.push(`${groupId}:${botId}`);
|
|
1153
|
+
// 确保 pushTypes 字段存在,如果不存在则补全为全部推送类型
|
|
1154
|
+
if (!existingItem.pushTypes || existingItem.pushTypes.length === 0) {
|
|
1155
|
+
existingItem.pushTypes = [...allBilibiliPushTypes];
|
|
1156
|
+
}
|
|
1157
|
+
// 保存配置到文件
|
|
1158
|
+
Config_1.Config.Modify('pushlist', 'bilibili', config.bilibili);
|
|
1159
|
+
await this.e.reply(`群:${groupInfo.groupName}(${groupId})\n添加成功!${data.data.card.name}\nUID:${host_mid}`);
|
|
1160
|
+
if (Config_1.Config.bilibili.push.switch === false)
|
|
1161
|
+
await this.e.reply('请发送「#设置B站推送开启」以进行推送');
|
|
1162
|
+
node_karin_1.logger.info(`\n设置成功!${data.data.card.name}\nUID:${host_mid}`);
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1165
|
+
else {
|
|
1166
|
+
// 在数据库中添加订阅
|
|
1167
|
+
await module_1.bilibiliDB.subscribeBilibiliUser(groupId, botId, host_mid, data.data.card.name);
|
|
1168
|
+
// 不存在相同的 host_mid,新增一个配置项
|
|
1169
|
+
config.bilibili.push({
|
|
1170
|
+
switch: true,
|
|
1171
|
+
host_mid,
|
|
1172
|
+
group_id: [`${groupId}:${botId}`],
|
|
1173
|
+
remark: data.data.card.name,
|
|
1174
|
+
pushTypes: [...allBilibiliPushTypes]
|
|
1175
|
+
});
|
|
1176
|
+
// 保存配置到文件
|
|
1177
|
+
Config_1.Config.Modify('pushlist', 'bilibili', config.bilibili);
|
|
1178
|
+
await this.e.reply(`群:${groupInfo.groupName}(${groupId})\n添加成功!${data.data.card.name}\nUID:${host_mid}`);
|
|
1179
|
+
if (Config_1.Config.bilibili.push.switch === false)
|
|
1180
|
+
await this.e.reply('请发送「#设置B站推送开启」以进行推送');
|
|
1181
|
+
node_karin_1.logger.info(`\n设置成功!${data.data.card.name}\nUID:${host_mid}`);
|
|
1182
|
+
}
|
|
1183
|
+
// 渲染状态图片
|
|
1184
|
+
await this.renderPushList();
|
|
1185
|
+
}
|
|
1186
|
+
/**
|
|
1187
|
+
* 检查并更新配置文件中指定用户的备注信息。
|
|
1188
|
+
* 该函数会遍历配置文件中的用户列表,对于没有备注或备注为空的用户,会从外部数据源获取其备注信息,并更新到配置文件中。
|
|
1189
|
+
*/
|
|
1190
|
+
async checkremark() {
|
|
1191
|
+
// 读取配置文件内容
|
|
1192
|
+
const config = Config_1.Config.pushlist;
|
|
1193
|
+
const abclist = [];
|
|
1194
|
+
if (Config_1.Config.pushlist.bilibili === null || Config_1.Config.pushlist.bilibili.length === 0)
|
|
1195
|
+
return true;
|
|
1196
|
+
// 遍历配置文件中的用户列表,收集需要更新备注信息的用户
|
|
1197
|
+
for (const i of Config_1.Config.pushlist.bilibili) {
|
|
1198
|
+
const remark = i.remark;
|
|
1199
|
+
const group_id = i.group_id;
|
|
1200
|
+
const host_mid = i.host_mid;
|
|
1201
|
+
if (remark === undefined || remark === '') {
|
|
1202
|
+
abclist.push({ host_mid, group_id });
|
|
1203
|
+
}
|
|
1204
|
+
}
|
|
1205
|
+
// 如果有需要更新备注的用户,则逐个获取备注信息并更新到配置文件中
|
|
1206
|
+
if (abclist.length > 0) {
|
|
1207
|
+
for (const i of abclist) {
|
|
1208
|
+
// 从外部数据源获取用户备注信息
|
|
1209
|
+
const resp = await this.amagi.bilibili.fetcher.fetchUserCard({ host_mid: i.host_mid });
|
|
1210
|
+
const remark = resp.data.data.card.name;
|
|
1211
|
+
// 在配置文件中找到对应的用户,并更新其备注信息
|
|
1212
|
+
const matchingItemIndex = config.bilibili.findIndex((item) => item.host_mid === i.host_mid);
|
|
1213
|
+
if (matchingItemIndex !== -1) {
|
|
1214
|
+
config.bilibili[matchingItemIndex].remark = remark;
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
// 将更新后的配置文件内容写回文件
|
|
1218
|
+
Config_1.Config.Modify('pushlist', 'bilibili', config.bilibili);
|
|
1219
|
+
}
|
|
1220
|
+
}
|
|
1221
|
+
/**
|
|
1222
|
+
* 强制推送
|
|
1223
|
+
* @param data 处理完成的推送列表
|
|
1224
|
+
*/
|
|
1225
|
+
async forcepush(data) {
|
|
1226
|
+
const currentGroupId = 'groupId' in this.e && this.e.groupId ? this.e.groupId : '';
|
|
1227
|
+
const currentBotId = this.e.selfId;
|
|
1228
|
+
// 如果不是全部强制推送,需要过滤数据
|
|
1229
|
+
if (!this.e.msg.includes('全部')) {
|
|
1230
|
+
// 获取当前群组订阅的所有UP主
|
|
1231
|
+
const subscriptions = await module_1.bilibiliDB.getGroupSubscriptions(currentGroupId);
|
|
1232
|
+
const subscribedUids = subscriptions.map((sub) => sub.host_mid);
|
|
1233
|
+
/** 创建一个新的推送列表,只包含当前群组订阅的UP主的动态 */
|
|
1234
|
+
const filteredData = {};
|
|
1235
|
+
for (const dynamicId in data) {
|
|
1236
|
+
// 检查该动态的UP主是否被当前群组订阅
|
|
1237
|
+
if (subscribedUids.includes(data[dynamicId].host_mid)) {
|
|
1238
|
+
// 复制该动态到过滤后的列表,并将目标设置为当前群组
|
|
1239
|
+
filteredData[dynamicId] = {
|
|
1240
|
+
...data[dynamicId],
|
|
1241
|
+
targets: [
|
|
1242
|
+
{
|
|
1243
|
+
groupId: currentGroupId,
|
|
1244
|
+
botId: currentBotId
|
|
1245
|
+
}
|
|
1246
|
+
]
|
|
1247
|
+
};
|
|
1248
|
+
}
|
|
1249
|
+
}
|
|
1250
|
+
// 使用过滤后的数据进行推送
|
|
1251
|
+
await this.getdata(filteredData);
|
|
1252
|
+
}
|
|
1253
|
+
else {
|
|
1254
|
+
// 全部强制推送,保持原有逻辑
|
|
1255
|
+
await this.getdata(data);
|
|
1256
|
+
}
|
|
1257
|
+
}
|
|
1258
|
+
/** 渲染推送列表图片 */
|
|
1259
|
+
async renderPushList() {
|
|
1260
|
+
await this.syncConfigToDatabase();
|
|
1261
|
+
const groupInfo = await this.e.bot.getGroupInfo('groupId' in this.e && this.e.groupId ? this.e.groupId : '');
|
|
1262
|
+
// 获取当前群组的所有订阅
|
|
1263
|
+
const subscriptions = await module_1.bilibiliDB.getGroupSubscriptions(groupInfo.groupId);
|
|
1264
|
+
if (subscriptions.length === 0) {
|
|
1265
|
+
await this.e.reply(`当前群:${groupInfo.groupName}(${groupInfo.groupId})\n没有设置任何B站UP推送!\n可使用「#设置B站推送 + UP主UID」进行设置`);
|
|
1266
|
+
return;
|
|
1267
|
+
}
|
|
1268
|
+
/** 用户的今日动态列表 */
|
|
1269
|
+
const renderOpt = [];
|
|
1270
|
+
// 获取所有订阅UP主的信息
|
|
1271
|
+
for (const subscription of subscriptions) {
|
|
1272
|
+
const host_mid = subscription.host_mid;
|
|
1273
|
+
const userInfo = await this.amagi.bilibili.fetcher.fetchUserCard({ host_mid });
|
|
1274
|
+
// 查找配置文件中对应的全局开关状态
|
|
1275
|
+
const configItem = Config_1.Config.pushlist.bilibili?.find((item) => item.host_mid === host_mid);
|
|
1276
|
+
const switchStatus = configItem?.switch !== false; // 默认为 true
|
|
1277
|
+
const pushTypes = configItem?.pushTypes || allBilibiliPushTypes;
|
|
1278
|
+
renderOpt.push({
|
|
1279
|
+
avatar_img: userInfo.data.data.card.face,
|
|
1280
|
+
username: userInfo.data.data.card.name,
|
|
1281
|
+
host_mid: userInfo.data.data.card.mid,
|
|
1282
|
+
fans: (0, module_1.Count)(userInfo.data.data.follower),
|
|
1283
|
+
total_favorited: (0, module_1.Count)(userInfo.data.data.like_num),
|
|
1284
|
+
following_count: (0, module_1.Count)(userInfo.data.data.card.attention),
|
|
1285
|
+
switch: switchStatus,
|
|
1286
|
+
pushTypes
|
|
1287
|
+
});
|
|
1288
|
+
}
|
|
1289
|
+
const img = await (0, module_1.Render)(this.e, 'bilibili/userlist', {
|
|
1290
|
+
renderOpt,
|
|
1291
|
+
groupInfo: {
|
|
1292
|
+
groupId: groupInfo.groupId || '',
|
|
1293
|
+
groupName: groupInfo.groupName || '',
|
|
1294
|
+
groupAvatar: groupInfo.avatar || ''
|
|
1295
|
+
}
|
|
1296
|
+
});
|
|
1297
|
+
await this.e.reply(img);
|
|
1298
|
+
}
|
|
1299
|
+
}
|
|
1300
|
+
exports.Bilibilipush = Bilibilipush;
|
|
1301
|
+
/**
|
|
1302
|
+
* 把直播状态接口的数据适配为现有直播动态分支实际读取的字段。
|
|
1303
|
+
*
|
|
1304
|
+
* 后续过滤、渲染、发送和缓存均继续使用统一的动态推送链路。
|
|
1305
|
+
*/
|
|
1306
|
+
const createLiveDynamicItem = (sessionId, liveStartedAt, liveInfo, liveStatus) => {
|
|
1307
|
+
const content = JSON.stringify({
|
|
1308
|
+
live_play_info: {
|
|
1309
|
+
area_name: liveInfo.area_name,
|
|
1310
|
+
cover: liveInfo.user_cover || liveStatus.cover,
|
|
1311
|
+
room_id: liveInfo.room_id,
|
|
1312
|
+
title: liveInfo.title || liveStatus.title
|
|
1313
|
+
}
|
|
1314
|
+
});
|
|
1315
|
+
return {
|
|
1316
|
+
id_str: sessionId,
|
|
1317
|
+
type: amagi_1.DynamicType.LIVE_RCMD,
|
|
1318
|
+
modules: {
|
|
1319
|
+
module_author: {
|
|
1320
|
+
face: '',
|
|
1321
|
+
pendant: { image: '' },
|
|
1322
|
+
pub_ts: Math.floor(Date.parse(liveStartedAt) / 1000)
|
|
1323
|
+
},
|
|
1324
|
+
module_dynamic: {
|
|
1325
|
+
additional: null,
|
|
1326
|
+
desc: null,
|
|
1327
|
+
major: {
|
|
1328
|
+
live_rcmd: { content, reserve_type: 0 },
|
|
1329
|
+
type: amagi_1.MajorType.LIVE_RCMD
|
|
1330
|
+
},
|
|
1331
|
+
topic: null
|
|
1332
|
+
}
|
|
1333
|
+
}
|
|
1334
|
+
};
|
|
1335
|
+
};
|
|
1336
|
+
/** 将未知异常转换为适合业务日志展示的文本。 */
|
|
1337
|
+
const formatErrorMessage = (error) => (error instanceof Error ? error.message : String(error));
|
|
1338
|
+
/**
|
|
1339
|
+
* 将换行符替换为HTML的<br>标签。
|
|
1340
|
+
* @param data 需要进行换行符替换的字符串。
|
|
1341
|
+
* @returns 替换后的字符串,其中的换行符\n被<br>替换。
|
|
1342
|
+
*/
|
|
1343
|
+
const br = (data) => {
|
|
1344
|
+
// 使用正则表达式将所有换行符替换为<br>
|
|
1345
|
+
return (data = data.replace(/\n/g, '<br>'));
|
|
1346
|
+
};
|
|
1347
|
+
/**
|
|
1348
|
+
* 根据动态类型构造用于「解析」按钮的地址。
|
|
1349
|
+
* 视频动态使用 BV 视频地址,其余动态使用动态地址;直播动态返回空字符串(不追加按钮)。
|
|
1350
|
+
* @param PushItem 推送项
|
|
1351
|
+
* @returns 解析地址,无法解析时返回空字符串
|
|
1352
|
+
*/
|
|
1353
|
+
const buildParseUrl = (PushItem) => {
|
|
1354
|
+
switch (PushItem.dynamic_type) {
|
|
1355
|
+
case amagi_1.DynamicType.AV: {
|
|
1356
|
+
const bvid = PushItem.Dynamic_Data.modules.module_dynamic.major?.archive?.bvid;
|
|
1357
|
+
return bvid ? `https://www.bilibili.com/video/${bvid}` : '';
|
|
1358
|
+
}
|
|
1359
|
+
case amagi_1.DynamicType.LIVE_RCMD:
|
|
1360
|
+
return '';
|
|
1361
|
+
default:
|
|
1362
|
+
return `https://t.bilibili.com/${PushItem.Dynamic_Data.id_str}`;
|
|
1363
|
+
}
|
|
1364
|
+
};
|
|
1365
|
+
/**
|
|
1366
|
+
* 判断标题是否有屏蔽词或屏蔽标签
|
|
1367
|
+
* @param PushItem 推送项
|
|
1368
|
+
* @returns 是否应该跳过推送
|
|
1369
|
+
*/
|
|
1370
|
+
const skipDynamic = async (PushItem) => {
|
|
1371
|
+
const tags = [];
|
|
1372
|
+
// 提取标签
|
|
1373
|
+
if (PushItem.Dynamic_Data.modules.module_dynamic?.desc?.rich_text_nodes) {
|
|
1374
|
+
for (const node of PushItem.Dynamic_Data.modules.module_dynamic.desc.rich_text_nodes) {
|
|
1375
|
+
if (node.type === 'topic') {
|
|
1376
|
+
if (node.orig_text) {
|
|
1377
|
+
tags.push(node.orig_text);
|
|
1378
|
+
}
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
}
|
|
1382
|
+
// 检查转发的原动态标签
|
|
1383
|
+
if (PushItem.Dynamic_Data.type === amagi_1.DynamicType.FORWARD && 'orig' in PushItem.Dynamic_Data) {
|
|
1384
|
+
if (PushItem.Dynamic_Data.orig.modules.module_dynamic.major.type === amagi_1.MajorType.DRAW ||
|
|
1385
|
+
PushItem.Dynamic_Data.orig.modules.module_dynamic.major.type === amagi_1.MajorType.OPUS ||
|
|
1386
|
+
PushItem.Dynamic_Data.orig.modules.module_dynamic.major.type === amagi_1.MajorType.LIVE_RCMD) {
|
|
1387
|
+
for (const node of PushItem.Dynamic_Data.orig.modules.module_dynamic.major.opus.summary.rich_text_nodes) {
|
|
1388
|
+
if (node.type === 'topic') {
|
|
1389
|
+
tags.push(node.orig_text);
|
|
1390
|
+
}
|
|
1391
|
+
}
|
|
1392
|
+
}
|
|
1393
|
+
}
|
|
1394
|
+
node_karin_1.logger.debug(`检查动态是否需要过滤:https://t.bilibili.com/${PushItem.Dynamic_Data.id_str}`);
|
|
1395
|
+
const shouldFilter = await module_1.bilibiliDB.shouldFilter(PushItem, tags);
|
|
1396
|
+
return shouldFilter;
|
|
1397
|
+
};
|