@lf_maple/koishi-plugin-phi-plugin-full 0.1.80
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/LICENSE +22 -0
- package/core/.github/ISSUE_TEMPLATE/bug.yaml +133 -0
- package/core/.github/ISSUE_TEMPLATE/config.yml +1 -0
- package/core/.github/ISSUE_TEMPLATE/enhancement.yml +44 -0
- package/core/.vscode/c_cpp_properties.json +18 -0
- package/core/.vscode/launch.json +24 -0
- package/core/.vscode/settings.json +59 -0
- package/core/CHANGELOG.md +184 -0
- package/core/LICENSE +674 -0
- package/core/README.md +330 -0
- package/core/README_en.md +285 -0
- package/core/apps/Dan.js +129 -0
- package/core/apps/RankList.js +322 -0
- package/core/apps/aliasProposal.js +223 -0
- package/core/apps/apiSetting.js +592 -0
- package/core/apps/b19.js +1329 -0
- package/core/apps/botClient.js +64 -0
- package/core/apps/chart.js +692 -0
- package/core/apps/guessGame/guessIll.js +821 -0
- package/core/apps/guessGame/guessLetter.js +831 -0
- package/core/apps/guessGame/guessTips.js +254 -0
- package/core/apps/guessGame/letterGameUtils.js +74 -0
- package/core/apps/guessGame.js +214 -0
- package/core/apps/help.js +117 -0
- package/core/apps/manage.js +288 -0
- package/core/apps/market.js +243 -0
- package/core/apps/money.js +1064 -0
- package/core/apps/phisong.js +1418 -0
- package/core/apps/session.js +664 -0
- package/core/apps/setting.js +468 -0
- package/core/apps/update.js +541 -0
- package/core/apps/user.js +968 -0
- package/core/components/Config.js +249 -0
- package/core/components/Data.js +304 -0
- package/core/components/FileWatcherRegistry.js +102 -0
- package/core/components/Logger.js +11 -0
- package/core/components/ProcessCleanup.js +113 -0
- package/core/components/Version.js +56 -0
- package/core/components/YamlReader.js +157 -0
- package/core/components/baseClass.js +287 -0
- package/core/components/common.js +47 -0
- package/core/components/index.js +13 -0
- package/core/components/platform/index.js +79 -0
- package/core/components/platform/koishi.js +800 -0
- package/core/components/platform/koishiDatabaseRedis.js +391 -0
- package/core/components/platform/memoryRedis.js +209 -0
- package/core/components/platform/types.d.ts +272 -0
- package/core/components/platform/yunzai.js +604 -0
- package/core/components/segment.js +4 -0
- package/core/config/config//350/277/231/351/207/214/346/230/257/351/205/215/347/275/256/346/226/207/344/273/266/347/233/256/345/275/225.txt +0 -0
- package/core/config/default_config/banGroup.yaml +14 -0
- package/core/config/default_config/config.yaml +159 -0
- package/core/config/default_config/nickconfig.yaml +6 -0
- package/core/config/default_config/otherinfo.yaml +51 -0
- package/core/guoba.support.js +597 -0
- package/core/index.js +85 -0
- package/core/lib/AES.js +40 -0
- package/core/lib/Base64.js +22 -0
- package/core/lib/ByteReader.js +168 -0
- package/core/lib/GameProgress.js +37 -0
- package/core/lib/GameRecord.js +47 -0
- package/core/lib/GameSettings.js +24 -0
- package/core/lib/GameUser.js +19 -0
- package/core/lib/Level.js +6 -0
- package/core/lib/LevelRecord.js +9 -0
- package/core/lib/PhigrosUser.js +135 -0
- package/core/lib/SaveManager.js +117 -0
- package/core/lib/Summary.js +47 -0
- package/core/lib/TapTap/CompleteQRCodeData.js +27 -0
- package/core/lib/TapTap/LCHelper.js +81 -0
- package/core/lib/TapTap/TapTapHelper.js +170 -0
- package/core/lib/TapTap/getQRcode.js +61 -0
- package/core/lib/Util.js +30 -0
- package/core/lib/getQRcode.js +73 -0
- package/core/lib/http.js +105 -0
- package/core/model/README.md +3 -0
- package/core/model/api/aliasProposalService.js +151 -0
- package/core/model/api/apiVersion.js +67 -0
- package/core/model/api/autoSeekApi.js +165 -0
- package/core/model/api/botApiAuth.js +208 -0
- package/core/model/api/botSyncService.js +78 -0
- package/core/model/api/gameRecordPayload.js +24 -0
- package/core/model/api/makeRequest.js +1004 -0
- package/core/model/api/makeRequestFnc.js +17 -0
- package/core/model/api/phiApiClient.js +53 -0
- package/core/model/api/phiApiErrors.js +121 -0
- package/core/model/filesystem/getFile.js +256 -0
- package/core/model/filesystem/path.js +84 -0
- package/core/model/game/Chart.js +57 -0
- package/core/model/game/LevelRecordInfo.js +109 -0
- package/core/model/game/SongsInfo.js +46 -0
- package/core/model/game/b30Analysis.js +93 -0
- package/core/model/game/chartParser/Chart.js +23 -0
- package/core/model/game/chartParser/JudgeLine.js +38 -0
- package/core/model/game/chartParser/base/JudgeLineEvent.js +99 -0
- package/core/model/game/chartParser/base/Note.js +44 -0
- package/core/model/game/chartParser/base/SpeedEvent.js +25 -0
- package/core/model/game/chartParser/base/baseType.js +2 -0
- package/core/model/game/constNum.js +215 -0
- package/core/model/game/fCompute.js +711 -0
- package/core/model/game/getChartTag.js +140 -0
- package/core/model/game/getComment.js +132 -0
- package/core/model/game/getInfo.js +1069 -0
- package/core/model/game/getRksRank.js +77 -0
- package/core/model/game/markdown.js +77 -0
- package/core/model/integrations/Vika.js +103 -0
- package/core/model/integrations/getInfoFromTap.js +80 -0
- package/core/model/render/getPic.js +79 -0
- package/core/model/render/picmodle.js +496 -0
- package/core/model/render/progress-bar.js +44 -0
- package/core/model/render/puppeteer.js +431 -0
- package/core/model/render/renderPressureHistory.js +71 -0
- package/core/model/render/send.js +94 -0
- package/core/model/save/Save.js +953 -0
- package/core/model/save/analyzeSaveHistory.js +413 -0
- package/core/model/save/getBackup.js +328 -0
- package/core/model/save/getSave.js +90 -0
- package/core/model/save/getSaveFromApi.js +46 -0
- package/core/model/save/saveHistory.js +586 -0
- package/core/model/save/scoreHistory.js +101 -0
- package/core/model/theme/catalog.js +192 -0
- package/core/model/theme/installGuard.js +275 -0
- package/core/model/theme/installLock.js +174 -0
- package/core/model/theme/installer.js +398 -0
- package/core/model/theme/manager.js +408 -0
- package/core/model/theme/marketClient.js +294 -0
- package/core/model/theme/paths.js +42 -0
- package/core/model/theme/policy.js +54 -0
- package/core/model/theme/recovery.js +167 -0
- package/core/model/theme/useService.js +187 -0
- package/core/model/type/aliasProposal.d.ts +45 -0
- package/core/model/type/type.js +420 -0
- package/core/model/user/apiPermission.js +62 -0
- package/core/model/user/getBanGroup.js +120 -0
- package/core/model/user/getNotes.js +48 -0
- package/core/model/user/pluginData.js +101 -0
- package/core/model/user/userCredentialStore.js +154 -0
- package/core/model/user/userCredentials.js +860 -0
- package/core/package.json +60 -0
- package/core/resources/0608badSave/save.json +1 -0
- package/core/resources/LICENSE +201 -0
- package/core/resources/html/analyzeSaveHistory/analyzeSaveHistory.art +220 -0
- package/core/resources/html/analyzeSaveHistory/analyzeSaveHistory.css +345 -0
- package/core/resources/html/analyzeSaveHistory/analyzeSaveHistory.html +434 -0
- package/core/resources/html/arcgrosB19/arcgros.png +0 -0
- package/core/resources/html/arcgrosB19/arcgrosB19-orz.html +276 -0
- package/core/resources/html/arcgrosB19/arcgrosB19.art +168 -0
- package/core/resources/html/arcgrosB19/arcgrosB19.css +637 -0
- package/core/resources/html/atlas/atlas-orz.html +313 -0
- package/core/resources/html/atlas/atlas.art +194 -0
- package/core/resources/html/atlas/atlas.css +695 -0
- package/core/resources/html/avatar/-SURREALISM-.png +0 -0
- package/core/resources/html/avatar/Alkaid.png +0 -0
- package/core/resources/html/avatar/Aphasia.png +0 -0
- package/core/resources/html/avatar/Artificial Existence.png +0 -0
- package/core/resources/html/avatar/Bonus Time.png +0 -0
- package/core/resources/html/avatar/Burn.png +0 -0
- package/core/resources/html/avatar/Cereris1.png +0 -0
- package/core/resources/html/avatar/Cereris2.png +0 -0
- package/core/resources/html/avatar/Cereris3.png +0 -0
- package/core/resources/html/avatar/Christmas -2019.png +0 -0
- package/core/resources/html/avatar/Cipher1.png +0 -0
- package/core/resources/html/avatar/Class Memories.png +0 -0
- package/core/resources/html/avatar/Credits.png +0 -0
- package/core/resources/html/avatar/Dash.png +0 -0
- package/core/resources/html/avatar/Dlyrotz.png +0 -0
- package/core/resources/html/avatar/Doppelganger1.png +0 -0
- package/core/resources/html/avatar/Doppelganger2.png +0 -0
- package/core/resources/html/avatar/Drop it.png +0 -0
- package/core/resources/html/avatar/Energy Synergy Matrix1.png +0 -0
- package/core/resources/html/avatar/Energy Synergy Matrix2.png +0 -0
- package/core/resources/html/avatar/Energy Synergy Matrix3.png +0 -0
- package/core/resources/html/avatar/Engine x Start!! (melody mix).png +0 -0
- package/core/resources/html/avatar/Engine x Start!! extra 1 -by cycats.png +0 -0
- package/core/resources/html/avatar/Eradication Catastrophe.png +0 -0
- package/core/resources/html/avatar/FULi AUTO SHOOTER extra 1 -by cycats.png +0 -0
- package/core/resources/html/avatar/FULi AUTO SHOOTER.png +0 -0
- package/core/resources/html/avatar/Feast/350/277/234/344/270/234/344/271/213/345/256/264-Special1.png +0 -0
- package/core/resources/html/avatar/Feast/350/277/234/344/270/234/344/271/213/345/256/264-Special2.png +0 -0
- package/core/resources/html/avatar/Feast/350/277/234/344/270/234/344/271/213/345/256/2641.png +0 -0
- package/core/resources/html/avatar/Feast/350/277/234/344/270/234/344/271/213/345/256/2642.png +0 -0
- package/core/resources/html/avatar/Feast/350/277/234/344/270/234/344/271/213/345/256/2643.png +0 -0
- package/core/resources/html/avatar/Feast/350/277/234/344/270/234/344/271/213/345/256/2644.png +0 -0
- package/core/resources/html/avatar/Feast/350/277/234/344/270/234/344/271/213/345/256/2645.png +0 -0
- package/core/resources/html/avatar/Feast/350/277/234/344/270/234/344/271/213/345/256/2646.png +0 -0
- package/core/resources/html/avatar/Feast/350/277/234/344/270/234/344/271/213/345/256/2647.png +0 -0
- package/core/resources/html/avatar/Feast/350/277/234/344/270/234/344/271/213/345/256/2648.png +0 -0
- package/core/resources/html/avatar/Feast/350/277/234/344/270/234/344/271/213/345/256/2649.png +0 -0
- package/core/resources/html/avatar/Find_Me.png +0 -0
- package/core/resources/html/avatar/Geopelia 1 -by cycats.png +0 -0
- package/core/resources/html/avatar/Geopelia 2 -by cycats.png +0 -0
- package/core/resources/html/avatar/Geopelia 3 -by /344/275/225/345/221/265.png +0 -0
- package/core/resources/html/avatar/Geopelia in WEPLAY -by /346/265/267/344/272/247.png +0 -0
- package/core/resources/html/avatar/Gino-AprilFool.png +0 -0
- package/core/resources/html/avatar/Glaciaxion.png +0 -0
- package/core/resources/html/avatar/HumaN.png +0 -0
- package/core/resources/html/avatar/Indelible Scar.png +0 -0
- package/core/resources/html/avatar/Introduction.png +0 -0
- package/core/resources/html/avatar/Khronostasis Katharsis.png +0 -0
- package/core/resources/html/avatar/MARENOL.png +0 -0
- package/core/resources/html/avatar/Marenol extra 1 -by /345/226/265n/350/221/265.png +0 -0
- package/core/resources/html/avatar/Non-Melodic Ragez (MUG Edit).png +0 -0
- package/core/resources/html/avatar/Non-Melodic Ragez extra 1 -by cycats.png +0 -0
- package/core/resources/html/avatar/Oblivion +0 -0
- package/core/resources/html/avatar/OblivionPHIN.png +0 -0
- package/core/resources/html/avatar/Para.png +0 -0
- package/core/resources/html/avatar/Pixel Rebelz1.png +0 -0
- package/core/resources/html/avatar/Pixel Rebelz2.png +0 -0
- package/core/resources/html/avatar/Pixel Rebelz3.png +0 -0
- package/core/resources/html/avatar/RIPPER extra 1 -by cycats.png +0 -0
- package/core/resources/html/avatar/RIPPER extra 2 -by /344/275/225/345/221/265.png +0 -0
- package/core/resources/html/avatar/Sein.png +0 -0
- package/core/resources/html/avatar/ShineAfter-/346/260/264/351/235/222-Special.png +0 -0
- package/core/resources/html/avatar/ShineAfter-/346/260/264/351/235/222-Special2.png +0 -0
- package/core/resources/html/avatar/ShineAfter-/346/260/264/351/235/222-/346/231/256/351/200/232.png +0 -0
- package/core/resources/html/avatar/ShineAfter-/346/260/264/351/235/222-/346/233/262/347/273/230Ver.png +0 -0
- package/core/resources/html/avatar/ShineAfter-/351/270/240-Special.png +0 -0
- package/core/resources/html/avatar/ShineAfter-/351/270/240-/346/231/256/351/200/232.png +0 -0
- package/core/resources/html/avatar/ShineAfter-/351/270/240-/346/233/262/347/273/230Ver.png +0 -0
- package/core/resources/html/avatar/ShineAfter-/351/270/240/345/222/214/346/260/264/351/235/222-Special.png +0 -0
- package/core/resources/html/avatar/Snow Desert.png +0 -0
- package/core/resources/html/avatar/Sparkle New Life.png +0 -0
- package/core/resources/html/avatar/Sultan Rage.png +0 -0
- package/core/resources/html/avatar/Winter /342/206/221cube/342/206/223.png +0 -0
- package/core/resources/html/avatar/Xenolith.png +0 -0
- package/core/resources/html/avatar/[PRAW].png +0 -0
- package/core/resources/html/avatar/dB doll.png +0 -0
- package/core/resources/html/avatar/ripper.png +0 -0
- package/core/resources/html/avatar//343/202/202/343/201/272/343/202/202/343/201/2721.png +0 -0
- package/core/resources/html/avatar//343/202/202/343/201/272/343/202/202/343/201/2722.png +0 -0
- package/core/resources/html/avatar//344/270/207/345/220/250/345/214/277/345/220/215/344/277/241.png +0 -0
- package/core/resources/html/avatar//344/272/221/345/245/263/345/255/251 extra 1 -by /345/276/241/345/235/202/346/236/234/345/255/220.png +0 -0
- package/core/resources/html/avatar//344/272/221/345/245/263/345/255/251.png +0 -0
- package/core/resources/html/avatar//345/205/211.png +0 -0
- package/core/resources/html/avatar//345/274/200/345/277/203/347/227/2051.png +0 -0
- package/core/resources/html/avatar//345/274/200/345/277/203/347/227/2052.png +0 -0
- package/core/resources/html/avatar//346/260/264/351/235/222-/344/270/200/345/221/250/345/271/264/347/233/270/350/201/232.png +0 -0
- package/core/resources/html/avatar//346/267/267/344/271/261-Confusion.png +0 -0
- package/core/resources/html/avatar//347/213/202/345/226/234/350/230/255/350/210/2361.png +0 -0
- package/core/resources/html/avatar//347/213/202/345/226/234/350/230/255/350/210/2362.png +0 -0
- package/core/resources/html/avatar//347/223/267/345/262/201-Special.png +0 -0
- package/core/resources/html/avatar//347/223/267/345/262/2011.png +0 -0
- package/core/resources/html/avatar//347/223/267/345/262/2012.png +0 -0
- package/core/resources/html/avatar//347/223/267/345/262/2013.png +0 -0
- package/core/resources/html/avatar//347/223/267/345/262/2014.png +0 -0
- package/core/resources/html/avatar//347/223/267/345/262/2015.png +0 -0
- package/core/resources/html/avatar//347/223/267/345/262/2016.png +0 -0
- package/core/resources/html/avatar//347/223/267/345/262/2017.png +0 -0
- package/core/resources/html/avatar//347/233/217/350/214/227-Special.png +0 -0
- package/core/resources/html/avatar//347/233/217/350/214/2271.png +0 -0
- package/core/resources/html/avatar//347/233/217/350/214/2272.png +0 -0
- package/core/resources/html/avatar//347/233/217/350/214/2273.png +0 -0
- package/core/resources/html/avatar//350/217/257/347/201/257/347/210/2611.png +0 -0
- package/core/resources/html/avatar//350/217/257/347/201/257/347/210/2612.png +0 -0
- package/core/resources/html/avatar//350/220/244/347/201/253/350/231/253/343/201/256/346/200/2501.png +0 -0
- package/core/resources/html/avatar//350/220/244/347/201/253/350/231/253/343/201/256/346/200/2502.png +0 -0
- package/core/resources/html/avatar//351/235/222/350/212/275-Special.png +0 -0
- package/core/resources/html/avatar//351/235/222/350/212/275.png +0 -0
- package/core/resources/html/avatar//351/243/216/345/261/277.png +0 -0
- package/core/resources/html/avatar//351/270/240-AprilFool.png +0 -0
- package/core/resources/html/avatar//351/270/240-/344/270/200/345/221/250/345/271/264/347/233/270/350/201/232.png +0 -0
- package/core/resources/html/b19/b19.art +490 -0
- package/core/resources/html/b19/b19.css +1261 -0
- package/core/resources/html/b19/b19666.art +350 -0
- package/core/resources/html/b19/b19666.css +1409 -0
- package/core/resources/html/b19/b19666.html +481 -0
- package/core/resources/html/b19/b19title.css +120 -0
- package/core/resources/html/b19/best19.html +853 -0
- package/core/resources/html/b19/dss2-orz.html +428 -0
- package/core/resources/html/b19/dss2.art +298 -0
- package/core/resources/html/b19/dss2.css +776 -0
- package/core/resources/html/b19/res/666.jpeg +0 -0
- package/core/resources/html/chap/chap-orz.html +93 -0
- package/core/resources/html/chap/chap.art +87 -0
- package/core/resources/html/chap/chap.css +365 -0
- package/core/resources/html/chartImg/chartImg.art +169 -0
- package/core/resources/html/chartImg/chartImg.css +439 -0
- package/core/resources/html/chartImg/echarts-wordcloud.min.js +3 -0
- package/core/resources/html/chartImg/echarts.js +85796 -0
- package/core/resources/html/chartImg/img/Drag.png +0 -0
- package/core/resources/html/chartImg/img/DragHL.png +0 -0
- package/core/resources/html/chartImg/img/Flick.png +0 -0
- package/core/resources/html/chartImg/img/FlickHL.png +0 -0
- package/core/resources/html/chartImg/img/Hold.png +0 -0
- package/core/resources/html/chartImg/img/HoldHL.png +0 -0
- package/core/resources/html/chartImg/img/Hold_End.png +0 -0
- package/core/resources/html/chartImg/img/Hold_Head.png +0 -0
- package/core/resources/html/chartImg/img/Hold_HeadHL.png +0 -0
- package/core/resources/html/chartImg/img/Tap.png +0 -0
- package/core/resources/html/chartImg/img/TapHL.png +0 -0
- package/core/resources/html/chartInfo/chartInfo-orz.html +250 -0
- package/core/resources/html/chartInfo/chartInfo.art +222 -0
- package/core/resources/html/chartInfo/chartInfo.css +265 -0
- package/core/resources/html/chartInfo/echarts-wordcloud.min.js +3 -0
- package/core/resources/html/chartInfo/echarts.js +85796 -0
- package/core/resources/html/clg/clg-orz.html +218 -0
- package/core/resources/html/clg/clg.art +88 -0
- package/core/resources/html/clg/clg.css +230 -0
- package/core/resources/html/clg/demo.jpg +0 -0
- package/core/resources/html/common/common.css +319 -0
- package/core/resources/html/common/css/playerInfo.css +136 -0
- package/core/resources/html/common/font/Aldrich-Regular.ttf +0 -0
- package/core/resources/html/common/font/HIMALAYA.TTF +0 -0
- package/core/resources/html/common/font/NotoColorEmoji-Regular.ttf +0 -0
- package/core/resources/html/common/font/NotoSans-Regular.ttf +0 -0
- package/core/resources/html/common/font/NotoSansArabic.ttf +0 -0
- package/core/resources/html/common/font/NotoSansCanadianAboriginal.ttf +0 -0
- package/core/resources/html/common/font/NotoSansJP.ttf +0 -0
- package/core/resources/html/common/font/NotoSansKannada.ttf +0 -0
- package/core/resources/html/common/font/NotoSansMath-Regular.ttf +0 -0
- package/core/resources/html/common/font/NotoSansSymbols2.ttf +0 -0
- package/core/resources/html/common/font/phi.ttf +0 -0
- package/core/resources/html/common/font//345/220/236/345/274/245/346/201/260/344/277/212.ttf +0 -0
- package/core/resources/html/common/layout/default.art +324 -0
- package/core/resources/html/common/layout/elem.art +21 -0
- package/core/resources/html/common/theme/snow/snow.css +17 -0
- package/core/resources/html/common/theme/snow/snow.js +19 -0
- package/core/resources/html/common/theme/star/star.js +201 -0
- package/core/resources/html/common/theme/topText/topText.css +15 -0
- package/core/resources/html/common/theme/topText/topText.js +30 -0
- package/core/resources/html/difficultyHistory/difficultyHistory-orz.html +361 -0
- package/core/resources/html/difficultyHistory/difficultyHistory.art +102 -0
- package/core/resources/html/difficultyHistory/difficultyHistory.css +205 -0
- package/core/resources/html/guess/guess-orz.html +50 -0
- package/core/resources/html/guess/guess.art +51 -0
- package/core/resources/html/guess/guess.css +33 -0
- package/core/resources/html/help/help-orz.html +73 -0
- package/core/resources/html/help/help.art +84 -0
- package/core/resources/html/help/help.css +266 -0
- package/core/resources/html/historyB30/historyB30-orz.html +168 -0
- package/core/resources/html/historyB30/historyB30.art +143 -0
- package/core/resources/html/historyB30/historyB30.css +270 -0
- package/core/resources/html/ill/ill-orz.html +21 -0
- package/core/resources/html/ill/ill.art +23 -0
- package/core/resources/html/ill/ill.css +79 -0
- package/core/resources/html/jrrp/ShineAfter.removebg.png +0 -0
- package/core/resources/html/jrrp/jrrp-orz.html +68 -0
- package/core/resources/html/jrrp/jrrp.art +58 -0
- package/core/resources/html/jrrp/jrrp.css +251 -0
- package/core/resources/html/list/list-orz.html +35 -0
- package/core/resources/html/list/list.art +67 -0
- package/core/resources/html/list/list.css +259 -0
- package/core/resources/html/lvsco/demo.jpg +0 -0
- package/core/resources/html/lvsco/lvsco-orz.html +334 -0
- package/core/resources/html/lvsco/lvsco.art +314 -0
- package/core/resources/html/lvsco/lvsco.css +706 -0
- package/core/resources/html/market/detail.art +44 -0
- package/core/resources/html/market/market.art +86 -0
- package/core/resources/html/market/market.css +64 -0
- package/core/resources/html/newSong/newSong.art +34 -0
- package/core/resources/html/newSong/newSong.css +48 -0
- package/core/resources/html/newSong/newSong.html +23 -0
- package/core/resources/html/newnotice/newnotice.art +47 -0
- package/core/resources/html/newnotice/newnotice.css +83 -0
- package/core/resources/html/otherimg/0.png +0 -0
- package/core/resources/html/otherimg/1.png +0 -0
- package/core/resources/html/otherimg/2.png +0 -0
- package/core/resources/html/otherimg/3.png +0 -0
- package/core/resources/html/otherimg/4.png +0 -0
- package/core/resources/html/otherimg/5.png +0 -0
- package/core/resources/html/otherimg/A.png +0 -0
- package/core/resources/html/otherimg/B.png +0 -0
- package/core/resources/html/otherimg/C.png +0 -0
- package/core/resources/html/otherimg/F.png +0 -0
- package/core/resources/html/otherimg/FC.png +0 -0
- package/core/resources/html/otherimg/NEW.png +0 -0
- package/core/resources/html/otherimg/Phigros_Icon_3.0.0.png +0 -0
- package/core/resources/html/otherimg/S.png +0 -0
- package/core/resources/html/otherimg/Star1.png +0 -0
- package/core/resources/html/otherimg/Star2.png +0 -0
- package/core/resources/html/otherimg/V.png +0 -0
- package/core/resources/html/otherimg/callback.png +0 -0
- package/core/resources/html/otherimg/chapHelp.png +0 -0
- package/core/resources/html/otherimg/dan_code.png +0 -0
- package/core/resources/html/otherimg/data.png +0 -0
- package/core/resources/html/otherimg/helpDoc.png +0 -0
- package/core/resources/html/otherimg/nickSuggest.png +0 -0
- package/core/resources/html/otherimg/phi.png +0 -0
- package/core/resources/html/otherimg/phigros.png +0 -0
- package/core/resources/html/otherimg/snow1.png +0 -0
- package/core/resources/html/otherimg/snow2.png +0 -0
- package/core/resources/html/otherimg/snow3.png +0 -0
- package/core/resources/html/otherimg/snow4.png +0 -0
- package/core/resources/html/otherimg/title.png +0 -0
- package/core/resources/html/rand/rand-orz.html +62 -0
- package/core/resources/html/rand/rand.art +59 -0
- package/core/resources/html/rand/rand.css +257 -0
- package/core/resources/html/rankingList/rankingList-orz.html +456 -0
- package/core/resources/html/rankingList/rankingList.art +171 -0
- package/core/resources/html/rankingList/rankingList.css +570 -0
- package/core/resources/html/rankingList-old/rankingList-orz.html +300 -0
- package/core/resources/html/rankingList-old/rankingList.art +89 -0
- package/core/resources/html/rankingList-old/rankingList.css +265 -0
- package/core/resources/html/score/score-orz.html +625 -0
- package/core/resources/html/score/score.art +249 -0
- package/core/resources/html/score/score.css +435 -0
- package/core/resources/html/score/scoreOld-orz.html +128 -0
- package/core/resources/html/score/scoreOld.art +230 -0
- package/core/resources/html/score/scoreOld.css +475 -0
- package/core/resources/html/score/scoreRankList-orz.html +613 -0
- package/core/resources/html/score/scoreRankList.art +231 -0
- package/core/resources/html/score/scoreRankList.css +197 -0
- package/core/resources/html/setting/setting-orz.html +123 -0
- package/core/resources/html/setting/setting.art +72 -0
- package/core/resources/html/setting/setting.css +170 -0
- package/core/resources/html/setting/userSetting-orz.html +132 -0
- package/core/resources/html/setting/userSetting.art +48 -0
- package/core/resources/html/setting/userSetting.css +160 -0
- package/core/resources/html/sign/sign-orz.html +262 -0
- package/core/resources/html/sign/sign.art +163 -0
- package/core/resources/html/sign/sign.css +706 -0
- package/core/resources/html/suggest/suggest.art +271 -0
- package/core/resources/html/suggest/suggest.css +300 -0
- package/core/resources/html/table/table-orz.html +228 -0
- package/core/resources/html/table/table.art +163 -0
- package/core/resources/html/table/table.css +401 -0
- package/core/resources/html/tasks/tasks-orz.html +83 -0
- package/core/resources/html/tasks/tasks.art +118 -0
- package/core/resources/html/tasks/tasks.css +334 -0
- package/core/resources/html/update/update-orz.html +735 -0
- package/core/resources/html/update/update.art +259 -0
- package/core/resources/html/update/update.css +676 -0
- package/core/resources/html/userinfo/userinfo-old-orz.html +408 -0
- package/core/resources/html/userinfo/userinfo-old.art +233 -0
- package/core/resources/html/userinfo/userinfo-old.css +466 -0
- package/core/resources/html/userinfo/userinfo-orz.html +543 -0
- package/core/resources/html/userinfo/userinfo.art +288 -0
- package/core/resources/html/userinfo/userinfo.css +757 -0
- package/core/resources/info/DLC/arc.json +412 -0
- package/core/resources/info/DLC/chunithm.json +1172 -0
- package/core/resources/info/DLC/dynamix.json +455 -0
- package/core/resources/info/DLC/fanshi.json +132 -0
- package/core/resources/info/DLC/lanota.json +412 -0
- package/core/resources/info/DLC/maimai.json +1110 -0
- package/core/resources/info/DLC/orz.json +158 -0
- package/core/resources/info/DLC/rizline.json +40 -0
- package/core/resources/info/DLC/rotaeno.json +159 -0
- package/core/resources/info/DLC/ryceam.json +53 -0
- package/core/resources/info/avatar.txt +109 -0
- package/core/resources/info/chaplist.yaml +102 -0
- package/core/resources/info/help/api.json +83 -0
- package/core/resources/info/help.json +436 -0
- package/core/resources/info/info.csv +315 -0
- package/core/resources/info/infolist.json +1758 -0
- package/core/resources/info/jrrp.json +92 -0
- package/core/resources/info/nicklist.yaml +2373 -0
- package/core/resources/info/notesInfo.json +1 -0
- package/core/resources/info/notice.json +11 -0
- package/core/resources/info/oldInfo/100/change.csv +218 -0
- package/core/resources/info/oldInfo/100/info.json +7 -0
- package/core/resources/info/oldInfo/101/change.csv +218 -0
- package/core/resources/info/oldInfo/101/info.json +7 -0
- package/core/resources/info/oldInfo/102/change.csv +223 -0
- package/core/resources/info/oldInfo/102/info.json +7 -0
- package/core/resources/info/oldInfo/103/change.csv +224 -0
- package/core/resources/info/oldInfo/103/info.json +7 -0
- package/core/resources/info/oldInfo/104/change.csv +225 -0
- package/core/resources/info/oldInfo/104/info.json +7 -0
- package/core/resources/info/oldInfo/105/change.csv +228 -0
- package/core/resources/info/oldInfo/105/info.json +7 -0
- package/core/resources/info/oldInfo/106/change.csv +229 -0
- package/core/resources/info/oldInfo/106/info.json +7 -0
- package/core/resources/info/oldInfo/108/change.csv +233 -0
- package/core/resources/info/oldInfo/108/info.json +7 -0
- package/core/resources/info/oldInfo/109/change.csv +235 -0
- package/core/resources/info/oldInfo/109/info.json +7 -0
- package/core/resources/info/oldInfo/110/change.csv +235 -0
- package/core/resources/info/oldInfo/110/info.json +7 -0
- package/core/resources/info/oldInfo/111/change.csv +242 -0
- package/core/resources/info/oldInfo/111/info.json +7 -0
- package/core/resources/info/oldInfo/112/change.csv +242 -0
- package/core/resources/info/oldInfo/112/info.json +7 -0
- package/core/resources/info/oldInfo/113/change.csv +244 -0
- package/core/resources/info/oldInfo/113/info.json +7 -0
- package/core/resources/info/oldInfo/115/change.csv +247 -0
- package/core/resources/info/oldInfo/115/info.json +7 -0
- package/core/resources/info/oldInfo/116/change.csv +249 -0
- package/core/resources/info/oldInfo/116/info.json +7 -0
- package/core/resources/info/oldInfo/118/change.csv +252 -0
- package/core/resources/info/oldInfo/118/info.json +7 -0
- package/core/resources/info/oldInfo/119/change.csv +255 -0
- package/core/resources/info/oldInfo/119/info.json +7 -0
- package/core/resources/info/oldInfo/120/change.csv +255 -0
- package/core/resources/info/oldInfo/120/info.json +7 -0
- package/core/resources/info/oldInfo/121/change.csv +257 -0
- package/core/resources/info/oldInfo/121/info.json +7 -0
- package/core/resources/info/oldInfo/122/change.csv +260 -0
- package/core/resources/info/oldInfo/122/info.json +7 -0
- package/core/resources/info/oldInfo/123/change.csv +260 -0
- package/core/resources/info/oldInfo/123/info.json +7 -0
- package/core/resources/info/oldInfo/124/change.csv +262 -0
- package/core/resources/info/oldInfo/124/info.json +7 -0
- package/core/resources/info/oldInfo/125/change.csv +266 -0
- package/core/resources/info/oldInfo/125/info.json +7 -0
- package/core/resources/info/oldInfo/126/change.csv +269 -0
- package/core/resources/info/oldInfo/126/info.json +7 -0
- package/core/resources/info/oldInfo/127/change.csv +270 -0
- package/core/resources/info/oldInfo/127/info.json +7 -0
- package/core/resources/info/oldInfo/128/change.csv +273 -0
- package/core/resources/info/oldInfo/128/info.json +7 -0
- package/core/resources/info/oldInfo/129/change.csv +274 -0
- package/core/resources/info/oldInfo/129/info.json +7 -0
- package/core/resources/info/oldInfo/130/change.csv +275 -0
- package/core/resources/info/oldInfo/130/info.json +7 -0
- package/core/resources/info/oldInfo/131/change.csv +278 -0
- package/core/resources/info/oldInfo/131/info.json +7 -0
- package/core/resources/info/oldInfo/132/change.csv +280 -0
- package/core/resources/info/oldInfo/132/info.json +7 -0
- package/core/resources/info/oldInfo/133/change.csv +284 -0
- package/core/resources/info/oldInfo/133/info.json +7 -0
- package/core/resources/info/oldInfo/134/change.csv +286 -0
- package/core/resources/info/oldInfo/134/info.json +7 -0
- package/core/resources/info/oldInfo/135/change.csv +290 -0
- package/core/resources/info/oldInfo/135/info.json +7 -0
- package/core/resources/info/oldInfo/136/change.csv +290 -0
- package/core/resources/info/oldInfo/136/info.json +7 -0
- package/core/resources/info/oldInfo/137/change.csv +293 -0
- package/core/resources/info/oldInfo/137/info.json +7 -0
- package/core/resources/info/oldInfo/138/change.csv +295 -0
- package/core/resources/info/oldInfo/138/info.json +7 -0
- package/core/resources/info/oldInfo/139/change.csv +295 -0
- package/core/resources/info/oldInfo/139/info.json +7 -0
- package/core/resources/info/oldInfo/140/change.csv +298 -0
- package/core/resources/info/oldInfo/140/info.json +7 -0
- package/core/resources/info/oldInfo/141/change.csv +300 -0
- package/core/resources/info/oldInfo/141/info.json +7 -0
- package/core/resources/info/oldInfo/142/change.csv +302 -0
- package/core/resources/info/oldInfo/142/info.json +7 -0
- package/core/resources/info/oldInfo/143/change.csv +303 -0
- package/core/resources/info/oldInfo/143/info.json +7 -0
- package/core/resources/info/oldInfo/144/change.csv +303 -0
- package/core/resources/info/oldInfo/144/info.json +7 -0
- package/core/resources/info/oldInfo/145/change.csv +305 -0
- package/core/resources/info/oldInfo/145/info.json +7 -0
- package/core/resources/info/oldInfo/146/change.csv +305 -0
- package/core/resources/info/oldInfo/146/info.json +7 -0
- package/core/resources/info/oldInfo/148/change.csv +307 -0
- package/core/resources/info/oldInfo/148/info.json +7 -0
- package/core/resources/info/oldInfo/149/change.csv +307 -0
- package/core/resources/info/oldInfo/149/info.json +7 -0
- package/core/resources/info/oldInfo/151/change.csv +309 -0
- package/core/resources/info/oldInfo/151/info.json +7 -0
- package/core/resources/info/oldInfo/152/change.csv +312 -0
- package/core/resources/info/oldInfo/152/info.json +7 -0
- package/core/resources/info/oldInfo/153/change.csv +313 -0
- package/core/resources/info/oldInfo/153/info.json +7 -0
- package/core/resources/info/oldInfo/154/change.csv +315 -0
- package/core/resources/info/oldInfo/154/info.json +7 -0
- package/core/resources/info/oldInfo/92/change.csv +204 -0
- package/core/resources/info/oldInfo/92/info.json +7 -0
- package/core/resources/info/oldInfo/93/change.csv +206 -0
- package/core/resources/info/oldInfo/93/info.json +7 -0
- package/core/resources/info/oldInfo/94/change.csv +209 -0
- package/core/resources/info/oldInfo/94/info.json +7 -0
- package/core/resources/info/oldInfo/95/change.csv +211 -0
- package/core/resources/info/oldInfo/95/info.json +7 -0
- package/core/resources/info/oldInfo/96/change.csv +216 -0
- package/core/resources/info/oldInfo/96/info.json +7 -0
- package/core/resources/info/oldInfo/98/change.csv +216 -0
- package/core/resources/info/oldInfo/98/info.json +7 -0
- package/core/resources/info/oldInfo/99/change.csv +217 -0
- package/core/resources/info/oldInfo/99/info.json +7 -0
- package/core/resources/info/oldNotesInfo.json +1 -0
- package/core/resources/info/sentences.json +1 -0
- package/core/resources/info/spinfo.json +362 -0
- package/core/resources/info/tips.txt +278 -0
- package/core/resources/otherill//351/233/252/351/231/215SP.png +0 -0
- package/core/resources/song-select.html +535 -0
- package/core/resources/themes/README.md +24 -0
- package/core/resources/themes/milthm/A.png +0 -0
- package/core/resources/themes/milthm/B.png +0 -0
- package/core/resources/themes/milthm/C.png +0 -0
- package/core/resources/themes/milthm/F.png +0 -0
- package/core/resources/themes/milthm/FC.png +0 -0
- package/core/resources/themes/milthm/S.png +0 -0
- package/core/resources/themes/milthm/V.png +0 -0
- package/core/resources/themes/milthm/arcgrosB19.css +36 -0
- package/core/resources/themes/milthm/b19.art +464 -0
- package/core/resources/themes/milthm/b19.css +1314 -0
- package/core/resources/themes/milthm/bg.png +0 -0
- package/core/resources/themes/milthm/clg.css +37 -0
- package/core/resources/themes/milthm/difficultyHistory.css +42 -0
- package/core/resources/themes/milthm/font.ttf +0 -0
- package/core/resources/themes/milthm/help.css +36 -0
- package/core/resources/themes/milthm/historyB30.css +48 -0
- package/core/resources/themes/milthm/info.yaml +45 -0
- package/core/resources/themes/milthm/list.css +39 -0
- package/core/resources/themes/milthm/phi.png +0 -0
- package/core/resources/themes/milthm/setting.css +37 -0
- package/core/resources/themes/milthm/sign.css +81 -0
- package/core/resources/themes/milthm/suggest.css +40 -0
- package/core/resources/themes/milthm/table.css +54 -0
- package/core/resources/themes/milthm/update.css +68 -0
- package/core/tests/aliasProposalService.test.js +82 -0
- package/core/tests/apiAccountDeletion.test.js +125 -0
- package/core/tests/apiPermission.test.js +44 -0
- package/core/tests/apiVersion.test.js +55 -0
- package/core/tests/b30Analysis.test.js +38 -0
- package/core/tests/backgroundIllustration.test.js +21 -0
- package/core/tests/botApiAuthRecovery.test.js +148 -0
- package/core/tests/botSyncService.test.js +42 -0
- package/core/tests/fileWatcherRegistry.test.js +44 -0
- package/core/tests/gameRecordPayload.test.js +34 -0
- package/core/tests/guessLetter.test.js +79 -0
- package/core/tests/makeRequestHandling.test.js +118 -0
- package/core/tests/marketOverflow.test.js +31 -0
- package/core/tests/platformTemplateCache.test.js +92 -0
- package/core/tests/pluginDataThemePreference.test.js +36 -0
- package/core/tests/processCleanup.test.js +58 -0
- package/core/tests/puppeteerShutdown.test.js +17 -0
- package/core/tests/renderPressureHistory.test.js +59 -0
- package/core/tests/saveStats.test.js +26 -0
- package/core/tests/themeInstallGuard.test.js +289 -0
- package/core/tests/themeManager.test.js +625 -0
- package/core/tests/themeManagerInit.test.js +11 -0
- package/core/tests/themeMarket.test.js +855 -0
- package/core/tests/themePageRouting.test.js +431 -0
- package/core/tests/themePolicy.test.js +28 -0
- package/core/tests/themeStorageRecovery.test.js +192 -0
- package/core/tests/userCredentialModuleBoundaries.test.js +41 -0
- package/core/tests/userCredentials.test.js +285 -0
- package/core/tsconfig.json +32 -0
- package/core/types/vendor.d.ts +14 -0
- package/lib/index.cjs +358 -0
- package/lib/index.d.cts +182 -0
- package/lib/index.d.ts +182 -0
- package/lib/index.js +320 -0
- package/package.json +74 -0
- package/readme.md +3 -0
|
@@ -0,0 +1,431 @@
|
|
|
1
|
+
import childProcess from "node:child_process"
|
|
2
|
+
import path from "node:path"
|
|
3
|
+
import { pathToFileURL } from "node:url"
|
|
4
|
+
import puppeteer from "puppeteer"
|
|
5
|
+
import timers from "node:timers/promises"
|
|
6
|
+
import fs from "node:fs/promises"
|
|
7
|
+
import { tempPath } from "../filesystem/path.js"
|
|
8
|
+
import logger from "../../components/Logger.js"
|
|
9
|
+
import platform from "../../components/platform/index.js"
|
|
10
|
+
|
|
11
|
+
const Renderer = platform.RendererBase
|
|
12
|
+
const botConfig = platform.getBotConfig()
|
|
13
|
+
|
|
14
|
+
/** @typedef {import('puppeteer').Browser} Browser */
|
|
15
|
+
/** @typedef {import('puppeteer').Page} Page */
|
|
16
|
+
/** @typedef {Record<string, any> & {tplFile?: string, saveId?: string, imgType?: 'jpeg'|'png'|'webp', quality?: number, omitBackground?: boolean, path?: string, multiPage?: boolean, multiPageHeight?: number, pageGotoParams?: Record<string, any>, isRenderTimeout?: boolean}} ScreenshotData */
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* 渲染器实例对外暴露的公共接口(供 picmodle 等消费方做类型推断)
|
|
20
|
+
* @typedef {object} PhiRenderer
|
|
21
|
+
* @property {string} browserId 实例编号
|
|
22
|
+
* @property {(name: string, data?: any) => Promise<any>} screenshot 截图,返回 Buffer / Buffer[] / false
|
|
23
|
+
* @property {() => Promise<any>} browserInit 初始化 / 启动浏览器
|
|
24
|
+
* @property {(force?: boolean) => Promise<any>} restart 重启浏览器
|
|
25
|
+
* @property {() => Promise<void>} shutdown 永久关闭实例
|
|
26
|
+
* @property {() => void} forceShutdown 退出阶段同步结束进程树
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* 插件独立 Puppeteer 渲染器。
|
|
31
|
+
*
|
|
32
|
+
* 不复用宿主渲染器,也不连接外部 WS。每个实例独立启动 Chromium、独立 profile,
|
|
33
|
+
* 避免和 Bot 主渲染器或其他插件互相抢占 / 关闭浏览器。
|
|
34
|
+
*
|
|
35
|
+
* @type {new (config?: any, browserId?: string) => PhiRenderer}
|
|
36
|
+
*/
|
|
37
|
+
class Puppeteer extends Renderer {
|
|
38
|
+
/**
|
|
39
|
+
* @param {any} config
|
|
40
|
+
* @param {string} browserId 实例编号
|
|
41
|
+
*/
|
|
42
|
+
constructor(config = {}, browserId = "0") {
|
|
43
|
+
super({
|
|
44
|
+
id: `phi-puppeteer-${browserId}`,
|
|
45
|
+
type: "image",
|
|
46
|
+
render: "screenshot",
|
|
47
|
+
})
|
|
48
|
+
this.browserId = browserId
|
|
49
|
+
this.browser = /** @type {Browser | false} */ (false)
|
|
50
|
+
this.browserPid = null
|
|
51
|
+
this.initPromise = /** @type {Promise<Browser | false> | null} */ (null)
|
|
52
|
+
this.closing = false
|
|
53
|
+
this.closingPid = null
|
|
54
|
+
this.shutdownRequested = false
|
|
55
|
+
/** @type {string[]} */
|
|
56
|
+
this.shoting = []
|
|
57
|
+
/** 截图数达到时重启浏览器 避免生成速度越来越慢 */
|
|
58
|
+
this.restartNum = config.restartNum || 100
|
|
59
|
+
/** 截图次数 */
|
|
60
|
+
this.renderNum = 0
|
|
61
|
+
/** 空闲多久(ms)后自动关闭浏览器释放资源,0 为不关闭 */
|
|
62
|
+
this.idleTimeout = config.idleTimeout ?? botConfig?.puppeteer_idle ?? 1800000
|
|
63
|
+
/** 空闲定时器 */
|
|
64
|
+
this.idleTimer = /** @type {NodeJS.Timeout | null} */ (null)
|
|
65
|
+
/** 关闭浏览器的超时时间(ms),超时则强制结束进程 */
|
|
66
|
+
this.closeTimeout = config.closeTimeout || 8000
|
|
67
|
+
/** @type {any} */
|
|
68
|
+
this.config = {
|
|
69
|
+
userDataDir: path.resolve(tempPath, "puppeteer", browserId),
|
|
70
|
+
headless: config.headless || "new",
|
|
71
|
+
args: config.args || ["--disable-gpu", "--disable-setuid-sandbox", "--no-sandbox", "--no-zygote"],
|
|
72
|
+
handleSIGINT: false,
|
|
73
|
+
handleSIGTERM: false,
|
|
74
|
+
handleSIGHUP: false,
|
|
75
|
+
}
|
|
76
|
+
if (config.chromiumPath || botConfig?.chromium_path) {
|
|
77
|
+
this.config.executablePath = config.chromiumPath || botConfig?.chromium_path
|
|
78
|
+
}
|
|
79
|
+
/** puppeteer截图超时时间 */
|
|
80
|
+
this.puppeteerTimeout = config.puppeteerTimeout || botConfig?.puppeteer_timeout || 0
|
|
81
|
+
this.pageGotoParams = config.pageGotoParams || {
|
|
82
|
+
timeout: 120000,
|
|
83
|
+
waitUntil: ["networkidle0", "load", "domcontentloaded"],
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* 初始化chromium。并发调用会等待同一个启动 Promise,避免首帧撞上启动锁直接失败。
|
|
89
|
+
* @returns {Promise<Browser | false>}
|
|
90
|
+
*/
|
|
91
|
+
async browserInit() {
|
|
92
|
+
if (this.shutdownRequested) return false
|
|
93
|
+
if (this.browser) return this.browser
|
|
94
|
+
if (this.initPromise) return this.initPromise
|
|
95
|
+
|
|
96
|
+
this.initPromise = this.launchBrowser().finally(() => {
|
|
97
|
+
this.initPromise = null
|
|
98
|
+
})
|
|
99
|
+
return this.initPromise
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** @returns {Promise<Browser | false>} */
|
|
103
|
+
async launchBrowser() {
|
|
104
|
+
logger.info(`[phi-plugin] puppeteer Chromium(${this.browserId}) 启动中...`)
|
|
105
|
+
|
|
106
|
+
const launched = await puppeteer.launch(this.config).catch(async (/** @type {any} */ err) => {
|
|
107
|
+
const errMsg = String(err)
|
|
108
|
+
logger.error(err)
|
|
109
|
+
if (errMsg.includes("Could not find Chromium")) {
|
|
110
|
+
logger.error("没有正确安装 Chromium,可以尝试执行安装命令:node node_modules/puppeteer/install.js")
|
|
111
|
+
} else if (errMsg.includes("cannot open shared object file")) {
|
|
112
|
+
logger.error("没有正确安装 Chromium 运行库")
|
|
113
|
+
} else if (errMsg.includes(this.config.userDataDir)) {
|
|
114
|
+
logger.warn(`[phi-plugin] puppeteer profile 被占用,清理后重试:${this.config.userDataDir}`)
|
|
115
|
+
await fs.rm(this.config.userDataDir, { force: true, recursive: true }).catch(() => { })
|
|
116
|
+
return puppeteer.launch(this.config).catch(retryErr => {
|
|
117
|
+
logger.error(retryErr)
|
|
118
|
+
return false
|
|
119
|
+
})
|
|
120
|
+
}
|
|
121
|
+
return false
|
|
122
|
+
})
|
|
123
|
+
const browser = /** @type {Browser | false} */ (launched)
|
|
124
|
+
|
|
125
|
+
if (!browser) {
|
|
126
|
+
logger.error(`[phi-plugin] puppeteer Chromium(${this.browserId}) 启动失败`)
|
|
127
|
+
return false
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (this.shutdownRequested) {
|
|
131
|
+
await this.stop(browser, browser.process()?.pid)
|
|
132
|
+
return false
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
this.browser = browser
|
|
136
|
+
this.browserPid = browser.process()?.pid
|
|
137
|
+
logger.info(`[phi-plugin] puppeteer Chromium(${this.browserId}) 启动成功 ${browser.wsEndpoint()}`)
|
|
138
|
+
|
|
139
|
+
browser.once("disconnected", () => this.onDisconnected(browser))
|
|
140
|
+
return browser
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** 浏览器意外断开处理,主动关闭时不做任何动作 */
|
|
144
|
+
/** @param {Browser} browser */
|
|
145
|
+
onDisconnected(browser) {
|
|
146
|
+
if (this.closing || this.browser !== browser) return
|
|
147
|
+
logger.warn(`[phi-plugin] puppeteer Chromium(${this.browserId}) 连接已断开,将在下次渲染时重新启动`)
|
|
148
|
+
this.browser = false
|
|
149
|
+
this.browserPid = null
|
|
150
|
+
this.clearIdleTimer()
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* `chromium` 截图
|
|
155
|
+
* @param {string} name
|
|
156
|
+
* @param {ScreenshotData} data 模板参数
|
|
157
|
+
* @return img 不做segment包裹
|
|
158
|
+
*/
|
|
159
|
+
async screenshot(name, data = {}) {
|
|
160
|
+
this.clearIdleTimer()
|
|
161
|
+
if (!(await this.browserInit())) return false
|
|
162
|
+
|
|
163
|
+
data.saveId = `${data.saveId || name.split("/").pop()}_${this.browserId}`
|
|
164
|
+
const resolvedPath = (/** @type {any} */ (this.dealTpl))(name, data)
|
|
165
|
+
if (!resolvedPath) return false
|
|
166
|
+
const savePath = String(resolvedPath)
|
|
167
|
+
|
|
168
|
+
const jobName = `${name}#${Date.now()}`
|
|
169
|
+
this.shoting.push(jobName)
|
|
170
|
+
const start = Date.now()
|
|
171
|
+
/** @type {Page | undefined} */
|
|
172
|
+
let page
|
|
173
|
+
|
|
174
|
+
try {
|
|
175
|
+
const renderPromise = (async () => {
|
|
176
|
+
const browser = this.browser
|
|
177
|
+
if (!browser) throw new Error('浏览器未启动')
|
|
178
|
+
page = await browser.newPage()
|
|
179
|
+
return this.renderPage(page, name, savePath, data, start)
|
|
180
|
+
})()
|
|
181
|
+
const ret = await this.withTimeout(renderPromise, this.puppeteerTimeout, async () => {
|
|
182
|
+
logger.error(`[图片生成][${name}] 截图超时,当前等待队列:${this.shoting.join(",")}`)
|
|
183
|
+
await this.restart(true)
|
|
184
|
+
})
|
|
185
|
+
|
|
186
|
+
this.removeJob(jobName)
|
|
187
|
+
|
|
188
|
+
if (ret.length === 0 || !ret[0]) {
|
|
189
|
+
logger.error(`[图片生成][${name}] 图片生成为空`)
|
|
190
|
+
return false
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
await this.restart()
|
|
194
|
+
this.resetIdleTimer()
|
|
195
|
+
return data.multiPage ? ret : ret[0]
|
|
196
|
+
} catch (/** @type {any} */ err) {
|
|
197
|
+
logger.error(`[图片生成][${name}] 图片生成失败`, err)
|
|
198
|
+
if (!err?.isRenderTimeout) await this.restart(true)
|
|
199
|
+
return false
|
|
200
|
+
} finally {
|
|
201
|
+
this.removeJob(jobName)
|
|
202
|
+
if (page && !page.isClosed()) {
|
|
203
|
+
await page.close().catch((/** @type {any} */ err) => logger.error(err))
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/** @param {string} jobName */
|
|
209
|
+
removeJob(jobName) {
|
|
210
|
+
const idx = this.shoting.indexOf(jobName)
|
|
211
|
+
if (idx >= 0) this.shoting.splice(idx, 1)
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/** @param {Page} page @param {string} name @param {string} savePath @param {ScreenshotData} data @param {number} start */
|
|
215
|
+
async renderPage(page, name, savePath, data, start) {
|
|
216
|
+
const pageHeight = Math.max(1, Number(data.multiPageHeight) || 4000)
|
|
217
|
+
const pageGotoParams = { ...this.pageGotoParams, ...(data.pageGotoParams || {}) }
|
|
218
|
+
await page.goto(pathToFileURL(path.resolve(savePath)).href, pageGotoParams)
|
|
219
|
+
|
|
220
|
+
const body = (await page.$("#container")) || (await page.$("body"))
|
|
221
|
+
if (!body) throw new Error("未找到可截图的页面节点")
|
|
222
|
+
|
|
223
|
+
const boundingBox = await body.boundingBox()
|
|
224
|
+
if (!boundingBox || boundingBox.width <= 0 || boundingBox.height <= 0) {
|
|
225
|
+
throw new Error("页面尺寸为空,无法截图")
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/** @type {any} */
|
|
229
|
+
const screenshotOptions = {
|
|
230
|
+
type: data.imgType || "jpeg",
|
|
231
|
+
omitBackground: data.omitBackground || false,
|
|
232
|
+
quality: data.quality || 90,
|
|
233
|
+
}
|
|
234
|
+
if (data.path) screenshotOptions.path = data.path
|
|
235
|
+
if (data.multiPage) screenshotOptions.type = "jpeg"
|
|
236
|
+
if (screenshotOptions.type === "png") delete screenshotOptions.quality
|
|
237
|
+
|
|
238
|
+
if (!data.multiPage) {
|
|
239
|
+
const buff = await this.toBuffer(body.screenshot(screenshotOptions))
|
|
240
|
+
this.renderNum++
|
|
241
|
+
const kb = (buff.length / 1024).toFixed(2) + "KB"
|
|
242
|
+
logger.mark(`[图片生成][${name}][${this.renderNum}次] ${kb} ${logger.green(`${Date.now() - start}ms`)}`)
|
|
243
|
+
return [buff]
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
const totalHeight = Math.ceil(boundingBox.height)
|
|
247
|
+
const viewportWidth = Math.max(1, Math.ceil(boundingBox.width))
|
|
248
|
+
const num = Math.max(1, Math.ceil(totalHeight / pageHeight))
|
|
249
|
+
const ret = []
|
|
250
|
+
|
|
251
|
+
if (num > 1) {
|
|
252
|
+
await page.setViewport({
|
|
253
|
+
width: viewportWidth,
|
|
254
|
+
height: Math.min(pageHeight, totalHeight) + 100,
|
|
255
|
+
})
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
for (let i = 0; i < num; i++) {
|
|
259
|
+
const remainHeight = totalHeight - pageHeight * i
|
|
260
|
+
const currentHeight = Math.max(1, Math.min(pageHeight, remainHeight))
|
|
261
|
+
if (num > 1) {
|
|
262
|
+
await page.setViewport({
|
|
263
|
+
width: viewportWidth,
|
|
264
|
+
height: currentHeight + (i === num - 1 ? 0 : 100),
|
|
265
|
+
})
|
|
266
|
+
await page.evaluate(`window.scrollTo(0, ${pageHeight * i})`)
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
const buff = await this.toBuffer(num === 1 ? body.screenshot(screenshotOptions) : page.screenshot(screenshotOptions))
|
|
270
|
+
if (num > 2) await timers.setTimeout(200)
|
|
271
|
+
this.renderNum++
|
|
272
|
+
|
|
273
|
+
const kb = (buff.length / 1024).toFixed(2) + "KB"
|
|
274
|
+
logger.mark(`[图片生成][${name}][${i + 1}/${num}] ${kb}`)
|
|
275
|
+
ret.push(buff)
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
if (num > 1) logger.mark(`[图片生成][${name}] 处理完成`)
|
|
279
|
+
return ret
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/** @param {Promise<Uint8Array | Buffer | string>} promise */
|
|
283
|
+
async toBuffer(promise) {
|
|
284
|
+
const buff = await promise
|
|
285
|
+
return Buffer.isBuffer(buff) ? buff : Buffer.from(buff)
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/** @template T @param {Promise<T>} promise @param {number} timeout @param {() => Promise<void>} onTimeout @returns {Promise<T>} */
|
|
289
|
+
async withTimeout(promise, timeout, onTimeout) {
|
|
290
|
+
if (!(timeout > 0)) return promise
|
|
291
|
+
|
|
292
|
+
let timeoutId
|
|
293
|
+
const timeoutPromise = new Promise((_, reject) => {
|
|
294
|
+
timeoutId = setTimeout(async () => {
|
|
295
|
+
try {
|
|
296
|
+
await onTimeout()
|
|
297
|
+
} catch (err) {
|
|
298
|
+
logger.error(err)
|
|
299
|
+
}
|
|
300
|
+
const err = Object.assign(new Error(`截图超时(${timeout}ms)`), { isRenderTimeout: true })
|
|
301
|
+
reject(err)
|
|
302
|
+
}, timeout)
|
|
303
|
+
timeoutId.unref?.()
|
|
304
|
+
})
|
|
305
|
+
|
|
306
|
+
try {
|
|
307
|
+
return await Promise.race([promise, timeoutPromise])
|
|
308
|
+
} finally {
|
|
309
|
+
clearTimeout(timeoutId)
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/** 重启 */
|
|
314
|
+
async restart(force = false) {
|
|
315
|
+
if (this.shutdownRequested) return false
|
|
316
|
+
if (!this.browser) return false
|
|
317
|
+
if (!force && (this.renderNum % this.restartNum !== 0 || this.shoting.length > 0)) return false
|
|
318
|
+
|
|
319
|
+
logger.info(`[phi-plugin] puppeteer Chromium(${this.browserId}) ${force ? "强制" : ""}关闭重启...`)
|
|
320
|
+
const browser = this.browser
|
|
321
|
+
const pid = this.browserPid
|
|
322
|
+
this.closingPid = pid
|
|
323
|
+
this.browser = false
|
|
324
|
+
this.browserPid = null
|
|
325
|
+
this.clearIdleTimer()
|
|
326
|
+
this.closing = true
|
|
327
|
+
try {
|
|
328
|
+
await this.stop(browser, pid)
|
|
329
|
+
} finally {
|
|
330
|
+
this.closingPid = null
|
|
331
|
+
this.closing = false
|
|
332
|
+
}
|
|
333
|
+
return this.browserInit()
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/** 空闲定时器:长时间无渲染时关闭浏览器释放资源 */
|
|
337
|
+
resetIdleTimer() {
|
|
338
|
+
this.clearIdleTimer()
|
|
339
|
+
if (this.shutdownRequested || !(this.idleTimeout > 0)) return
|
|
340
|
+
this.idleTimer = setTimeout(() => {
|
|
341
|
+
if (this.shoting.length > 0 || !this.browser) return
|
|
342
|
+
logger.info(`[phi-plugin] puppeteer Chromium(${this.browserId}) 空闲超过 ${this.idleTimeout / 1000}s,自动关闭释放资源`)
|
|
343
|
+
this.closeBrowser()
|
|
344
|
+
}, this.idleTimeout)
|
|
345
|
+
this.idleTimer.unref?.()
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
clearIdleTimer() {
|
|
349
|
+
if (this.idleTimer) {
|
|
350
|
+
clearTimeout(this.idleTimer)
|
|
351
|
+
this.idleTimer = null
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/** 主动关闭浏览器且不重启,下次渲染时按需重新启动 */
|
|
356
|
+
async closeBrowser() {
|
|
357
|
+
if (!this.browser) return
|
|
358
|
+
this.clearIdleTimer()
|
|
359
|
+
const browser = this.browser
|
|
360
|
+
const pid = this.browserPid
|
|
361
|
+
this.closingPid = pid
|
|
362
|
+
this.browser = false
|
|
363
|
+
this.browserPid = null
|
|
364
|
+
this.closing = true
|
|
365
|
+
try {
|
|
366
|
+
await this.stop(browser, pid)
|
|
367
|
+
} finally {
|
|
368
|
+
this.closingPid = null
|
|
369
|
+
this.closing = false
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
/** 永久关闭实例;退出清理后不允许再次拉起 Chromium。 */
|
|
374
|
+
async shutdown() {
|
|
375
|
+
this.shutdownRequested = true
|
|
376
|
+
this.clearIdleTimer()
|
|
377
|
+
if (this.initPromise) {
|
|
378
|
+
await this.initPromise.catch(() => false)
|
|
379
|
+
}
|
|
380
|
+
await this.closeBrowser()
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
/** 退出事件中只能做同步操作,按最后记录的 PID 强制结束进程树。 */
|
|
384
|
+
forceShutdown() {
|
|
385
|
+
this.shutdownRequested = true
|
|
386
|
+
this.clearIdleTimer()
|
|
387
|
+
const pid = this.browserPid || this.closingPid || (this.browser ? this.browser.process()?.pid : undefined)
|
|
388
|
+
this.browser = false
|
|
389
|
+
this.browserPid = null
|
|
390
|
+
this.closingPid = null
|
|
391
|
+
this.killProcess(pid)
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* 关闭浏览器实例,close 超时则按 PID 强制结束进程树,杜绝孤儿/僵尸进程
|
|
396
|
+
* @param browser 浏览器实例
|
|
397
|
+
* @param pid 浏览器主进程 PID,缺省时取 browser.process()
|
|
398
|
+
*/
|
|
399
|
+
/** @param {Browser} browser @param {number | null | undefined} pid */
|
|
400
|
+
async stop(browser, pid) {
|
|
401
|
+
if (!browser) return
|
|
402
|
+
pid = pid ?? browser.process()?.pid
|
|
403
|
+
try {
|
|
404
|
+
await Promise.race([
|
|
405
|
+
browser.close(),
|
|
406
|
+
timers.setTimeout(this.closeTimeout).then(() => Promise.reject(new Error("close 超时"))),
|
|
407
|
+
])
|
|
408
|
+
} catch (err) {
|
|
409
|
+
logger.error(`[phi-plugin] puppeteer Chromium(${this.browserId}) 正常关闭失败,尝试强制结束进程(${pid})`, err)
|
|
410
|
+
this.killProcess(pid)
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
/** 按 PID 强杀进程树(含子渲染进程) */
|
|
415
|
+
/** @param {number | null | undefined} pid */
|
|
416
|
+
killProcess(pid) {
|
|
417
|
+
if (!pid) return
|
|
418
|
+
try {
|
|
419
|
+
if (process.platform === "win32") {
|
|
420
|
+
childProcess.execFileSync("taskkill", ["/pid", `${pid}`, "/T", "/F"], { stdio: "ignore" })
|
|
421
|
+
} else {
|
|
422
|
+
process.kill(pid, "SIGKILL")
|
|
423
|
+
}
|
|
424
|
+
logger.mark(`[phi-plugin] puppeteer Chromium(${this.browserId}) 进程 ${pid} 已强制结束`)
|
|
425
|
+
} catch (/** @type {any} */ err) {
|
|
426
|
+
logger.debug(`[phi-plugin] puppeteer Chromium(${this.browserId}) 进程 ${pid} 结束失败(可能已退出):${err.message || err}`)
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
export default Puppeteer
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
const MINUTE_MS = 60_000
|
|
2
|
+
const HISTORY_WINDOW_MS = 30 * MINUTE_MS
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 保存最近 30 分钟的绘图压力分钟桶。
|
|
6
|
+
* 同一分钟内发生重连或手动同步时合并窗口,避免重复上报。
|
|
7
|
+
*/
|
|
8
|
+
export class RenderPressureHistory {
|
|
9
|
+
constructor() {
|
|
10
|
+
/** @type {Array<{
|
|
11
|
+
* startedAt: string, endedAt: string, capacity: number, active: number, queued: number,
|
|
12
|
+
* maxActive: number, maxQueued: number, completed: number, failed: number, timedOut: number
|
|
13
|
+
* }>} */
|
|
14
|
+
this.samples = []
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @param {{
|
|
19
|
+
* windowStartedAt: string, capacity: number, active: number, queued: number,
|
|
20
|
+
* maxActive: number, maxQueued: number, completed: number, failed: number, timedOut: number
|
|
21
|
+
* }} snapshot
|
|
22
|
+
* @param {string} [endedAt]
|
|
23
|
+
*/
|
|
24
|
+
record(snapshot, endedAt = new Date().toISOString()) {
|
|
25
|
+
const endedMs = Date.parse(endedAt)
|
|
26
|
+
if (!Number.isFinite(endedMs)) return this.snapshot()
|
|
27
|
+
|
|
28
|
+
const minute = Math.floor(endedMs / MINUTE_MS)
|
|
29
|
+
const previous = this.samples.find(sample => Math.floor(Date.parse(sample.endedAt) / MINUTE_MS) === minute)
|
|
30
|
+
if (previous) {
|
|
31
|
+
previous.startedAt = Date.parse(snapshot.windowStartedAt) < Date.parse(previous.startedAt)
|
|
32
|
+
? snapshot.windowStartedAt
|
|
33
|
+
: previous.startedAt
|
|
34
|
+
previous.endedAt = endedAt
|
|
35
|
+
previous.capacity = snapshot.capacity
|
|
36
|
+
previous.active = snapshot.active
|
|
37
|
+
previous.queued = snapshot.queued
|
|
38
|
+
previous.maxActive = Math.max(previous.maxActive, snapshot.maxActive, snapshot.active)
|
|
39
|
+
previous.maxQueued = Math.max(previous.maxQueued, snapshot.maxQueued, snapshot.queued)
|
|
40
|
+
previous.completed += snapshot.completed
|
|
41
|
+
previous.failed += snapshot.failed
|
|
42
|
+
previous.timedOut += snapshot.timedOut
|
|
43
|
+
} else {
|
|
44
|
+
this.samples.push({
|
|
45
|
+
startedAt: snapshot.windowStartedAt,
|
|
46
|
+
endedAt,
|
|
47
|
+
capacity: snapshot.capacity,
|
|
48
|
+
active: snapshot.active,
|
|
49
|
+
queued: snapshot.queued,
|
|
50
|
+
maxActive: Math.max(snapshot.maxActive, snapshot.active),
|
|
51
|
+
maxQueued: Math.max(snapshot.maxQueued, snapshot.queued),
|
|
52
|
+
completed: snapshot.completed,
|
|
53
|
+
failed: snapshot.failed,
|
|
54
|
+
timedOut: snapshot.timedOut,
|
|
55
|
+
})
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const cutoff = endedMs - HISTORY_WINDOW_MS
|
|
59
|
+
this.samples = this.samples
|
|
60
|
+
.filter(sample => Date.parse(sample.endedAt) > cutoff && Date.parse(sample.endedAt) <= endedMs)
|
|
61
|
+
.sort((a, b) => Date.parse(a.endedAt) - Date.parse(b.endedAt))
|
|
62
|
+
.slice(-30)
|
|
63
|
+
return this.snapshot()
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
snapshot() {
|
|
67
|
+
return this.samples.map(sample => ({ ...sample }))
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export default RenderPressureHistory
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import Config from '../../components/Config.js'
|
|
2
|
+
import { UserCredentials } from '../user/userCredentials.js';
|
|
3
|
+
import Save from "../save/Save.js";
|
|
4
|
+
import logger from "../../components/Logger.js";
|
|
5
|
+
import { canUseApi } from '../user/apiPermission.js';
|
|
6
|
+
import platform from "../../components/platform/index.js";
|
|
7
|
+
|
|
8
|
+
class send {
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* 普通回复,统一经过平台接口。
|
|
12
|
+
* @param {*} e
|
|
13
|
+
* @param {*} msg
|
|
14
|
+
* @param {boolean} [quote=false]
|
|
15
|
+
* @param {{}} [data={}]
|
|
16
|
+
*/
|
|
17
|
+
static async reply(e, msg, quote = false, data = {}) {
|
|
18
|
+
e = platform.wrapEvent(e)
|
|
19
|
+
return platform.reply(e, msg, { quote, ...data })
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* 私聊省略@
|
|
24
|
+
* @param {*} e
|
|
25
|
+
* @param {*} msg
|
|
26
|
+
* @param {boolean} [quote=false] 是否引用回复
|
|
27
|
+
* @param {{}} [data={}] recallMsg等
|
|
28
|
+
*/
|
|
29
|
+
static async send_with_At(e, msg, quote = false, data = {}) {
|
|
30
|
+
e = platform.wrapEvent(e)
|
|
31
|
+
return platform.sendWithAt(e, msg, quote, data)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* 检查存档部分
|
|
36
|
+
* @param {*} e
|
|
37
|
+
* @param {Number} [ver] 存档版本
|
|
38
|
+
* @param {boolean} [send=true] 是否发送提示
|
|
39
|
+
* @returns {Promise<Save|false>} 存档对象或false
|
|
40
|
+
*/
|
|
41
|
+
static async getsave_result(e, ver = undefined, send = true) {
|
|
42
|
+
|
|
43
|
+
let user_save = null
|
|
44
|
+
const credentials = UserCredentials.fromEvent(e)
|
|
45
|
+
let sessionToken = await credentials.getSessionToken()
|
|
46
|
+
const allowApi = await canUseApi(e)
|
|
47
|
+
if (allowApi) {
|
|
48
|
+
try {
|
|
49
|
+
user_save = await credentials.getUpdatedSaveFromApi()
|
|
50
|
+
if (user_save) return user_save.save
|
|
51
|
+
} catch (/**@type {any} */ err) {
|
|
52
|
+
logger.warn(`[phi-plugin] getUpdatedSaveFromApi `, err)
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (!sessionToken) {
|
|
57
|
+
if (send) {
|
|
58
|
+
this.send_with_At(e, `请先绑定sessionToken哦!如果不知道自己的sessionToken可以尝试扫码绑定嗷!\n帮助:/${Config.getUserCfg('config', 'cmdhead')} tk help\n获取二维码:/${Config.getUserCfg('config', 'cmdhead')} bind qrcode\n普通绑定:/${Config.getUserCfg('config', 'cmdhead')} bind <sessionToken>`)
|
|
59
|
+
}
|
|
60
|
+
return false
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
user_save = (await credentials.getUpdatedSaveFromLocal(sessionToken))?.save
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
if (!user_save || (ver && (!user_save.Recordver || user_save.Recordver < ver))) {
|
|
67
|
+
if (send) {
|
|
68
|
+
this.send_with_At(e, `请先更新数据哦!\n格式:/${Config.getUserCfg('config', 'cmdhead')} update`)
|
|
69
|
+
}
|
|
70
|
+
return false
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return user_save
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* 转发到私聊
|
|
78
|
+
* @param {any} e 消息数组e
|
|
79
|
+
* @param {any} msg 发送内容
|
|
80
|
+
*/
|
|
81
|
+
static async pick_send(e, msg) {
|
|
82
|
+
try {
|
|
83
|
+
e = platform.wrapEvent(e)
|
|
84
|
+
await platform.sendPrivate(e, msg)
|
|
85
|
+
await platform.sleep(500)
|
|
86
|
+
} catch (err) {
|
|
87
|
+
logger.error(err)
|
|
88
|
+
this.send_with_At(e, `转发失败QAQ!请尝试在私聊触发命令!`)
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export default send
|