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,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 给原版 WebUI(assets/web 里的 SPA)加一个「QQ 适配器」分类。
|
|
3
|
+
*
|
|
4
|
+
* 原版面板只认 Karin 那份 config.json(接口库 / 通用 / 抖音 / 哔哩哔哩 / 快手 / 小红书 / 推送列表),
|
|
5
|
+
* 而 QQ 专属的那几项(面板、切片、番剧选集表格、卡片 OCR)是 Koishi 侧才有的,
|
|
6
|
+
* 于是这里往打包好的 SPA 里补一个 tab:
|
|
7
|
+
*
|
|
8
|
+
* 1. 分类列表里加 { key: 'qq', label: 'QQ 适配器' };
|
|
9
|
+
* 2. 配置面板的分发 switch 里加 case 'qq',渲染下面生成的组件;
|
|
10
|
+
* 3. 组件用 SPA 自带的字段渲染器,路径一律 ['qq', 字段名],
|
|
11
|
+
* 读写的还是那份整包配置 —— 保存时 POST /kkk/v1/config,
|
|
12
|
+
* 服务端把 qq 拆出来写回 Koishi 的 koishi.yml(见 src/webui.ts)。
|
|
13
|
+
*
|
|
14
|
+
* 字段表来自 src/qqFields.json(和控制台表单同一份),所以两边永远一致。
|
|
15
|
+
* 脚本可反复执行:先删掉上次插入的片段,再按当前字段表重新插入。
|
|
16
|
+
*/
|
|
17
|
+
import fs from 'node:fs'
|
|
18
|
+
import path from 'node:path'
|
|
19
|
+
import { fileURLToPath } from 'node:url'
|
|
20
|
+
|
|
21
|
+
const here = path.dirname(fileURLToPath(import.meta.url))
|
|
22
|
+
const pluginRoot = path.resolve(here, '..')
|
|
23
|
+
const webAssets = path.join(pluginRoot, 'assets', 'web', 'assets')
|
|
24
|
+
|
|
25
|
+
// 用字符码拼反引号,免得本文件自己被模板串语法绊倒
|
|
26
|
+
const BT = String.fromCharCode(96)
|
|
27
|
+
const START = '/*KKK-QQ-START*/'
|
|
28
|
+
const END = '/*KKK-QQ-END*/'
|
|
29
|
+
const COMPONENT = 'KKKQQConfig'
|
|
30
|
+
|
|
31
|
+
const fields = JSON.parse(fs.readFileSync(path.join(pluginRoot, 'src', 'qqFields.json'), 'utf-8'))
|
|
32
|
+
|
|
33
|
+
const q = (value) => BT + String(value) + BT
|
|
34
|
+
const arr = (items) => '[' + items.map(q).join(',') + ']'
|
|
35
|
+
|
|
36
|
+
/** 一个字段 → 一行渲染器调用 */
|
|
37
|
+
function renderField (field) {
|
|
38
|
+
const target = arr(['qq', field.key])
|
|
39
|
+
const args = [target, q(field.label), q(field.description)]
|
|
40
|
+
if (field.type === 'boolean') return 'i(' + args.join(',') + ')'
|
|
41
|
+
const options = ['type:' + q(field.secret ? 'password' : field.type === 'number' ? 'number' : 'text')]
|
|
42
|
+
if (field.type === 'number') {
|
|
43
|
+
options.push('fallback:' + Number(field.default))
|
|
44
|
+
if (field.min !== undefined) options.push('min:' + field.min)
|
|
45
|
+
if (field.max !== undefined) options.push('max:' + field.max)
|
|
46
|
+
} else if (field.secret) {
|
|
47
|
+
options.push('placeholder:' + q('留空则使用公共测试密钥'))
|
|
48
|
+
}
|
|
49
|
+
return 'a(' + args.concat('{' + options.join(',') + '}').join(',') + ')'
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const groups = []
|
|
53
|
+
for (const field of fields) {
|
|
54
|
+
let group = groups.find((item) => item.name === field.group)
|
|
55
|
+
if (!group) groups.push(group = { name: field.group, fields: [] })
|
|
56
|
+
group.fields.push(field)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const sections = groups.map((group) => 'r(' + q(group.name) + ',(0,U.jsx)(U.Fragment,{children:[' + group.fields.map(renderField).join(',') + ']}))').join(',')
|
|
60
|
+
|
|
61
|
+
const componentCode = COMPONENT
|
|
62
|
+
+ '=({config:e,renderers:t})=>{let{renderPageHeader:n,renderSubSection:r,renderSwitch:i,renderTextField:a}=t;return(0,U.jsxs)(U.Fragment,{children:[n('
|
|
63
|
+
+ q('QQ 适配器') + ',' + q('这些设置只对 QQ 平台生效,其它平台不受影响。改完点右下角保存即可,不用重启。') + '),' + sections + ']})}'
|
|
64
|
+
|
|
65
|
+
const CATEGORY = '{key:' + q('qq') + ',label:' + q('QQ 适配器') + ',description:' + q('QQ 平台专属') + '}'
|
|
66
|
+
const SWITCH = ';case' + q('qq') + ':return(0,U.jsx)(' + COMPONENT + ',{...e})'
|
|
67
|
+
const CATEGORY_ANCHOR = ',{key:' + q('pushlist') + ',label:' + q('推送列表') + ',description:' + q('订阅 JSON') + '}'
|
|
68
|
+
const SWITCH_ANCHOR = 'case' + q('pushlist') + ':return(0,U.jsx)(MR,{...e})'
|
|
69
|
+
const COMPONENT_ANCHOR = ',PR=e=>{switch(e.activeFile){'
|
|
70
|
+
|
|
71
|
+
/** 去掉上次插入的组件(按标记切掉) */
|
|
72
|
+
function stripComponent (text) {
|
|
73
|
+
let out = text
|
|
74
|
+
for (;;) {
|
|
75
|
+
const start = out.indexOf(START)
|
|
76
|
+
if (start < 0) return out
|
|
77
|
+
const end = out.indexOf(END, start)
|
|
78
|
+
if (end < 0) return out
|
|
79
|
+
out = out.slice(0, start) + out.slice(end + END.length)
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const files = fs.readdirSync(webAssets).filter((name) => /^index-.*[.]js$/.test(name))
|
|
84
|
+
if (!files.length) throw new Error('找不到 assets/web/assets/index-*.js(WebUI 前端包)')
|
|
85
|
+
|
|
86
|
+
for (const name of files) {
|
|
87
|
+
const file = path.join(webAssets, name)
|
|
88
|
+
let text = fs.readFileSync(file, 'utf-8')
|
|
89
|
+
const before = text.length
|
|
90
|
+
|
|
91
|
+
// 可重复执行:先清掉上次插入的片段
|
|
92
|
+
text = stripComponent(text)
|
|
93
|
+
text = text.split(',' + CATEGORY).join('')
|
|
94
|
+
text = text.split(SWITCH).join('')
|
|
95
|
+
|
|
96
|
+
// 1. 分类列表
|
|
97
|
+
if (!text.includes(CATEGORY_ANCHOR)) throw new Error(name + ':找不到分类列表(前端包可能换版本了,需要重新适配)')
|
|
98
|
+
text = text.replace(CATEGORY_ANCHOR, ',' + CATEGORY + CATEGORY_ANCHOR)
|
|
99
|
+
|
|
100
|
+
// 2. 分发 switch
|
|
101
|
+
if (!text.includes(SWITCH_ANCHOR)) throw new Error(name + ':找不到配置面板的 switch')
|
|
102
|
+
text = text.replace(SWITCH_ANCHOR, SWITCH_ANCHOR + SWITCH)
|
|
103
|
+
|
|
104
|
+
// 3. 组件定义(塞在 PR 前面,同一个模块作用域,能用 U / Q 这些打包期变量)
|
|
105
|
+
if (!text.includes(COMPONENT_ANCHOR)) throw new Error(name + ':找不到配置面板组件')
|
|
106
|
+
text = text.replace(COMPONENT_ANCHOR, ',' + START + componentCode + END + COMPONENT_ANCHOR)
|
|
107
|
+
|
|
108
|
+
fs.writeFileSync(file, text)
|
|
109
|
+
console.log('[kkk] 已注入 QQ 适配器分类: ' + name + '(' + before + ' → ' + text.length + ' 字节)')
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
console.log('[kkk] 完成,共处理 ' + files.length + ' 个文件')
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 信息类命令冒烟测试:`#kkk帮助` / `#kkk版本` / `#kkk更新日志`。
|
|
3
|
+
* 覆盖 Render 兜底、CHANGELOG 解析(兼容层 logs/parseChangelog/range)、运行环境快照。
|
|
4
|
+
*
|
|
5
|
+
* 用法:node scripts/smoke-commands.cjs
|
|
6
|
+
*/
|
|
7
|
+
const fs = require('node:fs'); const path = require('node:path'); const { Context } = require('koishi');
|
|
8
|
+
const pluginRoot = path.resolve(__dirname, '..');
|
|
9
|
+
const dataRoot = path.resolve(pluginRoot, 'data-smoke-cmd');
|
|
10
|
+
fs.mkdirSync(path.join(dataRoot, 'koishi-plugin-kkk', 'config'), { recursive: true });
|
|
11
|
+
const config = JSON.parse(fs.readFileSync(path.join(pluginRoot, 'config/default_config/config.json'), 'utf8'));
|
|
12
|
+
config.app.parseTip = false;
|
|
13
|
+
fs.writeFileSync(path.join(dataRoot, 'koishi-plugin-kkk', 'config', 'config.json'), JSON.stringify(config, null, 2));
|
|
14
|
+
const plugin = require(path.join(pluginRoot, 'lib/index.js'));
|
|
15
|
+
const ctx = new Context();
|
|
16
|
+
const sent = [];
|
|
17
|
+
const fakeBot = { selfId: '10000', platform: 'smoke', status: 1, user: { id: '10000', name: 's' }, ctx,
|
|
18
|
+
sendMessage: async (ch, c) => { sent.push(c); return ['m'] }, getGuild: async () => ({ name: 'g' }), getFriendList: async () => [] };
|
|
19
|
+
Object.defineProperty(ctx, 'bots', { get: () => [fakeBot] });
|
|
20
|
+
const middlewares = [];
|
|
21
|
+
const orig = ctx.middleware.bind(ctx);
|
|
22
|
+
ctx.middleware = (fn, ...rest) => { middlewares.push(fn); return orig(fn, ...rest) };
|
|
23
|
+
ctx.plugin(plugin, { dataPath: dataRoot, debug: true, masters: ['12345'] });
|
|
24
|
+
const makeSession = (content) => ({ content, selfId: '10000', userId: '12345', guildId: '456', channelId: '456', messageId: 'm1', bot: fakeBot, author: { nick: 's' }, username: 's', event: {}, send: async (c) => { sent.push(c); return ['m2'] } });
|
|
25
|
+
async function dispatch (content) {
|
|
26
|
+
const session = makeSession(content); let i = 0;
|
|
27
|
+
const run = async () => { while (i < middlewares.length) { const mw = middlewares[i++]; let cont = false; await mw(session, () => { cont = true; return run() }); if (!cont) return } };
|
|
28
|
+
await run();
|
|
29
|
+
}
|
|
30
|
+
setTimeout(async () => {
|
|
31
|
+
const { commandQueue } = require(path.join(pluginRoot, 'lib/compat/runtime.js'));
|
|
32
|
+
console.log('middlewares=' + middlewares.length + ' commands=' + commandQueue.length);
|
|
33
|
+
for (const cmd of ['#kkk帮助', '#kkk版本', '#kkk更新日志']) {
|
|
34
|
+
try { console.log('--- ' + cmd + ' ---'); await dispatch(cmd); } catch (e) { console.log('FAIL', e.message); }
|
|
35
|
+
}
|
|
36
|
+
console.log('\n共发出 ' + sent.length + ' 条消息');
|
|
37
|
+
for (const c of sent) { const list = Array.isArray(c) ? c : [c]; console.log(list.map((el) => typeof el === 'string' ? el.slice(0, 160) : '[' + (el && el.type) + ']').join(' | ').slice(0, 300)); }
|
|
38
|
+
process.exit(0);
|
|
39
|
+
}, 5000);
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 冒烟测试:控制台配置表单(Schema)与「表单 → config.json」的落地规则。
|
|
3
|
+
*
|
|
4
|
+
* 覆盖:
|
|
5
|
+
* 1. 每个叶子字段都带默认值(控制台里不再是一片空白);
|
|
6
|
+
* 2. 枚举字段都渲染成下拉(union of const),选项里包含默认值,且没有假选项;
|
|
7
|
+
* 3. 默认值能通过 Schema 校验,非法值会被拒绝;
|
|
8
|
+
* 4. **与上游默认值相同的项不写回 config.json** —— 用户直接改文件的内容不会被表单默认值盖掉;
|
|
9
|
+
* 5. 真的改过的项会写回;空数组/空对象仍然算「没填」。
|
|
10
|
+
*
|
|
11
|
+
* 用法:node scripts/smoke-config.cjs
|
|
12
|
+
*/
|
|
13
|
+
const fs = require('node:fs')
|
|
14
|
+
const path = require('node:path')
|
|
15
|
+
const { Context } = require('koishi')
|
|
16
|
+
|
|
17
|
+
const pluginRoot = path.resolve(__dirname, '..')
|
|
18
|
+
const dataRoot = path.resolve(pluginRoot, 'data-smoke-config')
|
|
19
|
+
const cfgDir = path.join(dataRoot, 'koishi-plugin-kkk', 'config')
|
|
20
|
+
const cfgFile = path.join(cfgDir, 'config.json')
|
|
21
|
+
|
|
22
|
+
const defaults = JSON.parse(fs.readFileSync(path.join(pluginRoot, 'config/default_config/config.json'), 'utf8'))
|
|
23
|
+
|
|
24
|
+
/** 模拟「用户之前直接在 config.json 里手改过两处」 */
|
|
25
|
+
fs.mkdirSync(cfgDir, { recursive: true })
|
|
26
|
+
const direct = JSON.parse(JSON.stringify(defaults))
|
|
27
|
+
direct.douyin.videoQuality = '1080p'
|
|
28
|
+
direct.app.renderScale = 150
|
|
29
|
+
fs.writeFileSync(cfgFile, JSON.stringify(direct, null, 2))
|
|
30
|
+
|
|
31
|
+
const results = []
|
|
32
|
+
const check = (name, ok, detail) => {
|
|
33
|
+
results.push({ name, ok })
|
|
34
|
+
console.log((ok ? ' ✅ ' : ' ❌ ') + name + (detail ? ' —— ' + detail : ''))
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const plugin = require(path.join(pluginRoot, 'lib/index.js'))
|
|
38
|
+
const ctx = new Context()
|
|
39
|
+
// 控制台保存后 koishi.yml 里就是「默认值 + 用户改动」这个样子,这里直接把它整份塞进 upstream
|
|
40
|
+
ctx.plugin(plugin, { dataPath: dataRoot, debug: true, upstream: defaults })
|
|
41
|
+
|
|
42
|
+
setTimeout(async () => {
|
|
43
|
+
try {
|
|
44
|
+
const { buildUpstreamSchema } = require(path.join(pluginRoot, 'lib/schema.js'))
|
|
45
|
+
const { applyUpstreamOverrides } = require(path.join(pluginRoot, 'lib/configBridge.js'))
|
|
46
|
+
const schema = buildUpstreamSchema(pluginRoot)
|
|
47
|
+
|
|
48
|
+
console.log('\n[1] 叶子字段都要有默认值')
|
|
49
|
+
let leaf = 0
|
|
50
|
+
let missing = []
|
|
51
|
+
// Koishi 的 Schema 实例本身是**函数**(schema(value) 就是校验),typeof 判断别写成 !== 'object'
|
|
52
|
+
const isSchema = (node) => !!node && (typeof node === 'object' || typeof node === 'function')
|
|
53
|
+
const walkLeaf = (node, fieldPath) => {
|
|
54
|
+
if (!isSchema(node)) return
|
|
55
|
+
if (node.type === 'object') {
|
|
56
|
+
for (const [key, child] of Object.entries(node.dict || {})) walkLeaf(child, fieldPath + '.' + key)
|
|
57
|
+
return
|
|
58
|
+
}
|
|
59
|
+
leaf += 1
|
|
60
|
+
if (!node.type || node.type === 'any') return
|
|
61
|
+
if (!node.meta || node.meta.default === undefined) missing.push(fieldPath)
|
|
62
|
+
}
|
|
63
|
+
for (const [key, child] of Object.entries(schema.dict)) walkLeaf(child, key)
|
|
64
|
+
check('所有叶子字段都有默认值', missing.length === 0, missing.length ? '缺失:' + missing.slice(0, 8).join(', ') : '共 ' + leaf + ' 个叶子字段')
|
|
65
|
+
|
|
66
|
+
console.log('\n[2] 枚举字段渲染成下拉,且选项里含默认值')
|
|
67
|
+
const unions = []
|
|
68
|
+
const walkUnion = (node, fieldPath) => {
|
|
69
|
+
if (!isSchema(node)) return
|
|
70
|
+
if (node.type === 'union') { unions.push({ fieldPath, node }); return }
|
|
71
|
+
if (node.type === 'object') {
|
|
72
|
+
for (const [key, child] of Object.entries(node.dict || {})) walkUnion(child, fieldPath + '.' + key)
|
|
73
|
+
return
|
|
74
|
+
}
|
|
75
|
+
if (node.type === 'array' && node.inner) walkUnion(node.inner, fieldPath + '[]')
|
|
76
|
+
}
|
|
77
|
+
for (const [key, child] of Object.entries(schema.dict)) walkUnion(child, key)
|
|
78
|
+
const noDefaultInOptions = unions.filter((item) => {
|
|
79
|
+
const values = item.node.list.map((option) => option.value)
|
|
80
|
+
const fallback = item.node.meta.default
|
|
81
|
+
if (Array.isArray(fallback)) return fallback.some((value) => !values.includes(value))
|
|
82
|
+
return !values.includes(fallback)
|
|
83
|
+
})
|
|
84
|
+
check('枚举字段数量合理(≥ 25)', unions.length >= 25, unions.length + ' 个下拉字段')
|
|
85
|
+
check('每个下拉都包含自己的默认值', noDefaultInOptions.length === 0, noDefaultInOptions.map((item) => item.fieldPath).join(', '))
|
|
86
|
+
console.log(' 权限类字段:' + JSON.stringify(schema.dict.douyin.dict.loginPerm.list.map((option) => option.value)))
|
|
87
|
+
console.log(' B站画质:' + JSON.stringify(schema.dict.bilibili.dict.videoQuality.list.map((option) => option.value)))
|
|
88
|
+
console.log(' 抖音发送内容:' + JSON.stringify(schema.dict.douyin.dict.sendContent.inner.list.map((option) => option.value)))
|
|
89
|
+
const perms = schema.dict.app.dict.errorLogSendTo.inner.list.map((option) => option.value)
|
|
90
|
+
check('errorLogSendTo 没有混进 console 这种假选项', !perms.includes('console'), perms.join(','))
|
|
91
|
+
|
|
92
|
+
console.log('\n[3] Schema 校验')
|
|
93
|
+
let defaultsOk = true
|
|
94
|
+
try { schema(defaults) } catch (error) { defaultsOk = false; console.log(' ' + error.message) }
|
|
95
|
+
check('默认配置能通过校验', defaultsOk)
|
|
96
|
+
let rejected = false
|
|
97
|
+
try { schema({ douyin: { videoQuality: '999p' } }) } catch { rejected = true }
|
|
98
|
+
check('非法枚举值被拒绝', rejected)
|
|
99
|
+
|
|
100
|
+
console.log('\n[4] 与默认值相同的项不写回 config.json')
|
|
101
|
+
const untouched = applyUpstreamOverrides(defaults)
|
|
102
|
+
const afterUntouched = JSON.parse(fs.readFileSync(cfgFile, 'utf8'))
|
|
103
|
+
check('写回字段数为 0', untouched.changed.length === 0, untouched.changed.slice(0, 5).join(', '))
|
|
104
|
+
check('手改的 douyin.videoQuality 没被覆盖', afterUntouched.douyin.videoQuality === '1080p', afterUntouched.douyin.videoQuality)
|
|
105
|
+
check('手改的 app.renderScale 没被覆盖', afterUntouched.app.renderScale === 150, String(afterUntouched.app.renderScale))
|
|
106
|
+
|
|
107
|
+
console.log('\n[5] 真的改过的项要写回,空容器仍算没填')
|
|
108
|
+
const changedResult = applyUpstreamOverrides({ douyin: { videoQuality: '720p' }, app: { renderScale: 120 }, pushlist: { douyin: [] } })
|
|
109
|
+
const afterChanged = JSON.parse(fs.readFileSync(cfgFile, 'utf8'))
|
|
110
|
+
check('改过的两项都写回了', changedResult.changed.includes('douyin.videoQuality') && changedResult.changed.includes('app.renderScale'), changedResult.changed.join(', '))
|
|
111
|
+
check('config.json 里是新值', afterChanged.douyin.videoQuality === '720p' && afterChanged.app.renderScale === 120, afterChanged.douyin.videoQuality + ' / ' + afterChanged.app.renderScale)
|
|
112
|
+
check('空数组不写回(不算改动)', !changedResult.changed.some((item) => item.startsWith('pushlist')), changedResult.changed.join(', '))
|
|
113
|
+
|
|
114
|
+
const failed = results.filter((item) => !item.ok)
|
|
115
|
+
console.log('\n=== ' + (results.length - failed.length) + '/' + results.length + ' 通过 ===')
|
|
116
|
+
process.exitCode = failed.length ? 1 : 0
|
|
117
|
+
} catch (error) {
|
|
118
|
+
console.error('冒烟测试失败:', error && error.stack ? error.stack : error)
|
|
119
|
+
process.exitCode = 1
|
|
120
|
+
}
|
|
121
|
+
process.exit(process.exitCode || 0)
|
|
122
|
+
}, 4000)
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 抖音解析链路冒烟测试:把 amagi 的抖音接口替换成固定数据,
|
|
3
|
+
* 验证「链接识别 → 作品详情 → 清晰度选档 → 下载 → 发送」在 Koishi 侧是否跑得通。
|
|
4
|
+
* 用途:本机没有抖音 Cookie(接口必被风控)时,仍能验证抖音解析这条最长的业务链路。
|
|
5
|
+
*
|
|
6
|
+
* 用法:node scripts/smoke-douyin.cjs
|
|
7
|
+
*/
|
|
8
|
+
const fs = require('node:fs')
|
|
9
|
+
const path = require('node:path')
|
|
10
|
+
const { Context } = require('koishi')
|
|
11
|
+
|
|
12
|
+
const pluginRoot = path.resolve(__dirname, '..')
|
|
13
|
+
const dataRoot = path.resolve(pluginRoot, 'data-smoke-douyin')
|
|
14
|
+
const cfgDir = path.join(dataRoot, 'koishi-plugin-kkk', 'config')
|
|
15
|
+
fs.mkdirSync(cfgDir, { recursive: true })
|
|
16
|
+
|
|
17
|
+
const VIDEO_URL = 'https://www.w3schools.com/html/mov_bbb.mp4'
|
|
18
|
+
const COVER_URL = 'https://www.w3schools.com/html/pic_trulli.jpg'
|
|
19
|
+
|
|
20
|
+
const config = JSON.parse(fs.readFileSync(path.join(pluginRoot, 'config/default_config/config.json'), 'utf8'))
|
|
21
|
+
config.app.parseTip = false
|
|
22
|
+
config.app.removeCache = true
|
|
23
|
+
config.douyin.videoQuality = '720p'
|
|
24
|
+
config.douyin.sendContent = ['info', 'video']
|
|
25
|
+
config.douyin.switch = true
|
|
26
|
+
config.pushlist = { douyin: [], bilibili: [] }
|
|
27
|
+
fs.writeFileSync(path.join(cfgDir, 'config.json'), JSON.stringify(config, null, 2))
|
|
28
|
+
|
|
29
|
+
// 1) 让 getDouyinID 的短链解析不依赖外网(伪造重定向后的长链)
|
|
30
|
+
const axios = require(path.join(pluginRoot, 'node_modules/axios'))
|
|
31
|
+
const LONG_URL = 'https://www.douyin.com/video/7123456789012345678'
|
|
32
|
+
axios.get = async () => ({ request: { res: { responseUrl: LONG_URL } }, data: '' })
|
|
33
|
+
|
|
34
|
+
// 2) 替换 amagi 的客户端工厂(每个 Base 实例都会新建 client,必须包住工厂)
|
|
35
|
+
const amagi = require('@ikenxuan/amagi')
|
|
36
|
+
const realFactory = amagi.default
|
|
37
|
+
|
|
38
|
+
function makeBitRate (definition, width, height) {
|
|
39
|
+
return {
|
|
40
|
+
gear_name: definition,
|
|
41
|
+
quality_type: 28,
|
|
42
|
+
bit_rate: 1000000,
|
|
43
|
+
FPS: 30,
|
|
44
|
+
// 抖音 Web 端与下载都只认 mp4 封装,选档会按 format === 'mp4' 过滤
|
|
45
|
+
format: 'mp4',
|
|
46
|
+
video_extra: JSON.stringify({ definition }),
|
|
47
|
+
play_addr: { uri: 'v', url_list: [VIDEO_URL], data_size: 700000, width, height }
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function makeDetail () {
|
|
52
|
+
return {
|
|
53
|
+
aweme_id: '7123456789012345678',
|
|
54
|
+
aweme_type: 0,
|
|
55
|
+
is_slides: false,
|
|
56
|
+
desc: '【迁移验证】抖音视频解析测试',
|
|
57
|
+
preview_title: '【迁移验证】抖音视频解析测试',
|
|
58
|
+
create_time: Math.floor(Date.now() / 1000) - 3600,
|
|
59
|
+
share_url: LONG_URL,
|
|
60
|
+
share_info: { share_url: LONG_URL },
|
|
61
|
+
author: {
|
|
62
|
+
uid: '1234567890',
|
|
63
|
+
sec_uid: 'SEC_UID_TEST',
|
|
64
|
+
nickname: '测试作者',
|
|
65
|
+
unique_id: 'test_author',
|
|
66
|
+
signature: '这里是签名',
|
|
67
|
+
avatar_thumb: { url_list: [COVER_URL] },
|
|
68
|
+
avatar_larger: { url_list: [COVER_URL] },
|
|
69
|
+
follower_count: 12345
|
|
70
|
+
},
|
|
71
|
+
statistics: { digg_count: 1234, comment_count: 56, share_count: 78, collect_count: 910, play_count: 111213 },
|
|
72
|
+
images: null,
|
|
73
|
+
music: null,
|
|
74
|
+
video: {
|
|
75
|
+
play_addr: { uri: 'v', url_list: [VIDEO_URL], data_size: 700000, width: 1280, height: 720 },
|
|
76
|
+
play_addr_h264: { uri: 'v', url_list: [VIDEO_URL], data_size: 700000, width: 1280, height: 720 },
|
|
77
|
+
cover: { url_list: [COVER_URL] },
|
|
78
|
+
origin_cover: { url_list: [COVER_URL] },
|
|
79
|
+
dynamic_cover: { url_list: [COVER_URL] },
|
|
80
|
+
duration: 15000,
|
|
81
|
+
ratio: '720p',
|
|
82
|
+
bit_rate: [makeBitRate('1080p', 1920, 1080), makeBitRate('720p', 1280, 720), makeBitRate('540p', 960, 540)]
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
amagi.default = function (options) {
|
|
88
|
+
const client = realFactory(options)
|
|
89
|
+
client.douyin.fetcher.parseWork = async () => ({ success: true, code: 200, message: 'OK', data: { aweme_detail: makeDetail() } })
|
|
90
|
+
client.douyin.fetcher.fetchWorkComments = async () => ({ success: true, code: 200, message: 'OK', data: { comments: [], cursor: 0, has_more: 0, total: 0 } })
|
|
91
|
+
client.douyin.fetcher.fetchEmojiList = async () => ({ success: true, code: 200, message: 'OK', data: { emoji_list: [] } })
|
|
92
|
+
client.douyin.fetcher.fetchUserProfile = async () => ({
|
|
93
|
+
success: true, code: 200, message: 'OK',
|
|
94
|
+
data: {
|
|
95
|
+
user: {
|
|
96
|
+
uid: '1234567890',
|
|
97
|
+
sec_uid: 'SEC_UID_TEST',
|
|
98
|
+
nickname: '测试作者',
|
|
99
|
+
unique_id: 'test_author',
|
|
100
|
+
signature: '这里是签名',
|
|
101
|
+
avatar_thumb: { url_list: [COVER_URL] },
|
|
102
|
+
avatar_larger: { url_list: [COVER_URL] },
|
|
103
|
+
follower_count: 12345,
|
|
104
|
+
following_count: 66,
|
|
105
|
+
total_favorited: 7890,
|
|
106
|
+
aweme_count: 42,
|
|
107
|
+
ip_location: '浙江'
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
})
|
|
111
|
+
return client
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const plugin = require(path.join(pluginRoot, 'lib/index.js'))
|
|
115
|
+
const ctx = new Context()
|
|
116
|
+
const sent = []
|
|
117
|
+
const fakeBot = {
|
|
118
|
+
selfId: '10000', platform: 'smoke', status: 1, user: { id: '10000', name: 'smoke' }, ctx,
|
|
119
|
+
sendMessage: async (channel, content) => { sent.push({ channel, content }); return ['msg-1'] },
|
|
120
|
+
getGuild: async () => ({ name: 'smoke-guild' }),
|
|
121
|
+
getFriendList: async () => []
|
|
122
|
+
}
|
|
123
|
+
Object.defineProperty(ctx, 'bots', { get: () => [fakeBot] })
|
|
124
|
+
|
|
125
|
+
const middlewares = []
|
|
126
|
+
const originalMiddleware = ctx.middleware.bind(ctx)
|
|
127
|
+
ctx.middleware = (fn, ...rest) => { middlewares.push(fn); return originalMiddleware(fn, ...rest) }
|
|
128
|
+
|
|
129
|
+
ctx.plugin(plugin, { dataPath: dataRoot, debug: true, masters: ['12345'], webui: false })
|
|
130
|
+
|
|
131
|
+
const makeSession = (content) => ({
|
|
132
|
+
content, selfId: '10000', userId: '12345', guildId: '456', channelId: '456',
|
|
133
|
+
messageId: 'm1', bot: fakeBot, author: { nick: 'smoke' }, username: 'smoke', event: {},
|
|
134
|
+
send: async (c) => { sent.push({ channel: '456', content: c }); return ['msg-2'] }
|
|
135
|
+
})
|
|
136
|
+
|
|
137
|
+
async function dispatch (content) {
|
|
138
|
+
const session = makeSession(content)
|
|
139
|
+
let index = 0
|
|
140
|
+
const run = async () => {
|
|
141
|
+
while (index < middlewares.length) {
|
|
142
|
+
const middleware = middlewares[index++]
|
|
143
|
+
let continued = false
|
|
144
|
+
await middleware(session, () => { continued = true; return run() })
|
|
145
|
+
if (!continued) return
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
await run()
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
setTimeout(async () => {
|
|
152
|
+
try {
|
|
153
|
+
console.log('=== 抖音链接解析(固定数据) ===')
|
|
154
|
+
await dispatch('https://www.douyin.com/video/7123456789012345678')
|
|
155
|
+
console.log('\n=== 共发出 ' + sent.length + ' 条消息 ===')
|
|
156
|
+
for (const item of sent) {
|
|
157
|
+
const list = Array.isArray(item.content) ? item.content : [item.content]
|
|
158
|
+
console.log('→ ' + list.map((el) => {
|
|
159
|
+
if (typeof el === 'string') return el.slice(0, 160)
|
|
160
|
+
const type = el && el.type ? el.type : typeof el
|
|
161
|
+
const attrs = el && el.attrs ? JSON.stringify(el.attrs).slice(0, 120) : ''
|
|
162
|
+
return '[' + type + '] ' + attrs
|
|
163
|
+
}).join(' | ').slice(0, 400))
|
|
164
|
+
}
|
|
165
|
+
} catch (error) {
|
|
166
|
+
console.error('抖音冒烟测试失败:', error && error.stack ? error.stack : error)
|
|
167
|
+
process.exitCode = 1
|
|
168
|
+
}
|
|
169
|
+
process.exit(process.exitCode || 0)
|
|
170
|
+
}, 5000)
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 冒烟测试:指令注册与分发(去掉 # 前缀,注册成真正的 Koishi 指令)。
|
|
3
|
+
*
|
|
4
|
+
* 覆盖:
|
|
5
|
+
* 1. 33 个 karin 命令注册成了 Koishi 指令(在 \$commander 的指令表里、带说明和选项);
|
|
6
|
+
* 2. 指令的 action 走通:裸写 \`解析 <链接>\` 与带前缀 \`/解析 <链接>\` 都能触发解析面板;
|
|
7
|
+
* 3. 旧的 \`#解析 <链接>\` 仍可用(兜底中间件);
|
|
8
|
+
* 4. 消息里的链接自动解析(链接识别那条路)依旧工作,且遇到指令消息要让路;
|
|
9
|
+
* 5. 面板按钮发出去的就是「不带 # 的指令」,并随平台切换 解析 / 弹幕解析;
|
|
10
|
+
* 6. autoParse=false 时裸链接不再解析。
|
|
11
|
+
*
|
|
12
|
+
* 用法:node scripts/smoke-koishi-commands.cjs
|
|
13
|
+
* 说明:测试用 QQ 平台(platform=qqguild),解析会先出「交互面板」,
|
|
14
|
+
* 既验证了指令链路,又不会真的去下载视频。
|
|
15
|
+
*/
|
|
16
|
+
const fs = require('node:fs')
|
|
17
|
+
const path = require('node:path')
|
|
18
|
+
const { Context } = require('koishi')
|
|
19
|
+
|
|
20
|
+
const pluginRoot = path.resolve(__dirname, '..')
|
|
21
|
+
const dataRoot = path.resolve(pluginRoot, 'data-smoke-kcmd')
|
|
22
|
+
fs.mkdirSync(path.join(dataRoot, 'koishi-plugin-kkk', 'config'), { recursive: true })
|
|
23
|
+
const config = JSON.parse(fs.readFileSync(path.join(pluginRoot, 'config/default_config/config.json'), 'utf8'))
|
|
24
|
+
config.app.parseTip = false
|
|
25
|
+
fs.writeFileSync(path.join(dataRoot, 'koishi-plugin-kkk', 'config', 'config.json'), JSON.stringify(config, null, 2))
|
|
26
|
+
|
|
27
|
+
const plugin = require(path.join(pluginRoot, 'lib/index.js'))
|
|
28
|
+
const ctx = new Context()
|
|
29
|
+
let sent = []
|
|
30
|
+
const fakeBot = {
|
|
31
|
+
selfId: '10000', platform: 'qqguild', status: 1, user: { id: '10000', name: 's' }, ctx,
|
|
32
|
+
sendMessage: async (ch, c) => { sent.push(c); return ['m'] },
|
|
33
|
+
getGuild: async () => ({ name: 'g' }), getFriendList: async () => []
|
|
34
|
+
}
|
|
35
|
+
Object.defineProperty(ctx, 'bots', { get: () => [fakeBot] })
|
|
36
|
+
|
|
37
|
+
// 抓住所有中间件(含 Koishi 指令分发自己的那条),手动串成链
|
|
38
|
+
const middlewares = []
|
|
39
|
+
const original = ctx.middleware.bind(ctx)
|
|
40
|
+
ctx.middleware = (fn, ...rest) => { middlewares.push(fn); return original(fn, ...rest) }
|
|
41
|
+
|
|
42
|
+
ctx.plugin(plugin, { dataPath: dataRoot, debug: true, masters: ['12345'], qqPanel: true })
|
|
43
|
+
|
|
44
|
+
const results = []
|
|
45
|
+
const check = (name, ok, detail) => {
|
|
46
|
+
results.push({ name, ok })
|
|
47
|
+
console.log((ok ? ' ✅ ' : ' ❌ ') + name + (detail ? ' —— ' + detail : ''))
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const URL = 'https://www.bilibili.com/video/BV1xx411c7mD'
|
|
51
|
+
|
|
52
|
+
const makeSession = (content) => ({
|
|
53
|
+
content, selfId: '10000', userId: '12345', guildId: '456', channelId: '456', messageId: 'm1',
|
|
54
|
+
bot: fakeBot, author: { nick: 's' }, username: 's', event: {}, user: { id: '12345' },
|
|
55
|
+
send: async (c) => { sent.push(c); return ['m2'] }
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
/** 读这一次 dispatch 发出的面板内容 */
|
|
59
|
+
const readSent = () => {
|
|
60
|
+
const flat = []
|
|
61
|
+
for (const item of sent) for (const el of (Array.isArray(item) ? item : [item])) flat.push(el)
|
|
62
|
+
const markdown = flat.filter((el) => el && el.type === 'markdown')
|
|
63
|
+
.map((el) => (el.children || []).map((child) => child.attrs && child.attrs.content).join('')).join('\n')
|
|
64
|
+
// 按钮是 markdown 内联的 <qqbot-cmd-input text="…" show="…" />(群聊唯一可用的指令标签)
|
|
65
|
+
const buttons = []
|
|
66
|
+
const pattern = /<qqbot-cmd-input\s+text="([^"]*)"\s+show="([^"]*)"\s+reference="[^"]*"\s*\/>/g
|
|
67
|
+
let matched
|
|
68
|
+
while ((matched = pattern.exec(markdown)) !== null) {
|
|
69
|
+
buttons.push({ data: decodeURIComponent(matched[1]), label: decodeURIComponent(matched[2]) })
|
|
70
|
+
}
|
|
71
|
+
return { sent: sent.length, markdown, buttons }
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** 走中间件链(验证「链接自动解析」和旧的 # 写法) */
|
|
75
|
+
const dispatchMiddleware = async (content) => {
|
|
76
|
+
sent = []
|
|
77
|
+
const session = makeSession(content)
|
|
78
|
+
let index = 0
|
|
79
|
+
const run = async () => {
|
|
80
|
+
while (index < middlewares.length) {
|
|
81
|
+
const middleware = middlewares[index++]
|
|
82
|
+
let continued = false
|
|
83
|
+
await middleware(session, () => { continued = true; return run() })
|
|
84
|
+
if (!continued) return
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
await run()
|
|
88
|
+
return readSent()
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** 走 Koishi 指令的 action(就是指令匹配成功后 Koishi 会调用的那个函数) */
|
|
92
|
+
const runCommand = async (name, content) => {
|
|
93
|
+
const command = ctx.$commander._commandList.find((item) => item.name === name)
|
|
94
|
+
if (!command) throw new Error('没有注册指令: ' + name)
|
|
95
|
+
sent = []
|
|
96
|
+
const session = makeSession(content)
|
|
97
|
+
await command._actions[command._actions.length - 1]({ session, options: {}, args: [] })
|
|
98
|
+
return readSent()
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
setTimeout(async () => {
|
|
102
|
+
try {
|
|
103
|
+
console.log('\n[1] 注册成真正的 Koishi 指令')
|
|
104
|
+
const list = ctx.$commander._commandList
|
|
105
|
+
const names = list.map((item) => item.name)
|
|
106
|
+
const i18n = ctx.i18n._data[''] || {}
|
|
107
|
+
const desc = (name) => i18n['commands.' + name + '.description'] || ''
|
|
108
|
+
check('指令表里有 解析 / 弹幕解析 / kkk帮助', ['解析', '弹幕解析', 'kkk帮助'].every((name) => names.includes(name)), '共 ' + names.length + ' 个')
|
|
109
|
+
check('指令不再是 # 开头', names.every((name) => !name.startsWith('#')))
|
|
110
|
+
check('指令带说明(控制台可见)', desc('解析').length > 0 && desc('弹幕解析').length > 0, '解析: ' + desc('解析') + ' / 弹幕解析: ' + desc('弹幕解析'))
|
|
111
|
+
check('权限类指令也在表里', names.includes('b站登录') && names.includes('设置抖音推送'), names.filter((name) => /登录|推送/.test(name)).length + ' 个')
|
|
112
|
+
const parseCmd = list.find((item) => item.name === '解析')
|
|
113
|
+
check('解析 指令声明了面板用到的选项', ['qn', 'q', 'dm', 'panel'].every((key) => key in (parseCmd._options || {})), Object.keys(parseCmd._options || {}).join(','))
|
|
114
|
+
|
|
115
|
+
console.log('\n[2] 指令 action 走通(裸写与带前缀)')
|
|
116
|
+
const bare = await runCommand('解析', '解析 ' + URL)
|
|
117
|
+
check('「解析 <链接>」触发解析面板', /解析设置/.test(bare.markdown), bare.markdown.split('\n')[0] || '(无输出)')
|
|
118
|
+
const slash = await runCommand('解析', '/解析 ' + URL)
|
|
119
|
+
check('「/解析 <链接>」同样触发', /解析设置/.test(slash.markdown))
|
|
120
|
+
|
|
121
|
+
console.log('\n[3] 面板按钮发的是不带 # 的指令')
|
|
122
|
+
console.log(' 按钮:' + bare.buttons.map((button) => '[' + button.label + ']').join(' '))
|
|
123
|
+
check('按钮里没有 # 前缀', bare.buttons.length > 0 && bare.buttons.every((button) => !String(button.data).startsWith('#')), bare.buttons[0] && bare.buttons[0].data)
|
|
124
|
+
check('按钮文本是 解析/弹幕解析 指令预览', bare.buttons.every((button) => /^(解析|弹幕解析) /.test(String(button.data))), bare.buttons.map((button) => button.data).slice(0, 2).join(' | '))
|
|
125
|
+
check('按钮里不带链接(只放短令牌)', bare.buttons.every((button) => !/https?:\/\//.test(String(button.data))), bare.buttons.map((button) => button.data).join(' | '))
|
|
126
|
+
check('按钮长度可控(≤ 40 字符)', bare.buttons.every((button) => String(button.data).length <= 40), '最长 ' + Math.max(...bare.buttons.map((button) => String(button.data).length)) + ' 字符')
|
|
127
|
+
const danmakuButton = bare.buttons.find((button) => String(button.data).startsWith('弹幕解析 '))
|
|
128
|
+
check('存在「弹幕解析」按钮', !!danmakuButton, danmakuButton && danmakuButton.data)
|
|
129
|
+
check('没有任何按钮带 --panel(点了不会再弹面板)', bare.buttons.every((button) => !String(button.data).includes('--panel')), bare.buttons.map((button) => button.data).join(' | '))
|
|
130
|
+
const { resolvePanelToken } = require(path.join(pluginRoot, 'lib/karin/module/utils/QqPanel.js'))
|
|
131
|
+
const token = (String(bare.buttons[0].data).match(/--p=([0-9a-z]+)/) || [])[1]
|
|
132
|
+
check('短令牌能换回真实链接', resolvePanelToken(token) === URL, token + ' → ' + resolvePanelToken(token))
|
|
133
|
+
|
|
134
|
+
console.log('\n[4] 旧的 # 写法与链接自动解析仍然可用')
|
|
135
|
+
const legacy = await dispatchMiddleware('#解析 ' + URL)
|
|
136
|
+
check('旧的 #解析 仍可用(兜底中间件)', /解析设置/.test(legacy.markdown))
|
|
137
|
+
const link = await dispatchMiddleware(URL)
|
|
138
|
+
check('裸链接触发解析面板', /解析设置/.test(link.markdown))
|
|
139
|
+
check('只发一条(没有重复解析)', link.sent === 1, '共 ' + link.sent + ' 条')
|
|
140
|
+
|
|
141
|
+
console.log('\n[5] 按钮文本能被解析成参数(点下去就是一次带参数的解析)')
|
|
142
|
+
const { parseParseFlags } = require(path.join(pluginRoot, 'lib/karin/module/utils/ParseOverride.js'))
|
|
143
|
+
if (danmakuButton) {
|
|
144
|
+
const flags = parseParseFlags(String(danmakuButton.data))
|
|
145
|
+
check('带上了画质与令牌', flags.override.bilibiliQuality === 16 && !!flags.panelToken, JSON.stringify(flags.override) + ' token=' + flags.panelToken)
|
|
146
|
+
check('指令名决定要不要弹幕(不再用 --dm=1)', String(danmakuButton.data).startsWith('弹幕解析 ') && flags.override.burnDanmaku === undefined)
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
console.log('\n[6] 按钮点击的另一种落地方式:interaction/button 事件')
|
|
150
|
+
{
|
|
151
|
+
sent = []
|
|
152
|
+
const interactionSession = {
|
|
153
|
+
content: '', selfId: '10000', userId: '12345', guildId: '456', channelId: '456', messageId: 'm1',
|
|
154
|
+
bot: fakeBot, author: { nick: 's' }, username: 's', user: { id: '12345' },
|
|
155
|
+
event: { button: { id: 'b1', data: 'kkk版本' } },
|
|
156
|
+
send: async (c) => { sent.push(c); return ['m3'] }
|
|
157
|
+
}
|
|
158
|
+
ctx.emit('interaction/button', interactionSession)
|
|
159
|
+
await new Promise((resolve) => setTimeout(resolve, 1500))
|
|
160
|
+
check('回调按钮事件里的指令被执行了', sent.length > 0, '发出 ' + sent.length + ' 条')
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
console.log('\n[7] 其它指令也走通了同一条 action 包装')
|
|
164
|
+
const version = await runCommand('kkk版本', 'kkk版本')
|
|
165
|
+
check('「kkk版本」有回复', version.sent > 0, '发出 ' + version.sent + ' 条')
|
|
166
|
+
const help = await runCommand('kkk帮助', 'kkk帮助')
|
|
167
|
+
check('「kkk帮助」有回复', help.sent > 0, '发出 ' + help.sent + ' 条')
|
|
168
|
+
|
|
169
|
+
console.log('\n[8] Koishi 没认领时,文本兜底也能跑(宿主 prefix 没配空串的情况)')
|
|
170
|
+
// 假会话没有 argv(等于 Koishi 没把这条当指令),此时必须靠插件自己的文本兜底
|
|
171
|
+
const fallback = await dispatchMiddleware('kkk版本')
|
|
172
|
+
check('无前缀指令文本仍能被执行', fallback.sent > 0, '发出 ' + fallback.sent + ' 条')
|
|
173
|
+
const legacyLink = await dispatchMiddleware(URL)
|
|
174
|
+
check('裸链接走链接识别那条路(照常出面板)', /解析设置/.test(legacyLink.markdown))
|
|
175
|
+
|
|
176
|
+
console.log('\n[9] autoParse=false 时裸链接不再解析')
|
|
177
|
+
const ctx2 = new Context()
|
|
178
|
+
const middlewares2 = []
|
|
179
|
+
const original2 = ctx2.middleware.bind(ctx2)
|
|
180
|
+
ctx2.middleware = (fn, ...rest) => { middlewares2.push(fn); return original2(fn, ...rest) }
|
|
181
|
+
ctx2.plugin(plugin, { dataPath: dataRoot, debug: true, masters: ['12345'], autoParse: false })
|
|
182
|
+
await new Promise((resolve) => setTimeout(resolve, 1500))
|
|
183
|
+
let sent2 = []
|
|
184
|
+
const session2 = {
|
|
185
|
+
content: URL, selfId: '10000', userId: '12345', guildId: '456', channelId: '456', messageId: 'm1',
|
|
186
|
+
bot: { ...fakeBot, sendMessage: async (ch, c) => { sent2.push(c); return ['m'] } },
|
|
187
|
+
author: { nick: 's' }, username: 's', event: {}, user: { id: '12345' },
|
|
188
|
+
send: async (c) => { sent2.push(c); return ['m2'] }
|
|
189
|
+
}
|
|
190
|
+
let index = 0
|
|
191
|
+
const run = async () => {
|
|
192
|
+
while (index < middlewares2.length) {
|
|
193
|
+
const middleware = middlewares2[index++]
|
|
194
|
+
let continued = false
|
|
195
|
+
await middleware(session2, () => { continued = true; return run() })
|
|
196
|
+
if (!continued) return
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
await run()
|
|
200
|
+
check('autoParse=false 时裸链接不解析', sent2.length === 0, '发出 ' + sent2.length + ' 条')
|
|
201
|
+
|
|
202
|
+
const failed = results.filter((item) => !item.ok)
|
|
203
|
+
console.log('\n=== ' + (results.length - failed.length) + '/' + results.length + ' 通过 ===')
|
|
204
|
+
process.exitCode = failed.length ? 1 : 0
|
|
205
|
+
} catch (error) {
|
|
206
|
+
console.error('冒烟测试失败:', error && error.stack ? error.stack : error)
|
|
207
|
+
process.exitCode = 1
|
|
208
|
+
}
|
|
209
|
+
process.exit(process.exitCode || 0)
|
|
210
|
+
}, 5000)
|