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.
Files changed (702) hide show
  1. package/CHANGELOG.md +57 -0
  2. package/LICENSE +674 -0
  3. package/README.md +98 -0
  4. package/assets/web/assets/CronEditor-CYgFpX-g.js +1 -0
  5. package/assets/web/assets/DesktopLayout-iI43ij11.js +1 -0
  6. package/assets/web/assets/MobileLayout-CziU8MCR.js +1 -0
  7. package/assets/web/assets/ThemeSwitch-DFohhwd9.js +1 -0
  8. package/assets/web/assets/index-BRROK0vh.js +47 -0
  9. package/assets/web/assets/index-Dj-StEiS.css +2 -0
  10. package/assets/web/assets/separator-CxcFlCzz.js +1 -0
  11. package/assets/web/favicon.svg +1 -0
  12. package/assets/web/icons.svg +24 -0
  13. package/assets/web/index.html +15 -0
  14. package/assets/webui.html +115 -0
  15. package/client/index.ts +63 -0
  16. package/config/default_config/app.yaml +64 -0
  17. package/config/default_config/bilibili.yaml +116 -0
  18. package/config/default_config/config.json +157 -0
  19. package/config/default_config/cookies.yaml +11 -0
  20. package/config/default_config/douyin.yaml +99 -0
  21. package/config/default_config/kuaishou.yaml +8 -0
  22. package/config/default_config/pushlist.yaml +37 -0
  23. package/config/default_config/request.yaml +22 -0
  24. package/config/default_config/upload.yaml +50 -0
  25. package/config/default_config/xiaohongshu.yaml +23 -0
  26. package/dist/index.js +1 -0
  27. package/lib/compat/axios.js +23 -0
  28. package/lib/compat/cron.js +77 -0
  29. package/lib/compat/esm.js +15 -0
  30. package/lib/compat/express.js +23 -0
  31. package/lib/compat/heroui.js +12 -0
  32. package/lib/compat/lodash.js +33 -0
  33. package/lib/compat/logger.js +118 -0
  34. package/lib/compat/node-karin.js +1053 -0
  35. package/lib/compat/phosphor-icons.js +27 -0
  36. package/lib/compat/qqcard.js +256 -0
  37. package/lib/compat/root.js +44 -0
  38. package/lib/compat/runtime.js +87 -0
  39. package/lib/compat/segment.js +167 -0
  40. package/lib/compat/sqlite3.js +117 -0
  41. package/lib/compat/start.js +7 -0
  42. package/lib/compat/syncConfig.js +65 -0
  43. package/lib/compat/template-react.js +30 -0
  44. package/lib/compat/text.js +65 -0
  45. package/lib/compat/yaml.js +13 -0
  46. package/lib/configBridge.js +91 -0
  47. package/lib/index.js +775 -0
  48. package/lib/karin/app.js +34 -0
  49. package/lib/karin/apps/__ready.js +9 -0
  50. package/lib/karin/apps/admin.js +136 -0
  51. package/lib/karin/apps/help.js +233 -0
  52. package/lib/karin/apps/push.js +291 -0
  53. package/lib/karin/apps/qrlogin.js +176 -0
  54. package/lib/karin/apps/statistics.js +209 -0
  55. package/lib/karin/apps/testPush.js +247 -0
  56. package/lib/karin/apps/tools.js +473 -0
  57. package/lib/karin/apps/update.js +252 -0
  58. package/lib/karin/index.js +37 -0
  59. package/lib/karin/module/db/bilibili.js +831 -0
  60. package/lib/karin/module/db/douyin.js +918 -0
  61. package/lib/karin/module/db/index.js +165 -0
  62. package/lib/karin/module/db/migration.js +199 -0
  63. package/lib/karin/module/db/statistics.js +559 -0
  64. package/lib/karin/module/index.js +94 -0
  65. package/lib/karin/module/server/constants/routes.js +48 -0
  66. package/lib/karin/module/server/controllers/bots.js +230 -0
  67. package/lib/karin/module/server/controllers/config.js +75 -0
  68. package/lib/karin/module/server/controllers/video.js +208 -0
  69. package/lib/karin/module/server/index.js +26 -0
  70. package/lib/karin/module/server/middlewares/auth.js +133 -0
  71. package/lib/karin/module/server/routes/amagi.js +57 -0
  72. package/lib/karin/module/server/routes/api.js +40 -0
  73. package/lib/karin/module/server/routes/index.js +97 -0
  74. package/lib/karin/module/server/routes/ssr.js +16 -0
  75. package/lib/karin/module/server/routes/static.js +43 -0
  76. package/lib/karin/module/utils/Base.js +403 -0
  77. package/lib/karin/module/utils/CardParser.js +487 -0
  78. package/lib/karin/module/utils/Common.js +418 -0
  79. package/lib/karin/module/utils/Config.js +434 -0
  80. package/lib/karin/module/utils/EmojiReaction.js +242 -0
  81. package/lib/karin/module/utils/ErrorHandler/handler.js +114 -0
  82. package/lib/karin/module/utils/ErrorHandler/index.js +55 -0
  83. package/lib/karin/module/utils/ErrorHandler/render.js +182 -0
  84. package/lib/karin/module/utils/ErrorHandler/sender.js +206 -0
  85. package/lib/karin/module/utils/ErrorHandler/strategy.js +41 -0
  86. package/lib/karin/module/utils/ErrorHandler/types.js +2 -0
  87. package/lib/karin/module/utils/ErrorHandler/utils.js +108 -0
  88. package/lib/karin/module/utils/FFmpeg.js +298 -0
  89. package/lib/karin/module/utils/ImageHelper.js +91 -0
  90. package/lib/karin/module/utils/ImageSlice.js +429 -0
  91. package/lib/karin/module/utils/MotionPhoto.js +250 -0
  92. package/lib/karin/module/utils/Network/Downloader.js +413 -0
  93. package/lib/karin/module/utils/Network/ImageDownloader.js +250 -0
  94. package/lib/karin/module/utils/Network/Network.js +332 -0
  95. package/lib/karin/module/utils/Network/ThrottleStream.js +71 -0
  96. package/lib/karin/module/utils/Network/constants.js +129 -0
  97. package/lib/karin/module/utils/Network/helpers.js +174 -0
  98. package/lib/karin/module/utils/Network/index.js +34 -0
  99. package/lib/karin/module/utils/Network/types.js +12 -0
  100. package/lib/karin/module/utils/Networks.js +17 -0
  101. package/lib/karin/module/utils/ParseLock.js +34 -0
  102. package/lib/karin/module/utils/ParseOverride.js +88 -0
  103. package/lib/karin/module/utils/QqCardResolve.js +114 -0
  104. package/lib/karin/module/utils/QqPanel.js +879 -0
  105. package/lib/karin/module/utils/Render/coverTheme.js +256 -0
  106. package/lib/karin/module/utils/Render/index.js +582 -0
  107. package/lib/karin/module/utils/amagiClient.js +338 -0
  108. package/lib/karin/module/utils/avatar.js +201 -0
  109. package/lib/karin/module/utils/bot.js +141 -0
  110. package/lib/karin/module/utils/build-metadata.js +50 -0
  111. package/lib/karin/module/utils/changelog.js +166 -0
  112. package/lib/karin/module/utils/index.js +26 -0
  113. package/lib/karin/module/utils/loginSession.js +259 -0
  114. package/lib/karin/module/utils/parseTip.js +93 -0
  115. package/lib/karin/module/utils/runtime-report.js +140 -0
  116. package/lib/karin/module/utils/semver.js +72 -0
  117. package/lib/karin/module/utils/statisticsAggregate.js +415 -0
  118. package/lib/karin/platform/bilibili/bilibili.js +1805 -0
  119. package/lib/karin/platform/bilibili/comments.js +294 -0
  120. package/lib/karin/platform/bilibili/danmaku.js +555 -0
  121. package/lib/karin/platform/bilibili/dynamic-text.js +827 -0
  122. package/lib/karin/platform/bilibili/genParams.js +37 -0
  123. package/lib/karin/platform/bilibili/getID.js +159 -0
  124. package/lib/karin/platform/bilibili/index.js +24 -0
  125. package/lib/karin/platform/bilibili/live-status.js +40 -0
  126. package/lib/karin/platform/bilibili/login.js +132 -0
  127. package/lib/karin/platform/bilibili/push.js +1397 -0
  128. package/lib/karin/platform/bilibili/riskControl.js +133 -0
  129. package/lib/karin/platform/bilibili/search.js +299 -0
  130. package/lib/karin/platform/common/danmaku-types.js +12 -0
  131. package/lib/karin/platform/douyin/comments.js +310 -0
  132. package/lib/karin/platform/douyin/danmaku.js +893 -0
  133. package/lib/karin/platform/douyin/douyin.js +1145 -0
  134. package/lib/karin/platform/douyin/getID.js +94 -0
  135. package/lib/karin/platform/douyin/index.js +24 -0
  136. package/lib/karin/platform/douyin/login.js +230 -0
  137. package/lib/karin/platform/douyin/push/favorite.js +75 -0
  138. package/lib/karin/platform/douyin/push/index.js +21 -0
  139. package/lib/karin/platform/douyin/push/live.js +69 -0
  140. package/lib/karin/platform/douyin/push/post.js +60 -0
  141. package/lib/karin/platform/douyin/push/recommend.js +74 -0
  142. package/lib/karin/platform/douyin/push/render.js +621 -0
  143. package/lib/karin/platform/douyin/push/types.js +2 -0
  144. package/lib/karin/platform/douyin/push.js +1128 -0
  145. package/lib/karin/platform/douyin/types.js +13 -0
  146. package/lib/karin/platform/douyin/videoQuality.js +222 -0
  147. package/lib/karin/platform/douyin/workType.js +182 -0
  148. package/lib/karin/platform/index.js +20 -0
  149. package/lib/karin/platform/kuaishou/comments.js +91 -0
  150. package/lib/karin/platform/kuaishou/getID.js +43 -0
  151. package/lib/karin/platform/kuaishou/getdata.js +41 -0
  152. package/lib/karin/platform/kuaishou/index.js +20 -0
  153. package/lib/karin/platform/kuaishou/kuaishou.js +122 -0
  154. package/lib/karin/platform/xiaohongshu/comments.js +162 -0
  155. package/lib/karin/platform/xiaohongshu/getID.js +129 -0
  156. package/lib/karin/platform/xiaohongshu/index.js +18 -0
  157. package/lib/karin/platform/xiaohongshu/xiaohongshu.js +643 -0
  158. package/lib/karin/root.js +73 -0
  159. package/lib/karin/setup.js +99 -0
  160. package/lib/karin/types/config/amagi.js +2 -0
  161. package/lib/karin/types/config/app.js +2 -0
  162. package/lib/karin/types/config/bilibili.js +2 -0
  163. package/lib/karin/types/config/cookies.js +2 -0
  164. package/lib/karin/types/config/douyin.js +2 -0
  165. package/lib/karin/types/config/index.js +2 -0
  166. package/lib/karin/types/config/kuaishou.js +2 -0
  167. package/lib/karin/types/config/pushlist.js +2 -0
  168. package/lib/karin/types/config/request.js +2 -0
  169. package/lib/karin/types/config/upload.js +2 -0
  170. package/lib/karin/types/config/xiaohongshu.js +2 -0
  171. package/lib/karin/types/datatypes.js +2 -0
  172. package/lib/karin/types/index.js +18 -0
  173. package/lib/karin/types/netrorks/NetworksConfigType.js +2 -0
  174. package/lib/karin/types/netrorks/index.js +17 -0
  175. package/lib/karin/web.config.js +49 -0
  176. package/lib/ktr/registry.js +82 -0
  177. package/lib/ktr/template/_preview/components/PreviewInfoCard.js +10 -0
  178. package/lib/ktr/template/_preview/components/PreviewLayout.js +10 -0
  179. package/lib/ktr/template/_preview/components/PreviewVideoCard.js +8 -0
  180. package/lib/ktr/template/_preview/render.js +142 -0
  181. package/lib/ktr/template/_preview/types.js +2 -0
  182. package/lib/ktr/template/_preview/utils/status.js +31 -0
  183. package/lib/ktr/template/_preview/utils/time.js +12 -0
  184. package/lib/ktr/template/bilibili/bangumi/components/bangumi.js +127 -0
  185. package/lib/ktr/template/bilibili/bangumi/components/types.js +2 -0
  186. package/lib/ktr/template/bilibili/bangumi/index.js +12 -0
  187. package/lib/ktr/template/bilibili/comment/components/Comment.js +193 -0
  188. package/lib/ktr/template/bilibili/comment/components/types.js +2 -0
  189. package/lib/ktr/template/bilibili/comment/index.js +10 -0
  190. package/lib/ktr/template/bilibili/components/Icons.js +66 -0
  191. package/lib/ktr/template/bilibili/components/shared.js +93 -0
  192. package/lib/ktr/template/bilibili/components/types.js +2 -0
  193. package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_ARTICLE/components/DYNAMIC_TYPE_ARTICLE.js +66 -0
  194. package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_ARTICLE/components/types.js +2 -0
  195. package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_ARTICLE/index.js +10 -0
  196. package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_AV/components/DYNAMIC_TYPE_AV.js +87 -0
  197. package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_AV/components/types.js +2 -0
  198. package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_AV/index.js +10 -0
  199. package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_DRAW/components/DYNAMIC_TYPE_DRAW.js +93 -0
  200. package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_DRAW/components/types.js +2 -0
  201. package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_DRAW/index.js +10 -0
  202. package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_FORWARD/components/DYNAMIC_TYPE_FORWARD.js +132 -0
  203. package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_FORWARD/components/types.js +2 -0
  204. package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_FORWARD/index.js +10 -0
  205. package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_LIVE_RCMD/components/DYNAMIC_TYPE_LIVE_RCMD.js +84 -0
  206. package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_LIVE_RCMD/components/types.js +2 -0
  207. package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_LIVE_RCMD/index.js +10 -0
  208. package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_WORD/components/DYNAMIC_TYPE_WORD.js +38 -0
  209. package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_WORD/components/types.js +2 -0
  210. package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_WORD/index.js +10 -0
  211. package/lib/ktr/template/bilibili/dynamic/components/AdditionalCard.js +59 -0
  212. package/lib/ktr/template/bilibili/dynamic/components/CommonComponents.js +30 -0
  213. package/lib/ktr/template/bilibili/dynamic/types.js +2 -0
  214. package/lib/ktr/template/bilibili/qrcodeImg/components/qrcodeImg.js +48 -0
  215. package/lib/ktr/template/bilibili/qrcodeImg/components/types.js +3 -0
  216. package/lib/ktr/template/bilibili/qrcodeImg/index.js +10 -0
  217. package/lib/ktr/template/bilibili/userlist/components/UserList.js +53 -0
  218. package/lib/ktr/template/bilibili/userlist/components/types.js +3 -0
  219. package/lib/ktr/template/bilibili/userlist/index.js +13 -0
  220. package/lib/ktr/template/bilibili/videoInfo/components/types.js +2 -0
  221. package/lib/ktr/template/bilibili/videoInfo/components/videoInfo.js +62 -0
  222. package/lib/ktr/template/bilibili/videoInfo/index.js +10 -0
  223. package/lib/ktr/template/components/AmbientCover.js +36 -0
  224. package/lib/ktr/template/components/DefaultLayout.js +33 -0
  225. package/lib/ktr/template/components/GlowImage.js +276 -0
  226. package/lib/ktr/template/components/QRCodeWithAvatar.js +34 -0
  227. package/lib/ktr/template/components/RolldownLogo.js +6 -0
  228. package/lib/ktr/template/components/ViteLogo.js +6 -0
  229. package/lib/ktr/template/components/iconRegistry.js +173 -0
  230. package/lib/ktr/template/douyin/article-work/components/ArticleWork.js +99 -0
  231. package/lib/ktr/template/douyin/article-work/components/types.js +3 -0
  232. package/lib/ktr/template/douyin/article-work/index.js +10 -0
  233. package/lib/ktr/template/douyin/comment/components/Comment.js +189 -0
  234. package/lib/ktr/template/douyin/comment/components/types.js +2 -0
  235. package/lib/ktr/template/douyin/comment/index.js +10 -0
  236. package/lib/ktr/template/douyin/components/Icons.js +29 -0
  237. package/lib/ktr/template/douyin/components/types.js +3 -0
  238. package/lib/ktr/template/douyin/dynamic/components/Dynamic.js +90 -0
  239. package/lib/ktr/template/douyin/dynamic/components/types.js +3 -0
  240. package/lib/ktr/template/douyin/dynamic/index.js +10 -0
  241. package/lib/ktr/template/douyin/favorite-list/components/FavoriteList.js +30 -0
  242. package/lib/ktr/template/douyin/favorite-list/components/types.js +3 -0
  243. package/lib/ktr/template/douyin/favorite-list/index.js +10 -0
  244. package/lib/ktr/template/douyin/image-work/components/ImageWork.js +136 -0
  245. package/lib/ktr/template/douyin/image-work/components/types.js +2 -0
  246. package/lib/ktr/template/douyin/image-work/index.js +10 -0
  247. package/lib/ktr/template/douyin/live/components/Live.js +51 -0
  248. package/lib/ktr/template/douyin/live/components/types.js +3 -0
  249. package/lib/ktr/template/douyin/live/index.js +10 -0
  250. package/lib/ktr/template/douyin/musicinfo/components/MusicInfo.js +60 -0
  251. package/lib/ktr/template/douyin/musicinfo/components/types.js +3 -0
  252. package/lib/ktr/template/douyin/musicinfo/index.js +10 -0
  253. package/lib/ktr/template/douyin/qrcodeImg/components/qrcodeImg.js +39 -0
  254. package/lib/ktr/template/douyin/qrcodeImg/components/types.js +3 -0
  255. package/lib/ktr/template/douyin/qrcodeImg/index.js +9 -0
  256. package/lib/ktr/template/douyin/recommend-list/components/RecommendList.js +30 -0
  257. package/lib/ktr/template/douyin/recommend-list/components/types.js +3 -0
  258. package/lib/ktr/template/douyin/recommend-list/index.js +10 -0
  259. package/lib/ktr/template/douyin/user_profile/components/UserVideoList.js +54 -0
  260. package/lib/ktr/template/douyin/user_profile/components/types.js +3 -0
  261. package/lib/ktr/template/douyin/user_profile/index.js +9 -0
  262. package/lib/ktr/template/douyin/userlist/components/UserList.js +50 -0
  263. package/lib/ktr/template/douyin/userlist/components/types.js +3 -0
  264. package/lib/ktr/template/douyin/userlist/index.js +13 -0
  265. package/lib/ktr/template/douyin/video-work/components/VideoWork.js +127 -0
  266. package/lib/ktr/template/douyin/video-work/components/types.js +2 -0
  267. package/lib/ktr/template/douyin/video-work/index.js +10 -0
  268. package/lib/ktr/template/kuaishou/comment/components/Comment.js +88 -0
  269. package/lib/ktr/template/kuaishou/comment/components/types.js +2 -0
  270. package/lib/ktr/template/kuaishou/comment/index.js +10 -0
  271. package/lib/ktr/template/other/changelog/components/changelog.js +117 -0
  272. package/lib/ktr/template/other/changelog/components/types.js +3 -0
  273. package/lib/ktr/template/other/changelog/index.js +9 -0
  274. package/lib/ktr/template/other/handlerError/components/errorTitles.js +227 -0
  275. package/lib/ktr/template/other/handlerError/components/handlerError.js +392 -0
  276. package/lib/ktr/template/other/handlerError/components/stackHighlight.js +109 -0
  277. package/lib/ktr/template/other/handlerError/components/types.js +2 -0
  278. package/lib/ktr/template/other/handlerError/index.js +9 -0
  279. package/lib/ktr/template/other/help/components/Help.js +79 -0
  280. package/lib/ktr/template/other/help/components/types.js +3 -0
  281. package/lib/ktr/template/other/help/index.js +12 -0
  282. package/lib/ktr/template/other/live-photo-tip/components/LivePhotoTip.js +80 -0
  283. package/lib/ktr/template/other/live-photo-tip/components/types.js +3 -0
  284. package/lib/ktr/template/other/live-photo-tip/index.js +9 -0
  285. package/lib/ktr/template/other/qrlogin/components/qrlogin.js +58 -0
  286. package/lib/ktr/template/other/qrlogin/components/types.js +3 -0
  287. package/lib/ktr/template/other/qrlogin/index.js +9 -0
  288. package/lib/ktr/template/other/runtime/components/runtime.js +101 -0
  289. package/lib/ktr/template/other/runtime/components/types.js +3 -0
  290. package/lib/ktr/template/other/runtime/index.js +9 -0
  291. package/lib/ktr/template/other/version_warning/components/VersionWarning.js +38 -0
  292. package/lib/ktr/template/other/version_warning/components/types.js +3 -0
  293. package/lib/ktr/template/other/version_warning/index.js +9 -0
  294. package/lib/ktr/template/statistics/components/BoxplotGuide.js +17 -0
  295. package/lib/ktr/template/statistics/components/ChartCard.js +15 -0
  296. package/lib/ktr/template/statistics/components/KpiCard.js +14 -0
  297. package/lib/ktr/template/statistics/components/PlatformTable.js +20 -0
  298. package/lib/ktr/template/statistics/components/RankList.js +61 -0
  299. package/lib/ktr/template/statistics/components/SSRChart.js +22 -0
  300. package/lib/ktr/template/statistics/components/chartPresets.js +630 -0
  301. package/lib/ktr/template/statistics/components/chartTheme.js +226 -0
  302. package/lib/ktr/template/statistics/components/format.js +38 -0
  303. package/lib/ktr/template/statistics/components/types.js +9 -0
  304. package/lib/ktr/template/statistics/global/components/GlobalStatistics.js +246 -0
  305. package/lib/ktr/template/statistics/global/components/types.js +3 -0
  306. package/lib/ktr/template/statistics/global/index.js +9 -0
  307. package/lib/ktr/template/statistics/group/components/GroupStatistics.js +181 -0
  308. package/lib/ktr/template/statistics/group/components/types.js +3 -0
  309. package/lib/ktr/template/statistics/group/index.js +9 -0
  310. package/lib/ktr/template/types/ctx.js +2 -0
  311. package/lib/ktr/template/xiaohongshu/comment/components/Comment.js +99 -0
  312. package/lib/ktr/template/xiaohongshu/comment/components/types.js +3 -0
  313. package/lib/ktr/template/xiaohongshu/comment/index.js +9 -0
  314. package/lib/ktr/template/xiaohongshu/noteInfo/components/noteInfo.js +93 -0
  315. package/lib/ktr/template/xiaohongshu/noteInfo/components/types.js +2 -0
  316. package/lib/ktr/template/xiaohongshu/noteInfo/index.js +9 -0
  317. package/lib/ktr/utils/QRCodeAvatar.js +99 -0
  318. package/lib/ktr/utils/QRcode.js +56 -0
  319. package/lib/ktr/utils/avatarProxy.js +45 -0
  320. package/lib/ktr/utils/cn.js +11 -0
  321. package/lib/ktr/utils/theme.js +12 -0
  322. package/lib/qqFields.json +75 -0
  323. package/lib/qqOptions.js +44 -0
  324. package/lib/richtext/index.js +25 -0
  325. package/lib/richtext/parse/index.js +232 -0
  326. package/lib/richtext/react/cn.js +11 -0
  327. package/lib/richtext/react/index.js +221 -0
  328. package/lib/richtext/types.js +2 -0
  329. package/lib/schema.js +352 -0
  330. package/lib/webui.js +341 -0
  331. package/package.json +88 -0
  332. package/resources/image/bilibili/RICH_TEXT_NODE_TYPE/RICH_TEXT_NODE_TYPE_BV.svg +1 -0
  333. package/resources/image/bilibili/RICH_TEXT_NODE_TYPE/RICH_TEXT_NODE_TYPE_GOODS.svg +1 -0
  334. package/resources/image/bilibili/RICH_TEXT_NODE_TYPE/RICH_TEXT_NODE_TYPE_LOTTERY.svg +1 -0
  335. package/resources/image/bilibili/RICH_TEXT_NODE_TYPE/RICH_TEXT_NODE_TYPE_VIEW_PICTURE.svg +1 -0
  336. package/resources/image/bilibili/RICH_TEXT_NODE_TYPE/RICH_TEXT_NODE_TYPE_VOTE.svg +1 -0
  337. package/resources/image/bilibili/RICH_TEXT_NODE_TYPE/RICH_TEXT_NODE_TYPE_WEB.svg +1 -0
  338. package/resources/image/bilibili/bilibili-dark.png +0 -0
  339. package/resources/image/bilibili/bilibili-light.png +0 -0
  340. package/resources/image/bilibili/bilibili.png +0 -0
  341. package/resources/image/bilibili/id-dark.svg +1 -0
  342. package/resources/image/bilibili/id-light.svg +1 -0
  343. package/resources/image/bilibili/level/lv0.svg +1 -0
  344. package/resources/image/bilibili/level/lv1.svg +1 -0
  345. package/resources/image/bilibili/level/lv2.svg +1 -0
  346. package/resources/image/bilibili/level/lv3.svg +1 -0
  347. package/resources/image/bilibili/level/lv4.svg +1 -0
  348. package/resources/image/bilibili/level/lv5.svg +1 -0
  349. package/resources/image/bilibili/level/lv6.svg +1 -0
  350. package/resources/image/bilibili/level/lv7.svg +1 -0
  351. package/resources/image/bilibili/like-dark.svg +6 -0
  352. package/resources/image/bilibili/like-light.svg +6 -0
  353. package/resources/image/bilibili/play.svg +28 -0
  354. package/resources/image/bilibili/res-local1.png +0 -0
  355. package/resources/image/bilibili/up_pb.svg +1 -0
  356. package/resources/image/bilibili//347/233/264/346/222/255/344/270/255.png +0 -0
  357. package/resources/image/douyin/douyin.png +0 -0
  358. package/resources/image/douyin/dylogo-dark.svg +23 -0
  359. package/resources/image/douyin/dylogo-light.svg +38 -0
  360. package/resources/image/douyin/search-dark.svg +1 -0
  361. package/resources/image/douyin/search-light.svg +3 -0
  362. package/resources/image/douyin//346/212/226/351/237/263-/347/233/264/346/222/255/344/270/255.png +0 -0
  363. package/resources/image/frame-logo.png +0 -0
  364. package/resources/image/kuaishou/logo.png +0 -0
  365. package/resources/image/other/handlerError/Milky.png +0 -0
  366. package/resources/image/other/handlerError/chronocat.svg +43 -0
  367. package/resources/image/other/handlerError/conwechat.webp +0 -0
  368. package/resources/image/other/handlerError/gocq-http.webp +0 -0
  369. package/resources/image/other/handlerError/lagrange.webp +0 -0
  370. package/resources/image/other/handlerError/llonebot.webp +0 -0
  371. package/resources/image/other/handlerError/napcat.webp +0 -0
  372. package/resources/image/other/handlerError/onebot.png +0 -0
  373. package/resources/image/other/handlerError/satori.png +0 -0
  374. package/resources/image/xiaohongshu/logo.png +0 -0
  375. package/resources/template/style.css +23708 -0
  376. package/resources/vite.svg +130 -0
  377. package/scripts/build.mjs +129 -0
  378. package/scripts/check-schema.cjs +55 -0
  379. package/scripts/deploy.mjs +78 -0
  380. package/scripts/make-demo-placeholders.mjs +112 -0
  381. package/scripts/patch-deps.mjs +46 -0
  382. package/scripts/patch-webui.mjs +112 -0
  383. package/scripts/smoke-commands.cjs +39 -0
  384. package/scripts/smoke-config.cjs +122 -0
  385. package/scripts/smoke-douyin.cjs +170 -0
  386. package/scripts/smoke-koishi-commands.cjs +210 -0
  387. package/scripts/smoke-login.cjs +110 -0
  388. package/scripts/smoke-parse.cjs +54 -0
  389. package/scripts/smoke-push-mock.cjs +114 -0
  390. package/scripts/smoke-push.cjs +104 -0
  391. package/scripts/smoke-qq.cjs +147 -0
  392. package/scripts/smoke-qqcard.cjs +108 -0
  393. package/scripts/smoke-qqpanel.cjs +205 -0
  394. package/scripts/smoke-render.cjs +106 -0
  395. package/scripts/smoke-server.cjs +94 -0
  396. package/src/compat/axios.ts +5 -0
  397. package/src/compat/cron.ts +86 -0
  398. package/src/compat/esm.ts +13 -0
  399. package/src/compat/express.ts +5 -0
  400. package/src/compat/heroui.tsx +53 -0
  401. package/src/compat/lodash.ts +32 -0
  402. package/src/compat/logger.ts +121 -0
  403. package/src/compat/node-karin.ts +1064 -0
  404. package/src/compat/phosphor-icons.tsx +25 -0
  405. package/src/compat/qqcard.ts +251 -0
  406. package/src/compat/root.ts +44 -0
  407. package/src/compat/runtime.ts +120 -0
  408. package/src/compat/segment.ts +161 -0
  409. package/src/compat/sqlite3.ts +123 -0
  410. package/src/compat/start.ts +3 -0
  411. package/src/compat/syncConfig.ts +64 -0
  412. package/src/compat/template-react.ts +54 -0
  413. package/src/compat/text.ts +58 -0
  414. package/src/compat/yaml.ts +6 -0
  415. package/src/configBridge.ts +94 -0
  416. package/src/index.ts +769 -0
  417. package/src/karin/app.ts +1 -0
  418. package/src/karin/apps/__ready.ts +14 -0
  419. package/src/karin/apps/admin.ts +127 -0
  420. package/src/karin/apps/help.ts +228 -0
  421. package/src/karin/apps/push.ts +327 -0
  422. package/src/karin/apps/qrlogin.ts +160 -0
  423. package/src/karin/apps/statistics.ts +203 -0
  424. package/src/karin/apps/testPush.ts +226 -0
  425. package/src/karin/apps/tools.ts +510 -0
  426. package/src/karin/apps/update.ts +239 -0
  427. package/src/karin/index.ts +9 -0
  428. package/src/karin/module/db/bilibili.ts +1089 -0
  429. package/src/karin/module/db/douyin.ts +1218 -0
  430. package/src/karin/module/db/index.ts +159 -0
  431. package/src/karin/module/db/migration.ts +249 -0
  432. package/src/karin/module/db/statistics.ts +817 -0
  433. package/src/karin/module/index.ts +37 -0
  434. package/src/karin/module/server/constants/routes.ts +53 -0
  435. package/src/karin/module/server/controllers/bots.ts +289 -0
  436. package/src/karin/module/server/controllers/config.ts +85 -0
  437. package/src/karin/module/server/controllers/video.ts +212 -0
  438. package/src/karin/module/server/index.ts +11 -0
  439. package/src/karin/module/server/middlewares/auth.ts +147 -0
  440. package/src/karin/module/server/routes/amagi.ts +57 -0
  441. package/src/karin/module/server/routes/api.ts +42 -0
  442. package/src/karin/module/server/routes/index.ts +68 -0
  443. package/src/karin/module/server/routes/ssr.ts +14 -0
  444. package/src/karin/module/server/routes/static.ts +43 -0
  445. package/src/karin/module/utils/Base.ts +497 -0
  446. package/src/karin/module/utils/CardParser.ts +503 -0
  447. package/src/karin/module/utils/Common.ts +448 -0
  448. package/src/karin/module/utils/Config.ts +443 -0
  449. package/src/karin/module/utils/EmojiReaction.ts +268 -0
  450. package/src/karin/module/utils/ErrorHandler/handler.ts +124 -0
  451. package/src/karin/module/utils/ErrorHandler/index.ts +48 -0
  452. package/src/karin/module/utils/ErrorHandler/render.ts +180 -0
  453. package/src/karin/module/utils/ErrorHandler/sender.ts +192 -0
  454. package/src/karin/module/utils/ErrorHandler/strategy.ts +41 -0
  455. package/src/karin/module/utils/ErrorHandler/types.ts +122 -0
  456. package/src/karin/module/utils/ErrorHandler/utils.ts +108 -0
  457. package/src/karin/module/utils/FFmpeg.ts +357 -0
  458. package/src/karin/module/utils/ImageHelper.ts +90 -0
  459. package/src/karin/module/utils/ImageSlice.ts +383 -0
  460. package/src/karin/module/utils/MotionPhoto.ts +297 -0
  461. package/src/karin/module/utils/Network/Downloader.ts +481 -0
  462. package/src/karin/module/utils/Network/ImageDownloader.ts +291 -0
  463. package/src/karin/module/utils/Network/Network.ts +344 -0
  464. package/src/karin/module/utils/Network/ThrottleStream.ts +76 -0
  465. package/src/karin/module/utils/Network/constants.ts +135 -0
  466. package/src/karin/module/utils/Network/helpers.ts +183 -0
  467. package/src/karin/module/utils/Network/index.ts +28 -0
  468. package/src/karin/module/utils/Network/types.ts +46 -0
  469. package/src/karin/module/utils/Networks.ts +20 -0
  470. package/src/karin/module/utils/ParseLock.ts +33 -0
  471. package/src/karin/module/utils/ParseOverride.ts +128 -0
  472. package/src/karin/module/utils/QqCardResolve.ts +116 -0
  473. package/src/karin/module/utils/QqPanel.ts +880 -0
  474. package/src/karin/module/utils/Render/coverTheme.ts +294 -0
  475. package/src/karin/module/utils/Render/index.ts +574 -0
  476. package/src/karin/module/utils/amagiClient.ts +368 -0
  477. package/src/karin/module/utils/avatar.ts +220 -0
  478. package/src/karin/module/utils/bot.ts +115 -0
  479. package/src/karin/module/utils/build-metadata.ts +60 -0
  480. package/src/karin/module/utils/changelog.ts +175 -0
  481. package/src/karin/module/utils/index.ts +10 -0
  482. package/src/karin/module/utils/loginSession.ts +291 -0
  483. package/src/karin/module/utils/parseTip.ts +59 -0
  484. package/src/karin/module/utils/runtime-report.ts +142 -0
  485. package/src/karin/module/utils/semver.ts +60 -0
  486. package/src/karin/module/utils/statisticsAggregate.ts +507 -0
  487. package/src/karin/platform/bilibili/bilibili.ts +2004 -0
  488. package/src/karin/platform/bilibili/comments.ts +397 -0
  489. package/src/karin/platform/bilibili/danmaku.ts +653 -0
  490. package/src/karin/platform/bilibili/dynamic-text.ts +926 -0
  491. package/src/karin/platform/bilibili/genParams.ts +30 -0
  492. package/src/karin/platform/bilibili/getID.ts +163 -0
  493. package/src/karin/platform/bilibili/index.ts +8 -0
  494. package/src/karin/platform/bilibili/live-status.ts +36 -0
  495. package/src/karin/platform/bilibili/login.ts +130 -0
  496. package/src/karin/platform/bilibili/push.ts +1615 -0
  497. package/src/karin/platform/bilibili/riskControl.ts +114 -0
  498. package/src/karin/platform/bilibili/search.ts +305 -0
  499. package/src/karin/platform/common/danmaku-types.ts +18 -0
  500. package/src/karin/platform/douyin/comments.ts +404 -0
  501. package/src/karin/platform/douyin/danmaku.ts +1187 -0
  502. package/src/karin/platform/douyin/douyin.ts +1244 -0
  503. package/src/karin/platform/douyin/getID.ts +101 -0
  504. package/src/karin/platform/douyin/index.ts +8 -0
  505. package/src/karin/platform/douyin/login.ts +251 -0
  506. package/src/karin/platform/douyin/push/favorite.ts +97 -0
  507. package/src/karin/platform/douyin/push/index.ts +5 -0
  508. package/src/karin/platform/douyin/push/live.ts +86 -0
  509. package/src/karin/platform/douyin/push/post.ts +75 -0
  510. package/src/karin/platform/douyin/push/recommend.ts +96 -0
  511. package/src/karin/platform/douyin/push/render.ts +768 -0
  512. package/src/karin/platform/douyin/push/types.ts +41 -0
  513. package/src/karin/platform/douyin/push.ts +1241 -0
  514. package/src/karin/platform/douyin/types.ts +151 -0
  515. package/src/karin/platform/douyin/videoQuality.ts +234 -0
  516. package/src/karin/platform/douyin/workType.ts +238 -0
  517. package/src/karin/platform/index.ts +4 -0
  518. package/src/karin/platform/kuaishou/comments.ts +114 -0
  519. package/src/karin/platform/kuaishou/getID.ts +48 -0
  520. package/src/karin/platform/kuaishou/getdata.ts +78 -0
  521. package/src/karin/platform/kuaishou/index.ts +4 -0
  522. package/src/karin/platform/kuaishou/kuaishou.ts +130 -0
  523. package/src/karin/platform/xiaohongshu/comments.ts +227 -0
  524. package/src/karin/platform/xiaohongshu/getID.ts +127 -0
  525. package/src/karin/platform/xiaohongshu/index.ts +2 -0
  526. package/src/karin/platform/xiaohongshu/xiaohongshu.ts +733 -0
  527. package/src/karin/root.ts +78 -0
  528. package/src/karin/setup.ts +77 -0
  529. package/src/karin/types/config/amagi.ts +46 -0
  530. package/src/karin/types/config/app.ts +129 -0
  531. package/src/karin/types/config/bilibili.ts +121 -0
  532. package/src/karin/types/config/cookies.ts +11 -0
  533. package/src/karin/types/config/douyin.ts +93 -0
  534. package/src/karin/types/config/index.ts +41 -0
  535. package/src/karin/types/config/kuaishou.ts +10 -0
  536. package/src/karin/types/config/pushlist.ts +55 -0
  537. package/src/karin/types/config/request.ts +27 -0
  538. package/src/karin/types/config/upload.ts +49 -0
  539. package/src/karin/types/config/xiaohongshu.ts +24 -0
  540. package/src/karin/types/datatypes.ts +42 -0
  541. package/src/karin/types/index.ts +4 -0
  542. package/src/karin/types/netrorks/NetworksConfigType.ts +61 -0
  543. package/src/karin/types/netrorks/index.ts +1 -0
  544. package/src/karin/web.config.ts +48 -0
  545. package/src/ktr/registry.ts +55 -0
  546. package/src/ktr/template/_preview/components/PreviewInfoCard.tsx +33 -0
  547. package/src/ktr/template/_preview/components/PreviewLayout.tsx +65 -0
  548. package/src/ktr/template/_preview/components/PreviewVideoCard.tsx +22 -0
  549. package/src/ktr/template/_preview/render.ts +158 -0
  550. package/src/ktr/template/_preview/types.ts +15 -0
  551. package/src/ktr/template/_preview/utils/status.ts +29 -0
  552. package/src/ktr/template/_preview/utils/time.ts +8 -0
  553. package/src/ktr/template/bilibili/bangumi/components/bangumi.tsx +462 -0
  554. package/src/ktr/template/bilibili/bangumi/components/types.ts +36 -0
  555. package/src/ktr/template/bilibili/bangumi/index.tsx +9 -0
  556. package/src/ktr/template/bilibili/comment/components/Comment.tsx +657 -0
  557. package/src/ktr/template/bilibili/comment/components/types.ts +26 -0
  558. package/src/ktr/template/bilibili/comment/index.tsx +11 -0
  559. package/src/ktr/template/bilibili/components/Icons.tsx +209 -0
  560. package/src/ktr/template/bilibili/components/shared.tsx +162 -0
  561. package/src/ktr/template/bilibili/components/types.ts +388 -0
  562. package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_ARTICLE/components/DYNAMIC_TYPE_ARTICLE.tsx +251 -0
  563. package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_ARTICLE/components/types.ts +67 -0
  564. package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_ARTICLE/index.tsx +12 -0
  565. package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_AV/components/DYNAMIC_TYPE_AV.tsx +238 -0
  566. package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_AV/components/types.ts +39 -0
  567. package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_AV/index.tsx +12 -0
  568. package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_DRAW/components/DYNAMIC_TYPE_DRAW.tsx +205 -0
  569. package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_DRAW/components/types.ts +20 -0
  570. package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_DRAW/index.tsx +11 -0
  571. package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_FORWARD/components/DYNAMIC_TYPE_FORWARD.tsx +348 -0
  572. package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_FORWARD/components/types.ts +16 -0
  573. package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_FORWARD/index.tsx +12 -0
  574. package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_LIVE_RCMD/components/DYNAMIC_TYPE_LIVE_RCMD.tsx +264 -0
  575. package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_LIVE_RCMD/components/types.ts +32 -0
  576. package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_LIVE_RCMD/index.tsx +12 -0
  577. package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_WORD/components/DYNAMIC_TYPE_WORD.tsx +68 -0
  578. package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_WORD/components/types.ts +14 -0
  579. package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_WORD/index.tsx +12 -0
  580. package/src/ktr/template/bilibili/dynamic/components/AdditionalCard.tsx +165 -0
  581. package/src/ktr/template/bilibili/dynamic/components/CommonComponents.tsx +142 -0
  582. package/src/ktr/template/bilibili/dynamic/types.ts +382 -0
  583. package/src/ktr/template/bilibili/qrcodeImg/components/qrcodeImg.tsx +179 -0
  584. package/src/ktr/template/bilibili/qrcodeImg/components/types.ts +9 -0
  585. package/src/ktr/template/bilibili/qrcodeImg/index.tsx +12 -0
  586. package/src/ktr/template/bilibili/userlist/components/UserList.tsx +246 -0
  587. package/src/ktr/template/bilibili/userlist/components/types.ts +35 -0
  588. package/src/ktr/template/bilibili/userlist/index.tsx +11 -0
  589. package/src/ktr/template/bilibili/videoInfo/components/types.ts +28 -0
  590. package/src/ktr/template/bilibili/videoInfo/components/videoInfo.tsx +217 -0
  591. package/src/ktr/template/bilibili/videoInfo/index.tsx +12 -0
  592. package/src/ktr/template/components/AmbientCover.tsx +50 -0
  593. package/src/ktr/template/components/DefaultLayout.tsx +166 -0
  594. package/src/ktr/template/components/GlowImage.tsx +572 -0
  595. package/src/ktr/template/components/QRCodeWithAvatar.tsx +52 -0
  596. package/src/ktr/template/components/RolldownLogo.tsx +110 -0
  597. package/src/ktr/template/components/ViteLogo.tsx +134 -0
  598. package/src/ktr/template/components/iconRegistry.ts +294 -0
  599. package/src/ktr/template/douyin/article-work/components/ArticleWork.tsx +301 -0
  600. package/src/ktr/template/douyin/article-work/components/types.ts +53 -0
  601. package/src/ktr/template/douyin/article-work/index.tsx +12 -0
  602. package/src/ktr/template/douyin/comment/components/Comment.tsx +612 -0
  603. package/src/ktr/template/douyin/comment/components/types.ts +85 -0
  604. package/src/ktr/template/douyin/comment/index.tsx +11 -0
  605. package/src/ktr/template/douyin/components/Icons.tsx +75 -0
  606. package/src/ktr/template/douyin/components/types.ts +83 -0
  607. package/src/ktr/template/douyin/dynamic/components/Dynamic.tsx +283 -0
  608. package/src/ktr/template/douyin/dynamic/components/types.ts +46 -0
  609. package/src/ktr/template/douyin/dynamic/index.tsx +11 -0
  610. package/src/ktr/template/douyin/favorite-list/components/FavoriteList.tsx +201 -0
  611. package/src/ktr/template/douyin/favorite-list/components/types.ts +38 -0
  612. package/src/ktr/template/douyin/favorite-list/index.tsx +12 -0
  613. package/src/ktr/template/douyin/image-work/components/ImageWork.tsx +437 -0
  614. package/src/ktr/template/douyin/image-work/components/types.ts +78 -0
  615. package/src/ktr/template/douyin/image-work/index.tsx +11 -0
  616. package/src/ktr/template/douyin/live/components/Live.tsx +229 -0
  617. package/src/ktr/template/douyin/live/components/types.ts +47 -0
  618. package/src/ktr/template/douyin/live/index.tsx +11 -0
  619. package/src/ktr/template/douyin/musicinfo/components/MusicInfo.tsx +187 -0
  620. package/src/ktr/template/douyin/musicinfo/components/types.ts +31 -0
  621. package/src/ktr/template/douyin/musicinfo/index.tsx +11 -0
  622. package/src/ktr/template/douyin/qrcodeImg/components/qrcodeImg.tsx +170 -0
  623. package/src/ktr/template/douyin/qrcodeImg/components/types.ts +9 -0
  624. package/src/ktr/template/douyin/qrcodeImg/index.tsx +9 -0
  625. package/src/ktr/template/douyin/recommend-list/components/RecommendList.tsx +201 -0
  626. package/src/ktr/template/douyin/recommend-list/components/types.ts +37 -0
  627. package/src/ktr/template/douyin/recommend-list/index.tsx +12 -0
  628. package/src/ktr/template/douyin/user_profile/components/UserVideoList.tsx +225 -0
  629. package/src/ktr/template/douyin/user_profile/components/types.ts +71 -0
  630. package/src/ktr/template/douyin/user_profile/index.tsx +9 -0
  631. package/src/ktr/template/douyin/userlist/components/UserList.tsx +229 -0
  632. package/src/ktr/template/douyin/userlist/components/types.ts +35 -0
  633. package/src/ktr/template/douyin/userlist/index.tsx +11 -0
  634. package/src/ktr/template/douyin/video-work/components/VideoWork.tsx +398 -0
  635. package/src/ktr/template/douyin/video-work/components/types.ts +80 -0
  636. package/src/ktr/template/douyin/video-work/index.tsx +11 -0
  637. package/src/ktr/template/font.css +6071 -0
  638. package/src/ktr/template/global.d.ts +69 -0
  639. package/src/ktr/template/kuaishou/comment/components/Comment.tsx +207 -0
  640. package/src/ktr/template/kuaishou/comment/components/types.ts +47 -0
  641. package/src/ktr/template/kuaishou/comment/index.tsx +11 -0
  642. package/src/ktr/template/other/changelog/components/changelog.tsx +411 -0
  643. package/src/ktr/template/other/changelog/components/types.ts +21 -0
  644. package/src/ktr/template/other/changelog/index.tsx +9 -0
  645. package/src/ktr/template/other/handlerError/components/errorTitles.ts +224 -0
  646. package/src/ktr/template/other/handlerError/components/handlerError.tsx +1076 -0
  647. package/src/ktr/template/other/handlerError/components/stackHighlight.ts +127 -0
  648. package/src/ktr/template/other/handlerError/components/types.ts +124 -0
  649. package/src/ktr/template/other/handlerError/index.tsx +9 -0
  650. package/src/ktr/template/other/help/components/Help.tsx +249 -0
  651. package/src/ktr/template/other/help/components/types.ts +47 -0
  652. package/src/ktr/template/other/help/index.tsx +9 -0
  653. package/src/ktr/template/other/live-photo-tip/components/LivePhotoTip.tsx +295 -0
  654. package/src/ktr/template/other/live-photo-tip/components/types.ts +8 -0
  655. package/src/ktr/template/other/live-photo-tip/index.tsx +9 -0
  656. package/src/ktr/template/other/qrlogin/components/qrlogin.tsx +295 -0
  657. package/src/ktr/template/other/qrlogin/components/types.ts +11 -0
  658. package/src/ktr/template/other/qrlogin/index.tsx +9 -0
  659. package/src/ktr/template/other/runtime/components/runtime.tsx +347 -0
  660. package/src/ktr/template/other/runtime/components/types.ts +75 -0
  661. package/src/ktr/template/other/runtime/index.tsx +9 -0
  662. package/src/ktr/template/other/version_warning/components/VersionWarning.tsx +392 -0
  663. package/src/ktr/template/other/version_warning/components/types.ts +8 -0
  664. package/src/ktr/template/other/version_warning/index.tsx +9 -0
  665. package/src/ktr/template/statistics/components/BoxplotGuide.tsx +57 -0
  666. package/src/ktr/template/statistics/components/ChartCard.tsx +40 -0
  667. package/src/ktr/template/statistics/components/KpiCard.tsx +39 -0
  668. package/src/ktr/template/statistics/components/PlatformTable.tsx +83 -0
  669. package/src/ktr/template/statistics/components/RankList.tsx +127 -0
  670. package/src/ktr/template/statistics/components/SSRChart.tsx +41 -0
  671. package/src/ktr/template/statistics/components/chartPresets.ts +700 -0
  672. package/src/ktr/template/statistics/components/chartTheme.ts +234 -0
  673. package/src/ktr/template/statistics/components/format.ts +33 -0
  674. package/src/ktr/template/statistics/components/types.ts +92 -0
  675. package/src/ktr/template/statistics/global/components/GlobalStatistics.tsx +597 -0
  676. package/src/ktr/template/statistics/global/components/types.ts +138 -0
  677. package/src/ktr/template/statistics/global/index.tsx +9 -0
  678. package/src/ktr/template/statistics/group/components/GroupStatistics.tsx +468 -0
  679. package/src/ktr/template/statistics/group/components/types.ts +113 -0
  680. package/src/ktr/template/statistics/group/index.tsx +9 -0
  681. package/src/ktr/template/style.css +65 -0
  682. package/src/ktr/template/types/ctx.ts +42 -0
  683. package/src/ktr/template/xiaohongshu/comment/components/Comment.tsx +264 -0
  684. package/src/ktr/template/xiaohongshu/comment/components/types.ts +119 -0
  685. package/src/ktr/template/xiaohongshu/comment/index.tsx +9 -0
  686. package/src/ktr/template/xiaohongshu/noteInfo/components/noteInfo.tsx +271 -0
  687. package/src/ktr/template/xiaohongshu/noteInfo/components/types.ts +66 -0
  688. package/src/ktr/template/xiaohongshu/noteInfo/index.tsx +9 -0
  689. package/src/ktr/utils/QRCodeAvatar.ts +102 -0
  690. package/src/ktr/utils/QRcode.ts +65 -0
  691. package/src/ktr/utils/avatarProxy.ts +42 -0
  692. package/src/ktr/utils/cn.ts +6 -0
  693. package/src/ktr/utils/theme.ts +10 -0
  694. package/src/qqFields.json +75 -0
  695. package/src/qqOptions.ts +64 -0
  696. package/src/richtext/index.ts +9 -0
  697. package/src/richtext/parse/index.ts +271 -0
  698. package/src/richtext/react/cn.ts +6 -0
  699. package/src/richtext/react/index.tsx +582 -0
  700. package/src/richtext/types.ts +320 -0
  701. package/src/schema.ts +372 -0
  702. package/src/webui.ts +352 -0
@@ -0,0 +1,1128 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.DouYinpush = void 0;
40
+ const node_fs_1 = __importDefault(require("node:fs"));
41
+ const date_fns_1 = require("date-fns");
42
+ const node_karin_1 = __importStar(require("../../../compat/node-karin.js"));
43
+ const module_1 = require("../../module");
44
+ const Config_1 = require("../../module/utils/Config");
45
+ const douyin_1 = require("../../platform/douyin");
46
+ const workType_1 = require("../../platform/douyin/workType");
47
+ const favorite_1 = require("./push/favorite");
48
+ const live_1 = require("./push/live");
49
+ const post_1 = require("./push/post");
50
+ const recommend_1 = require("./push/recommend");
51
+ const render_1 = require("./push/render");
52
+ const douyinBaseHeaders = {
53
+ ...module_1.baseHeaders,
54
+ Referer: 'https://www.douyin.com',
55
+ Cookie: Config_1.Config.amagi.cookies.douyin
56
+ };
57
+ class DouYinpush extends module_1.Base {
58
+ force = false;
59
+ /**
60
+ *
61
+ * @param e 事件Message
62
+ * @param force 是否强制推送
63
+ * @default false
64
+ * @returns
65
+ */
66
+ constructor(e = {}, force = false) {
67
+ super(e);
68
+ this.headers.Referer = 'https://www.douyin.com';
69
+ this.headers.Cookie = Config_1.Config.amagi.cookies.douyin;
70
+ this.force = force;
71
+ }
72
+ injectBotToEventForRender(targets) {
73
+ const targetBotId = targets.find((item) => item.botId)?.botId;
74
+ if (!targetBotId)
75
+ return;
76
+ const bot = node_karin_1.default.getBot(targetBotId);
77
+ if (!bot)
78
+ return;
79
+ const eventWithBot = this.e;
80
+ eventWithBot.bot = bot;
81
+ eventWithBot.selfId = eventWithBot.selfId ?? targetBotId;
82
+ }
83
+ /**
84
+ * 执行主要的操作流程
85
+ */
86
+ async action() {
87
+ await this.syncConfigToDatabase();
88
+ // 清理旧的作品缓存记录
89
+ const deletedCount = await (0, module_1.cleanOldDynamicCache)('douyin');
90
+ if (deletedCount > 0) {
91
+ node_karin_1.logger.info(`已清理 ${deletedCount} 条过期的抖音作品缓存记录`);
92
+ }
93
+ // 检查备注信息
94
+ if (await this.checkremark())
95
+ return true;
96
+ // 检查并补全配置文件中缺失的字段
97
+ await this.ensureConfigFields(Config_1.Config.pushlist.douyin);
98
+ // 获取已注册的 bot 列表,过滤未注册的 bot
99
+ const registeredBotIds = node_karin_1.default.getAllBotID();
100
+ const filteredPushList = this.filterPushListByRegisteredBots(Config_1.Config.pushlist.douyin, registeredBotIds);
101
+ if (filteredPushList.length === 0) {
102
+ // 推送列表本来就是空的属正常情况,别刷 warn(用户反馈日志一直被它刷屏)
103
+ if (Config_1.Config.pushlist.douyin?.length) {
104
+ node_karin_1.logger.warn('推送列表里的机器人都不在线,本次跳过抖音推送');
105
+ }
106
+ else {
107
+ node_karin_1.logger.debug('抖音推送列表为空,跳过');
108
+ }
109
+ return true;
110
+ }
111
+ const data = await this.getDynamicList(filteredPushList);
112
+ if (Object.keys(data).length === 0)
113
+ return true;
114
+ if (this.force)
115
+ return await this.forcepush(data);
116
+ else
117
+ return await this.getdata(data);
118
+ }
119
+ /**
120
+ * 检查并补全配置文件中缺失的字段
121
+ * @param pushList 推送配置列表
122
+ */
123
+ async ensureConfigFields(pushList) {
124
+ if (!pushList || pushList.length === 0)
125
+ return;
126
+ let hasChanges = false;
127
+ for (const item of pushList) {
128
+ // 检查并补全 sec_uid 字段
129
+ if (!item.sec_uid && item.short_id) {
130
+ try {
131
+ node_karin_1.logger.info(`自动获取用户 ${item.remark || item.short_id} 的 sec_uid`);
132
+ const searchResult = await this.amagi.douyin.fetcher.searchContent({
133
+ query: item.short_id,
134
+ type: 'user'
135
+ });
136
+ // 在搜索结果中查找匹配的用户
137
+ let matchedUser = null;
138
+ for (const userItem of searchResult.data.user_list) {
139
+ const currentDouyinId = userItem.user_info.unique_id || userItem.user_info.short_id;
140
+ if (currentDouyinId === item.short_id) {
141
+ matchedUser = userItem.user_info;
142
+ break;
143
+ }
144
+ }
145
+ if (matchedUser?.sec_uid) {
146
+ item.sec_uid = matchedUser.sec_uid;
147
+ hasChanges = true;
148
+ node_karin_1.logger.info(`已为 ${item.remark || item.short_id} 补全 sec_uid: ${item.sec_uid}`);
149
+ }
150
+ else {
151
+ node_karin_1.logger.warn(`无法获取用户 ${item.short_id} 的 sec_uid`);
152
+ }
153
+ }
154
+ catch (error) {
155
+ node_karin_1.logger.error(`获取 ${item.short_id} 的 sec_uid 失败: ${error}`);
156
+ }
157
+ }
158
+ // 检查并补全 pushTypes 字段
159
+ if (!item.pushTypes || item.pushTypes.length === 0) {
160
+ item.pushTypes = ['post', 'live', 'favorite', 'recommend'];
161
+ hasChanges = true;
162
+ node_karin_1.logger.info(`为用户 ${item.remark ?? item.sec_uid} 自动补全推送类型:作品列表、直播、收藏、推荐`);
163
+ }
164
+ // 检查并补全 switch 字段
165
+ if (item.switch === undefined) {
166
+ item.switch = true;
167
+ hasChanges = true;
168
+ }
169
+ }
170
+ // 如果有修改,保存到配置文件
171
+ if (hasChanges) {
172
+ Config_1.Config.Modify('pushlist', 'douyin', pushList);
173
+ node_karin_1.logger.info('已自动补全配置文件中缺失的字段并保存');
174
+ }
175
+ }
176
+ /**
177
+ * 根据已注册的 bot 列表过滤推送配置
178
+ * @param pushList 原始推送配置列表
179
+ * @param registeredBotIds 已注册的 bot ID 列表
180
+ * @returns 过滤后的推送配置列表
181
+ */
182
+ filterPushListByRegisteredBots(pushList, registeredBotIds) {
183
+ if (!pushList || pushList.length === 0)
184
+ return [];
185
+ const registeredSet = new Set(registeredBotIds);
186
+ const filteredList = [];
187
+ for (const item of pushList) {
188
+ // 过滤 group_id 中未注册的 bot
189
+ const filteredGroupIds = item.group_id.filter((groupWithBot) => {
190
+ const botId = groupWithBot.split(':')[1];
191
+ const isRegistered = registeredSet.has(botId);
192
+ if (!isRegistered) {
193
+ node_karin_1.logger.debug(`Bot ${botId} 未注册,跳过群组 ${groupWithBot.split(':')[0]} 的推送`);
194
+ }
195
+ return isRegistered;
196
+ });
197
+ // 如果过滤后还有有效的群组,则保留该订阅项
198
+ if (filteredGroupIds.length > 0) {
199
+ filteredList.push({
200
+ ...item,
201
+ group_id: filteredGroupIds
202
+ });
203
+ }
204
+ else {
205
+ node_karin_1.logger.debug(`用户 ${item.remark ?? item.sec_uid} 的所有推送目标 bot 均未注册,跳过`);
206
+ }
207
+ }
208
+ return filteredList;
209
+ }
210
+ /**
211
+ * 同步配置文件中的订阅信息到数据库
212
+ */
213
+ async syncConfigToDatabase() {
214
+ // 如果配置文件中没有抖音推送列表,直接返回
215
+ if (!Config_1.Config.pushlist.douyin || Config_1.Config.pushlist.douyin.length === 0) {
216
+ return;
217
+ }
218
+ await module_1.douyinDB.syncConfigSubscriptions(Config_1.Config.pushlist.douyin);
219
+ }
220
+ async getdata(data) {
221
+ if (Object.keys(data).length === 0)
222
+ return true;
223
+ for (const awemeId in data) {
224
+ const pushItem = data[awemeId];
225
+ const actualAwemeId = awemeId.replace(/^(post|favorite|recommend|live)_/, ''); // 移除推送类型前缀
226
+ const shareUrl = pushItem.pushType === 'live'
227
+ ? `https://live.douyin.com/${pushItem.Detail_Data.room_data?.owner.web_rid}`
228
+ : (pushItem.Detail_Data.share_url ?? `https://www.douyin.com/video/${actualAwemeId}`);
229
+ let pushTypeLabel;
230
+ switch (pushItem.pushType) {
231
+ case 'post':
232
+ pushTypeLabel = '作品列表';
233
+ break;
234
+ case 'favorite':
235
+ pushTypeLabel = '喜欢列表';
236
+ break;
237
+ case 'recommend':
238
+ pushTypeLabel = '推荐列表';
239
+ break;
240
+ default:
241
+ pushTypeLabel = '直播';
242
+ break;
243
+ }
244
+ node_karin_1.logger.mark(`
245
+ ${node_karin_1.logger.blue('开始处理并渲染抖音动态图片')}
246
+ ${node_karin_1.logger.blue('博主')}: ${node_karin_1.logger.green(pushItem.remark)}
247
+ ${node_karin_1.logger.blue('推送类型')}: ${node_karin_1.logger.magenta(pushTypeLabel)}
248
+ ${node_karin_1.logger.cyan('作品id')}:${node_karin_1.logger.yellow(actualAwemeId)}
249
+ ${node_karin_1.logger.cyan('访问地址')}:${node_karin_1.logger.green('https://www.douyin.com/video/' + actualAwemeId)}
250
+ ${node_karin_1.logger.cyan('分享链接')}: ${node_karin_1.logger.green(shareUrl)}
251
+ `);
252
+ const Detail_Data = pushItem.Detail_Data;
253
+ const workTypeInfo = (0, workType_1.getWorkTypeInfo)(Detail_Data);
254
+ const skip = await skipDynamic(pushItem);
255
+ if (skip) {
256
+ node_karin_1.logger.warn(`作品 https://www.douyin.com/video/${actualAwemeId} 已被处理,跳过`);
257
+ }
258
+ let img = [];
259
+ let iddata = { type: 'one_work' };
260
+ /** 按画质配置选中、即将下载发送的那一路视频源 */
261
+ let selectedVideo = null;
262
+ this.injectBotToEventForRender(pushItem.targets);
263
+ if (!skip) {
264
+ iddata = await (0, douyin_1.getDouyinID)(this.e, shareUrl, false);
265
+ }
266
+ if (!skip) {
267
+ // 画质选档必须早于渲染和分享链接拼接:卡片上展示的清晰度要和后面实际下载的那一路视频源完全一致,
268
+ // 否则会出现「卡片写 4K、实际下载 720p」的错位。
269
+ if (pushItem.pushType !== 'live' && workTypeInfo.isVideo && pushItem.Detail_Data.video?.bit_rate?.length) {
270
+ selectedVideo = (0, douyin_1.douyinProcessVideos)(pushItem.Detail_Data.video.bit_rate, Config_1.Config.douyin.videoQuality)[0];
271
+ }
272
+ let workShareLink;
273
+ if (pushItem.pushType !== 'live') {
274
+ if (workTypeInfo.isArticle) {
275
+ workShareLink = `https://www.douyin.com/article/${actualAwemeId}`;
276
+ }
277
+ else if (workTypeInfo.isImage) {
278
+ // 图文和合辑使用无追踪参数的短链接,降低二维码密度并提高扫描识别率。
279
+ workShareLink = `https://www.douyin.com/note/${actualAwemeId}`;
280
+ }
281
+ else if (Config_1.Config.douyin.push.shareType === 'web') {
282
+ // 视频同样用无追踪参数的规范链接:share_url 302 之后只是多出一串追踪参数,白搭一次网络请求还会拉高二维码密度
283
+ workShareLink = `https://www.douyin.com/video/${actualAwemeId}`;
284
+ }
285
+ else {
286
+ // 直链模式:优先用选档后的视频源拼播放地址,二维码内容与卡片展示的清晰度一致
287
+ const playAddr = selectedVideo?.play_addr ?? pushItem.Detail_Data.video?.play_addr;
288
+ workShareLink = playAddr ? (0, douyin_1.buildDouyinPlayUrl)(playAddr) : `https://www.douyin.com/video/${actualAwemeId}`;
289
+ }
290
+ }
291
+ switch (pushItem.pushType) {
292
+ case 'live': {
293
+ if (!pushItem.Detail_Data.room_data || !pushItem.Detail_Data.live_data)
294
+ break;
295
+ img = await (0, render_1.renderLiveImage)({
296
+ e: this.e,
297
+ Detail_Data: pushItem.Detail_Data,
298
+ dynamicTypeLabel: '直播动态推送'
299
+ });
300
+ break;
301
+ }
302
+ case 'favorite': {
303
+ img = await (0, render_1.renderFavoriteImage)({
304
+ e: this.e,
305
+ Detail_Data: pushItem.Detail_Data,
306
+ create_time: pushItem.create_time,
307
+ shareLink: workShareLink,
308
+ remark: pushItem.remark
309
+ });
310
+ break;
311
+ }
312
+ case 'recommend': {
313
+ img = await (0, render_1.renderRecommendImage)({
314
+ e: this.e,
315
+ Detail_Data: pushItem.Detail_Data,
316
+ create_time: pushItem.create_time,
317
+ shareLink: workShareLink,
318
+ remark: pushItem.remark
319
+ });
320
+ break;
321
+ }
322
+ case 'post':
323
+ default: {
324
+ img = await (0, render_1.renderWorkImage)({
325
+ e: this.e,
326
+ Detail_Data: pushItem.Detail_Data,
327
+ create_time: pushItem.create_time,
328
+ shareLink: workShareLink,
329
+ videoSource: selectedVideo
330
+ });
331
+ break;
332
+ }
333
+ }
334
+ }
335
+ // 遍历目标群组,并发送消息
336
+ for (const target of pushItem.targets) {
337
+ let status = { message_id: '' };
338
+ const { groupId, botId } = target;
339
+ if (!skip) {
340
+ const Contact = node_karin_1.default.contactGroup(groupId);
341
+ // 为当前目标注入 bot,后续解析下载沿用该 bot 身份
342
+ const bot = node_karin_1.default.getBot(botId);
343
+ const eventWithBot = this.e;
344
+ eventWithBot.bot = bot;
345
+ eventWithBot.selfId = botId;
346
+ const pushImg = img ?? [];
347
+ // 仅 QQ 官方机器人支持按钮:非直播作品在卡片末尾追加「解析」回调按钮,点击后下发 #解析 + 分享链接
348
+ const parseButton = bot?.adapter?.name === 'QQ Official Bot' && pushItem.pushType !== 'live' && pushItem.Detail_Data.share_url
349
+ ? [
350
+ node_karin_1.segment.button([
351
+ { text: '解析', callback: true, data: `#解析${pushItem.Detail_Data.share_url}` },
352
+ { text: '帮助', callback: true, data: `#kkk帮助` }
353
+ ])
354
+ ]
355
+ : [];
356
+ // 发送消息
357
+ status = await node_karin_1.default.sendMsg(botId, Contact, [...pushImg, ...parseButton]);
358
+ // 如果是直播推送,更新直播状态
359
+ if (pushItem.pushType === 'live' && 'room_data' in pushItem.Detail_Data && status.message_id) {
360
+ await module_1.douyinDB.updateLiveStatus(pushItem.sec_uid, true);
361
+ }
362
+ // 是否一同解析该新作品?(直播推送没有可解析的作品内容)
363
+ if (pushItem.pushType !== 'live' && Config_1.Config.douyin.push.parsedynamic && status.message_id) {
364
+ // 收窄为作品类推送的作品详情
365
+ const Detail_Data = pushItem.Detail_Data;
366
+ node_karin_1.logger.debug(`开始解析作品,类型为:${(0, workType_1.getWorkTypeDisplayName)(workTypeInfo)}`);
367
+ // 如果新作品是视频
368
+ if (workTypeInfo.isVideo && Detail_Data.video) {
369
+ /** 默认视频下载地址 */
370
+ let downloadUrl = (0, douyin_1.buildDouyinPlayUrl)(Detail_Data.video.play_addr);
371
+ // 根据配置文件自动选择分辨率
372
+ node_karin_1.logger.debug(`开始排除不符合条件的视频分辨率;\n
373
+ 共拥有${node_karin_1.logger.yellow(Detail_Data.video.bit_rate.length)}个视频源\n
374
+ 视频ID:${node_karin_1.logger.green(Detail_Data.aweme_id)}\n
375
+ 分享链接:${node_karin_1.logger.green(Detail_Data.share_url)}
376
+ `);
377
+ // 复用渲染前已选好的视频源,卡片展示的清晰度与实际下载的必然一致
378
+ const videoObj = selectedVideo ?? (0, douyin_1.douyinProcessVideos)(Detail_Data.video.bit_rate, Config_1.Config.douyin.videoQuality)[0];
379
+ node_karin_1.logger.debug('获取精确下载地址');
380
+ downloadUrl = await new module_1.Networks({
381
+ url: videoObj.play_addr.url_list[0],
382
+ headers: douyinBaseHeaders
383
+ }).getLongLink();
384
+ // 下载视频
385
+ await (0, module_1.downloadVideo)(this.e, {
386
+ video_url: downloadUrl,
387
+ title: { timestampTitle: `tmp_${Date.now()}.mp4`, originTitle: `${Detail_Data.desc}.mp4` }
388
+ }, { active: true, activeOption: { uin: botId, group_id: groupId } });
389
+ }
390
+ else if (workTypeInfo.isImage && iddata.type === 'one_work') {
391
+ // 如果新作品是图集或合辑
392
+ // 判断是否为合辑(is_slides)
393
+ const isSlides = Detail_Data.is_slides === true;
394
+ if (isSlides && Detail_Data.images) {
395
+ // 合辑处理逻辑
396
+ const images = [];
397
+ const temp = [];
398
+ let hasGeneratedLivePhoto = false; // 标记是否生成了实况图
399
+ /** 下载 BGM(如果存在) */
400
+ let liveimgbgm = null;
401
+ let bgmContext = null;
402
+ const mergeMode = Config_1.Config.douyin.liveImageMergeMode ?? 'independent';
403
+ if (Detail_Data.music) {
404
+ let mp3Path = '';
405
+ // 该声音由于版权原因在当前地区不可用
406
+ if (Detail_Data.music.play_url.uri === '') {
407
+ const extraData = JSON.parse(Detail_Data.music.extra);
408
+ mp3Path = extraData.original_song_url;
409
+ }
410
+ else {
411
+ mp3Path = Detail_Data.music.play_url.uri;
412
+ }
413
+ liveimgbgm = await (0, module_1.downloadFile)(mp3Path, {
414
+ title: `Douyin_tmp_A_${Date.now()}.mp3`,
415
+ headers: douyinBaseHeaders
416
+ });
417
+ temp.push(liveimgbgm);
418
+ }
419
+ const images1 = Detail_Data.images ?? [];
420
+ if (!images1.length) {
421
+ node_karin_1.logger.debug('未获取到合辑的图片数据');
422
+ }
423
+ for (const [index, item] of images1.entries()) {
424
+ // 静态图片,clip_type为2或undefined
425
+ if (item.clip_type === 2 || item.clip_type === undefined) {
426
+ const imageUrl = await (0, module_1.processImageUrl)(item.url_list[0], Detail_Data.desc, index);
427
+ images.push(node_karin_1.segment.image(imageUrl));
428
+ continue;
429
+ }
430
+ /** 动图/短片 */
431
+ const livePlayAddr = item.video?.play_addr_h264;
432
+ if (!livePlayAddr?.uri) {
433
+ node_karin_1.logger.warn(`合辑第 ${index + 1} 个动态媒体缺少视频源,跳过`);
434
+ continue;
435
+ }
436
+ const liveimg = await (0, module_1.downloadFile)((0, douyin_1.buildDouyinPlayUrl)(livePlayAddr), {
437
+ title: `Douyin_tmp_V_${Date.now()}.mp4`,
438
+ headers: douyinBaseHeaders
439
+ });
440
+ if (liveimg.filepath) {
441
+ const outputPath = module_1.Common.tempDri.video + `Douyin_Result_${Date.now()}.mp4`;
442
+ const loopCount = item.clip_type === 4 ? 1 : 3;
443
+ let staticImgPath = '';
444
+ if (item.url_list?.[0]) {
445
+ const staticImg = await (0, module_1.downloadFile)(item.url_list[0], {
446
+ title: `Douyin_static_${Date.now()}_${index}.jpg`,
447
+ headers: douyinBaseHeaders,
448
+ filepath: module_1.Common.tempDri.images + `Douyin_static_${Date.now()}_${index}.jpg`
449
+ });
450
+ if (staticImg.filepath) {
451
+ temp.push({ filepath: staticImg.filepath, totalBytes: 0 });
452
+ }
453
+ staticImgPath = staticImg.filepath ?? '';
454
+ }
455
+ const { shouldGenerateVideo, shouldGenerateLivePhoto } = (0, workType_1.getDouyinLiveImageSendPolicy)(item.clip_type, Config_1.Config.app.livePhotoMode ?? 'video_and_livephoto');
456
+ // 生成视频
457
+ if (shouldGenerateVideo) {
458
+ const transitionEnabled = loopCount > 1 && Boolean(staticImgPath);
459
+ const safeStaticPath = staticImgPath || liveimg.filepath;
460
+ const result = await (0, module_1.loopVideoWithTransition)({
461
+ inputPath: liveimg.filepath,
462
+ outputPath,
463
+ loopCount,
464
+ staticImagePath: safeStaticPath,
465
+ transitionEnabled,
466
+ bgmPath: liveimgbgm?.filepath,
467
+ mergeMode,
468
+ context: bgmContext ?? undefined
469
+ });
470
+ const success = result.success;
471
+ if (mergeMode === 'continuous' && result.context) {
472
+ bgmContext = result.context;
473
+ }
474
+ if (success) {
475
+ const filePath = module_1.Common.tempDri.video + `tmp_${Date.now()}.mp4`;
476
+ node_fs_1.default.renameSync(outputPath, filePath);
477
+ node_karin_1.logger.mark(`视频文件重命名完成: ${outputPath.split('/').pop()} -> ${filePath.split('/').pop()}`);
478
+ temp.push({ filepath: filePath, totalBytes: 0 });
479
+ const videoPath = Config_1.Config.app.videoSendMode === 'base64'
480
+ ? `base64://${node_fs_1.default.readFileSync(filePath).toString('base64')}`
481
+ : `file://${filePath}`;
482
+ images.push(node_karin_1.segment.video(videoPath));
483
+ }
484
+ }
485
+ // 生成实况图(clip_type === 5 是 livePhoto)
486
+ if (shouldGenerateLivePhoto && item.clip_type === 5 && item.url_list?.[0]) {
487
+ let hasPushedMotionPhotoCover = false;
488
+ if (staticImgPath) {
489
+ const motionPhotoCoverPath = module_1.Common.tempDri.images + `MVIMG_${(0, date_fns_1.format)(new Date(), 'yyyyMMdd_HHmmss_SSS')}_${index}.jpg`;
490
+ const motionPhotoCreated = await (0, module_1.buildGoogleMotionPhoto)({
491
+ imagePath: staticImgPath,
492
+ videoPath: liveimg.filepath,
493
+ outputPath: motionPhotoCoverPath
494
+ });
495
+ if (motionPhotoCreated) {
496
+ temp.push({ filepath: motionPhotoCoverPath, totalBytes: 0 });
497
+ const motionPhotoCover = (0, module_1.processLocalImageFile)(motionPhotoCoverPath);
498
+ images.push(node_karin_1.segment.image(motionPhotoCover));
499
+ hasPushedMotionPhotoCover = true;
500
+ }
501
+ }
502
+ if (!hasPushedMotionPhotoCover) {
503
+ const imageUrl = await (0, module_1.processImageUrl)(item.url_list[0], Detail_Data.desc, index);
504
+ images.push(node_karin_1.segment.image(imageUrl));
505
+ }
506
+ else {
507
+ hasGeneratedLivePhoto = true; // 标记已生成实况图
508
+ }
509
+ }
510
+ node_karin_1.logger.mark('正在尝试删除缓存文件');
511
+ await module_1.Common.removeFile(liveimg.filepath, true);
512
+ }
513
+ }
514
+ // 如果生成了实况图,添加提示文字
515
+ if (hasGeneratedLivePhoto) {
516
+ const tipImg = await (0, module_1.Render)(this.e, 'other/live-photo-tip', {
517
+ title: '实况照片已生成',
518
+ description: '保存原图到相册即可识别为实况图'
519
+ });
520
+ images.push(...tipImg);
521
+ }
522
+ const bot = node_karin_1.default.getBot(botId);
523
+ try {
524
+ if (images.length === 0) {
525
+ node_karin_1.logger.warn(`抖音合辑推送解析未生成可发送内容,aweme_id=${Detail_Data.aweme_id}`);
526
+ }
527
+ else {
528
+ const Element = node_karin_1.common.makeForward(images, botId, bot.account.name);
529
+ await bot.sendForwardMsg(Contact, Element, {
530
+ source: '合辑内容',
531
+ summary: `查看${Element.length}张图片/视频消息`,
532
+ prompt: '抖音合辑解析结果',
533
+ news: [{ text: '点击查看解析结果' }]
534
+ });
535
+ }
536
+ }
537
+ catch (error) {
538
+ node_karin_1.logger.error(`发送合辑失败: ${error}`);
539
+ }
540
+ finally {
541
+ for (const item of temp) {
542
+ await module_1.Common.removeFile(item.filepath, true);
543
+ }
544
+ }
545
+ }
546
+ else if (Detail_Data.images) {
547
+ // 普通图集处理逻辑
548
+ // 检查是否包含 live 图(clip_type !== 2 且 clip_type !== undefined)
549
+ const hasLiveImage = Detail_Data.images.some((item) => item.clip_type !== 2 && item.clip_type !== undefined);
550
+ if (hasLiveImage) {
551
+ // 包含 live 图,需要特殊处理
552
+ const processedImages = [];
553
+ const temp = [];
554
+ let hasGeneratedLivePhoto = false; // 标记是否生成了实况图
555
+ /** 下载 BGM(如果存在) */
556
+ let liveimgbgm = null;
557
+ let bgmContext = null;
558
+ const mergeMode = Config_1.Config.douyin.liveImageMergeMode ?? 'independent';
559
+ if (Detail_Data.music) {
560
+ let mp3Path = '';
561
+ if (Detail_Data.music.play_url.uri === '') {
562
+ const extraData = JSON.parse(Detail_Data.music.extra);
563
+ mp3Path = extraData.original_song_url;
564
+ }
565
+ else {
566
+ mp3Path = Detail_Data.music.play_url.uri;
567
+ }
568
+ liveimgbgm = await (0, module_1.downloadFile)(mp3Path, {
569
+ title: `Douyin_tmp_A_${Date.now()}.mp3`,
570
+ headers: douyinBaseHeaders
571
+ });
572
+ temp.push(liveimgbgm);
573
+ }
574
+ for (const [index, item] of Detail_Data.images.entries()) {
575
+ // 静态图片,clip_type为2或undefined
576
+ if (item.clip_type === 2 || item.clip_type === undefined) {
577
+ const image_url = item.url_list[2] ?? item.url_list[1];
578
+ if (!image_url)
579
+ continue;
580
+ const imageUrl = await (0, module_1.processImageUrl)(image_url, Detail_Data.desc, index);
581
+ processedImages.push(node_karin_1.segment.image(imageUrl));
582
+ continue;
583
+ }
584
+ /** live 图 */
585
+ const livePlayAddr = item.video?.play_addr_h264;
586
+ if (!livePlayAddr?.uri) {
587
+ node_karin_1.logger.warn(`图集第 ${index + 1} 个动态媒体缺少视频源,跳过`);
588
+ continue;
589
+ }
590
+ const liveimg = await (0, module_1.downloadFile)((0, douyin_1.buildDouyinPlayUrl)(livePlayAddr), {
591
+ title: `Douyin_tmp_V_${Date.now()}.mp4`,
592
+ headers: douyinBaseHeaders
593
+ });
594
+ if (liveimg.filepath) {
595
+ const outputPath = module_1.Common.tempDri.video + `Douyin_Result_${Date.now()}.mp4`;
596
+ const loopCount = item.clip_type === 4 ? 1 : 3;
597
+ let staticImgPath = '';
598
+ if (item.url_list?.[0]) {
599
+ const staticImg = await (0, module_1.downloadFile)(item.url_list[0], {
600
+ title: `Douyin_static_${Date.now()}_${index}.jpg`,
601
+ headers: douyinBaseHeaders,
602
+ filepath: module_1.Common.tempDri.images + `Douyin_static_${Date.now()}_${index}.jpg`
603
+ });
604
+ if (staticImg.filepath) {
605
+ temp.push({ filepath: staticImg.filepath, totalBytes: 0 });
606
+ }
607
+ staticImgPath = staticImg.filepath ?? '';
608
+ }
609
+ const { shouldGenerateVideo, shouldGenerateLivePhoto } = (0, workType_1.getDouyinLiveImageSendPolicy)(item.clip_type, Config_1.Config.app.livePhotoMode ?? 'video_and_livephoto');
610
+ // 生成视频
611
+ if (shouldGenerateVideo) {
612
+ const transitionEnabled = loopCount > 1 && Boolean(staticImgPath);
613
+ const safeStaticPath = staticImgPath || liveimg.filepath;
614
+ const result = await (0, module_1.loopVideoWithTransition)({
615
+ inputPath: liveimg.filepath,
616
+ outputPath,
617
+ loopCount,
618
+ staticImagePath: safeStaticPath,
619
+ transitionEnabled,
620
+ bgmPath: liveimgbgm?.filepath,
621
+ mergeMode,
622
+ context: bgmContext ?? undefined
623
+ });
624
+ const success = result.success;
625
+ if (mergeMode === 'continuous' && result.context) {
626
+ bgmContext = result.context;
627
+ }
628
+ if (success) {
629
+ const filePath = module_1.Common.tempDri.video + `tmp_${Date.now()}.mp4`;
630
+ node_fs_1.default.renameSync(outputPath, filePath);
631
+ node_karin_1.logger.mark(`视频文件重命名完成: ${outputPath.split('/').pop()} -> ${filePath.split('/').pop()}`);
632
+ temp.push({ filepath: filePath, totalBytes: 0 });
633
+ const videoPath = Config_1.Config.app.videoSendMode === 'base64'
634
+ ? `base64://${node_fs_1.default.readFileSync(filePath).toString('base64')}`
635
+ : `file://${filePath}`;
636
+ processedImages.push(node_karin_1.segment.video(videoPath));
637
+ }
638
+ }
639
+ // 生成实况图(clip_type === 5 是 livePhoto)
640
+ if (shouldGenerateLivePhoto && item.clip_type === 5 && item.url_list?.[0]) {
641
+ let hasPushedMotionPhotoCover = false;
642
+ if (staticImgPath) {
643
+ const motionPhotoCoverPath = module_1.Common.tempDri.images + `MVIMG_${(0, date_fns_1.format)(new Date(), 'yyyyMMdd_HHmmss_SSS')}_${index}.jpg`;
644
+ const motionPhotoCreated = await (0, module_1.buildGoogleMotionPhoto)({
645
+ imagePath: staticImgPath,
646
+ videoPath: liveimg.filepath,
647
+ outputPath: motionPhotoCoverPath
648
+ });
649
+ if (motionPhotoCreated) {
650
+ temp.push({ filepath: motionPhotoCoverPath, totalBytes: 0 });
651
+ const motionPhotoCover = (0, module_1.processLocalImageFile)(motionPhotoCoverPath);
652
+ processedImages.push(node_karin_1.segment.image(motionPhotoCover));
653
+ hasPushedMotionPhotoCover = true;
654
+ }
655
+ }
656
+ if (!hasPushedMotionPhotoCover) {
657
+ const imageUrl = await (0, module_1.processImageUrl)(item.url_list[0], Detail_Data.desc, index);
658
+ processedImages.push(node_karin_1.segment.image(imageUrl));
659
+ }
660
+ else {
661
+ hasGeneratedLivePhoto = true; // 标记已生成实况图
662
+ }
663
+ }
664
+ node_karin_1.logger.mark('正在尝试删除缓存文件');
665
+ await module_1.Common.removeFile(liveimg.filepath, true);
666
+ }
667
+ }
668
+ // 如果生成了实况图,添加提示文字
669
+ if (hasGeneratedLivePhoto) {
670
+ const tipImg = await (0, module_1.Render)(this.e, 'other/live-photo-tip', {
671
+ title: '实况照片已生成',
672
+ description: '保存原图到相册即可识别为实况图'
673
+ });
674
+ processedImages.push(...tipImg);
675
+ }
676
+ const bot = node_karin_1.default.getBot(botId);
677
+ try {
678
+ if (processedImages.length === 0) {
679
+ node_karin_1.logger.warn(`抖音图集推送解析未生成可发送内容,aweme_id=${Detail_Data.aweme_id}`);
680
+ }
681
+ else {
682
+ const Element = node_karin_1.common.makeForward(processedImages, botId, bot.account.name);
683
+ await bot.sendForwardMsg(Contact, Element, {
684
+ source: '图集内容',
685
+ summary: `查看${Element.length}张图片/视频消息`,
686
+ prompt: '抖音图集解析结果',
687
+ news: [{ text: '点击查看解析结果' }]
688
+ });
689
+ }
690
+ }
691
+ catch (error) {
692
+ node_karin_1.logger.error(`发送图集失败: ${error}`);
693
+ }
694
+ finally {
695
+ for (const item of temp) {
696
+ await module_1.Common.removeFile(item.filepath, true);
697
+ }
698
+ }
699
+ }
700
+ else {
701
+ // 纯静态图集
702
+ const imageres = [];
703
+ let image_url;
704
+ for (const [index, item] of Detail_Data.images.entries()) {
705
+ image_url = item.url_list[2] ?? item.url_list[1]; // 图片地址
706
+ if (!image_url)
707
+ continue;
708
+ const imageUrl = await (0, module_1.processImageUrl)(image_url, Detail_Data.desc, index);
709
+ imageres.push(node_karin_1.segment.image(imageUrl));
710
+ }
711
+ const bot = node_karin_1.default.getBot(botId);
712
+ if (imageres.length === 1 && image_url) {
713
+ // 单张图片直接发送
714
+ const imageUrl = await (0, module_1.processImageUrl)(image_url, Detail_Data.desc);
715
+ await bot.sendMsg(Contact, [node_karin_1.segment.image(imageUrl)]);
716
+ }
717
+ else {
718
+ // 多张图片使用合并转发
719
+ const forwardMsg = node_karin_1.common.makeForward(imageres, botId, bot.account.name);
720
+ await bot.sendForwardMsg(Contact, forwardMsg, {
721
+ source: '图片合集',
722
+ summary: `查看${forwardMsg.length}张图片消息`,
723
+ prompt: '抖音图集解析结果',
724
+ news: [{ text: '点击查看解析结果' }]
725
+ });
726
+ }
727
+ }
728
+ }
729
+ }
730
+ }
731
+ }
732
+ // 添加作品缓存(直播不需要缓存aweme_id)
733
+ if (skip || (pushItem.pushType !== 'live' && status.message_id)) {
734
+ await module_1.douyinDB.addAwemeCache(actualAwemeId, pushItem.sec_uid, groupId, pushItem.pushType);
735
+ }
736
+ }
737
+ }
738
+ return true;
739
+ }
740
+ /**
741
+ * 根据配置文件获取用户当天的作品列表。
742
+ * @returns 将要推送的列表
743
+ */
744
+ async getDynamicList(userList) {
745
+ const willbepushlist = {};
746
+ try {
747
+ /** 过滤掉不启用的订阅项 */
748
+ const filteredUserList = userList.filter((item) => item.switch !== false);
749
+ for (const item of filteredUserList) {
750
+ await node_karin_1.common.sleep(2000);
751
+ if (!item.sec_uid) {
752
+ node_karin_1.logger.warn(`用户 ${item.remark || item.short_id} 缺少 sec_uid,跳过`);
753
+ continue;
754
+ }
755
+ const sec_uid = item.sec_uid;
756
+ const pushTypes = item.pushTypes || ['post']; // 默认推送作品列表
757
+ node_karin_1.logger.debug(`开始获取用户:${item.remark}(${sec_uid})的内容,推送类型:${pushTypes.join(', ')}`);
758
+ const userinfo = await this.amagi.douyin.fetcher.fetchUserProfile({ sec_uid });
759
+ const targets = item.group_id.map((groupWithBot) => {
760
+ const [groupId, botId] = groupWithBot.split(':');
761
+ return { groupId, botId };
762
+ });
763
+ // 如果没有订阅群组,跳过该用户
764
+ if (targets.length === 0)
765
+ continue;
766
+ // special_state 特殊状态,用户已注销
767
+ if (userinfo.data.user?.special_state_info?.special_state === 1 && userinfo.data.user?.user_deleted === true) {
768
+ node_karin_1.logger.warn(`${item.remark}(${sec_uid})${userinfo.data.user.special_state_info.title}`);
769
+ continue;
770
+ }
771
+ // 遍历每种推送类型
772
+ for (const pushType of pushTypes) {
773
+ await node_karin_1.common.sleep(1000);
774
+ // 处理直播推送
775
+ if (pushType === 'live') {
776
+ const liveItem = await (0, live_1.processLiveStream)(sec_uid, userinfo.data, item, targets, this.amagi);
777
+ if (liveItem) {
778
+ willbepushlist[`live_${sec_uid}`] = liveItem;
779
+ }
780
+ continue;
781
+ }
782
+ let contentList = [];
783
+ let listName = '';
784
+ // 根据推送类型获取不同的列表
785
+ switch (pushType) {
786
+ case 'post':
787
+ listName = '作品列表';
788
+ const videolist = await this.amagi.douyin.fetcher.fetchUserVideoList({
789
+ sec_uid,
790
+ number: 15
791
+ });
792
+ contentList = videolist.data.aweme_list || [];
793
+ break;
794
+ case 'favorite':
795
+ listName = '喜欢列表';
796
+ const favoritelist = await this.amagi.douyin.fetcher.fetchUserFavoriteList({
797
+ sec_uid,
798
+ number: 15
799
+ });
800
+ if (favoritelist.data.aweme_list.length === 0)
801
+ node_karin_1.logger.warn(`${item.remark}(${item.short_id}) 获取到的喜欢列表数量为零!此博主可能未公开他/她的喜欢列表`);
802
+ contentList = favoritelist.data.aweme_list || [];
803
+ break;
804
+ case 'recommend':
805
+ listName = '推荐列表';
806
+ const recommendlist = await this.amagi.douyin.fetcher.fetchUserRecommendList({
807
+ sec_uid,
808
+ number: 15
809
+ });
810
+ if (recommendlist.data.aweme_list.length === 0)
811
+ node_karin_1.logger.warn(`${item.remark}(${item.short_id}) 获取到的推荐列表数量为零!此博主可能未公开他/她的推荐列表`);
812
+ contentList = recommendlist.data.aweme_list || [];
813
+ break;
814
+ }
815
+ node_karin_1.logger.debug(`获取到 ${item.remark} 的${listName},共 ${contentList.length} 条`);
816
+ // 根据推送类型调用不同的处理函数
817
+ if (contentList.length > 0) {
818
+ let pushItems = [];
819
+ switch (pushType) {
820
+ case 'post':
821
+ pushItems = await (0, post_1.processPostList)(contentList, sec_uid, userinfo.data, item, targets);
822
+ break;
823
+ case 'favorite':
824
+ pushItems = await (0, favorite_1.processFavoriteList)(contentList, sec_uid, userinfo.data, item, targets, this.force);
825
+ break;
826
+ case 'recommend':
827
+ pushItems = await (0, recommend_1.processRecommendList)(contentList, sec_uid, userinfo.data, item, targets, this.force);
828
+ break;
829
+ }
830
+ // 将返回的推送项添加到willbepushlist中
831
+ for (const pushItem of pushItems) {
832
+ const key = `${pushType}_${pushItem.Detail_Data.aweme_id}`;
833
+ willbepushlist[key] = pushItem;
834
+ }
835
+ }
836
+ }
837
+ }
838
+ }
839
+ catch (error) {
840
+ throw new Error(`获取抖音用户内容列表失败: ${error}`);
841
+ }
842
+ return willbepushlist;
843
+ }
844
+ /**
845
+ * 检查作品是否已经推送过
846
+ * @param aweme_id 作品ID
847
+ * @param sec_uid 用户sec_uid
848
+ * @param groupIds 群组ID列表
849
+ * @param pushType 推送类型
850
+ * @returns 是否已经推送过
851
+ */
852
+ async checkIfAlreadyPushed(aweme_id, sec_uid, groupIds, pushType = 'post') {
853
+ for (const groupId of groupIds) {
854
+ const isPushed = await module_1.douyinDB.isAwemePushed(aweme_id, sec_uid, groupId, pushType);
855
+ if (!isPushed) {
856
+ return false;
857
+ }
858
+ }
859
+ return true;
860
+ }
861
+ /**
862
+ * 设置或更新特定 sec_uid 的群组信息。
863
+ * @param data 抖音的搜索结果数据。需要接口返回的原始数据
864
+ * @returns 操作成功或失败的消息字符串。
865
+ */
866
+ async setting(data) {
867
+ const groupInfo = await this.e.bot.getGroupInfo('groupId' in this.e && this.e.groupId ? this.e.groupId : '');
868
+ const config = Config_1.Config.pushlist; // 读取配置文件
869
+ const groupId = 'groupId' in this.e && this.e.groupId ? this.e.groupId : '';
870
+ const botId = this.e.selfId;
871
+ try {
872
+ // 获取用户输入的抖音号
873
+ const inputDouyinId = this.e.msg.replace(/^#设置抖音推送/, '').trim();
874
+ /**
875
+ * 搜索结果按响应形态自述(判别式 `__search_type`,由 amagi 的 normalize 按响应结构 +
876
+ * 请求类型写入)。订阅只认「用户搜索」那一支:抖音把 user 请求回成别的形态时在这里说清楚,
877
+ * 而不是拿一个 undefined 去遍历。
878
+ */
879
+ if (data.__search_type !== 'user') {
880
+ throw new Error(`抖音没有返回用户搜索结果(返回形态:${data.__search_type ?? '未知'})`);
881
+ }
882
+ // 在用户列表中查找匹配的用户
883
+ let matchedUser = null;
884
+ for (const userItem of data.user_list) {
885
+ const currentDouyinId = userItem.user_info.unique_id === '' ? userItem.user_info.short_id : userItem.user_info.unique_id;
886
+ if (currentDouyinId === inputDouyinId) {
887
+ matchedUser = userItem.user_info;
888
+ break;
889
+ }
890
+ }
891
+ // 如果没找到匹配的用户,抛出错误
892
+ if (!matchedUser) {
893
+ throw new Error(`未找到抖音号为 ${inputDouyinId} 的用户`);
894
+ }
895
+ // 使用匹配到的用户的 sec_uid 进行下一步请求
896
+ const sec_uid = matchedUser.sec_uid;
897
+ const UserInfoData = await this.amagi.douyin.fetcher.fetchUserProfile({ sec_uid });
898
+ /** 处理抖音号 */
899
+ let user_shortid;
900
+ user_shortid = UserInfoData.data.user.unique_id === '' ? UserInfoData.data.user.short_id : UserInfoData.data.user.unique_id;
901
+ // 初始化 douyin 数组
902
+ config.douyin ??= [];
903
+ // 查找是否存在相同的 sec_uid
904
+ const existingItem = config.douyin.find((item) => item.sec_uid === sec_uid);
905
+ // 检查数据库中是否已订阅
906
+ const isSubscribed = await module_1.douyinDB.isSubscribed(sec_uid, groupId);
907
+ if (existingItem) {
908
+ // 如果已经存在相同的 sec_uid,则检查是否存在相同的 group_id
909
+ let has = false;
910
+ let groupIndexToRemove = -1; // 用于记录要删除的 group_id 对象的索引
911
+ for (let index = 0; index < existingItem.group_id.length; index++) {
912
+ // 分割每个对象的 id 属性,并获取第一部分
913
+ const item = existingItem.group_id[index];
914
+ const existingGroupId = item.split(':')[0];
915
+ // 检查分割后的第一部分是否与提供的 group_id 相同
916
+ if (existingGroupId === String(groupId)) {
917
+ has = true;
918
+ groupIndexToRemove = index;
919
+ break; // 找到匹配项后退出循环
920
+ }
921
+ }
922
+ if (has) {
923
+ // 如果存在相同的 group_id,则删除它
924
+ existingItem.group_id.splice(groupIndexToRemove, 1);
925
+ // 同时从数据库中取消订阅
926
+ if (isSubscribed) {
927
+ await module_1.douyinDB.unsubscribeDouyinUser(groupId, sec_uid);
928
+ }
929
+ // 如果删除后 group_id 数组为空,则删除整个属性
930
+ if (existingItem.group_id.length === 0) {
931
+ const index = config.douyin.indexOf(existingItem);
932
+ config.douyin.splice(index, 1);
933
+ }
934
+ // 保存配置到文件
935
+ Config_1.Config.Modify('pushlist', 'douyin', config.douyin);
936
+ await this.e.reply(`群:${groupInfo.groupName}(${groupId})\n删除成功!${UserInfoData.data.user.nickname}\n抖音号:${user_shortid}`);
937
+ node_karin_1.logger.info(`\n删除成功!${UserInfoData.data.user.nickname}\n抖音号:${user_shortid}\nsec_uid${UserInfoData.data.user.sec_uid}`);
938
+ }
939
+ else {
940
+ // 否则,将新的 group_id 添加到该 sec_uid 对应的数组中
941
+ existingItem.group_id.push(`${groupId}:${botId}`);
942
+ // 确保 pushTypes 字段存在,如果不存在则添加默认值
943
+ if (!existingItem.pushTypes || existingItem.pushTypes.length === 0) {
944
+ existingItem.pushTypes = ['post', 'live'];
945
+ }
946
+ // 同时在数据库中添加订阅
947
+ if (!isSubscribed) {
948
+ await module_1.douyinDB.subscribeDouyinUser(groupId, botId, sec_uid, user_shortid, UserInfoData.data.user.nickname);
949
+ }
950
+ // 保存配置到文件
951
+ Config_1.Config.Modify('pushlist', 'douyin', config.douyin);
952
+ await this.e.reply(`群:${groupInfo.groupName}(${groupId})\n添加成功!${UserInfoData.data.user.nickname}\n抖音号:${user_shortid}`);
953
+ if (Config_1.Config.douyin.push.switch === false)
954
+ await this.e.reply('请发送「#设置抖音推送开启」以进行推送');
955
+ node_karin_1.logger.info(`\n设置成功!${UserInfoData.data.user.nickname}\n抖音号:${user_shortid}\nsec_uid${UserInfoData.data.user.sec_uid}`);
956
+ }
957
+ }
958
+ else {
959
+ // 如果不存在相同的 sec_uid,则新增一个属性
960
+ config.douyin.push({
961
+ switch: true,
962
+ sec_uid,
963
+ group_id: [`${groupId}:${botId}`],
964
+ remark: UserInfoData.data.user.nickname,
965
+ short_id: user_shortid,
966
+ pushTypes: ['post', 'live']
967
+ });
968
+ // 同时在数据库中添加订阅
969
+ if (!isSubscribed) {
970
+ await module_1.douyinDB.subscribeDouyinUser(groupId, botId, sec_uid, user_shortid, UserInfoData.data.user.nickname);
971
+ }
972
+ // 保存配置到文件
973
+ Config_1.Config.Modify('pushlist', 'douyin', config.douyin);
974
+ await this.e.reply(`群:${groupInfo.groupName}(${groupId})\n添加成功!${UserInfoData.data.user.nickname}\n抖音号:${user_shortid}`);
975
+ if (Config_1.Config.douyin.push.switch === false)
976
+ await this.e.reply('请发送「#设置抖音推送开启」以进行推送');
977
+ node_karin_1.logger.info(`\n设置成功!${UserInfoData.data.user.nickname}\n抖音号:${user_shortid}\nsec_uid${UserInfoData.data.user.sec_uid}`);
978
+ }
979
+ await this.renderPushList();
980
+ }
981
+ catch (error) {
982
+ throw new Error(`设置失败,请查看日志: ${error}`);
983
+ }
984
+ }
985
+ /** 渲染推送列表图片 */
986
+ async renderPushList() {
987
+ await this.syncConfigToDatabase();
988
+ const groupInfo = await this.e.bot.getGroupInfo('groupId' in this.e && this.e.groupId ? this.e.groupId : '');
989
+ // 获取当前群组的所有订阅
990
+ const subscriptions = await module_1.douyinDB.getGroupSubscriptions(groupInfo.groupId);
991
+ if (subscriptions.length === 0) {
992
+ await this.e.reply(`当前群:${groupInfo.groupName}(${groupInfo.groupId})\n没有设置任何抖音博主推送!\n可使用「#设置抖音推送 + 抖音号」进行设置`);
993
+ return;
994
+ }
995
+ const renderOpt = [];
996
+ for (const subscription of subscriptions) {
997
+ const sec_uid = subscription.sec_uid;
998
+ const userInfo = await this.amagi.douyin.fetcher.fetchUserProfile({ sec_uid });
999
+ // 查找配置文件中对应的全局开关状态
1000
+ const configItem = Config_1.Config.pushlist.douyin?.find((item) => item.sec_uid === sec_uid);
1001
+ const switchStatus = configItem?.switch !== false; // 默认为 true
1002
+ const pushTypes = configItem?.pushTypes || ['post'];
1003
+ renderOpt.push({
1004
+ avatar_img: userInfo.data.user.avatar_larger.url_list[0],
1005
+ username: userInfo.data.user.nickname,
1006
+ short_id: userInfo.data.user.unique_id === '' ? userInfo.data.user.short_id : userInfo.data.user.unique_id,
1007
+ fans: this.count(userInfo.data.user.follower_count),
1008
+ total_favorited: this.count(userInfo.data.user.total_favorited),
1009
+ following_count: this.count(userInfo.data.user.following_count),
1010
+ switch: switchStatus,
1011
+ pushTypes
1012
+ });
1013
+ }
1014
+ const img = await (0, module_1.Render)(this.e, 'douyin/userlist', {
1015
+ renderOpt,
1016
+ groupInfo: {
1017
+ groupId: groupInfo.groupId || '',
1018
+ groupName: groupInfo.groupName || '',
1019
+ groupAvatar: groupInfo.avatar || ''
1020
+ }
1021
+ });
1022
+ await this.e.reply(img);
1023
+ }
1024
+ /**
1025
+ * 强制推送
1026
+ * @param data 处理完成的推送列表
1027
+ */
1028
+ async forcepush(data) {
1029
+ const currentGroupId = 'groupId' in this.e && this.e.groupId ? this.e.groupId : '';
1030
+ const currentBotId = this.e.selfId;
1031
+ // 如果不是全部强制推送,需要过滤数据
1032
+ if (!this.e.msg.includes('全部')) {
1033
+ // 获取当前群组订阅的所有抖音用户
1034
+ const subscriptions = await module_1.douyinDB.getGroupSubscriptions(currentGroupId);
1035
+ const subscribedUids = subscriptions.map((sub) => sub.sec_uid);
1036
+ // 创建一个新的推送列表,只包含当前群组订阅的用户的作品
1037
+ const filteredData = {};
1038
+ for (const awemeId in data) {
1039
+ // 检查该作品的用户是否被当前群组订阅
1040
+ if (subscribedUids.includes(data[awemeId].sec_uid)) {
1041
+ // 复制该作品到过滤后的列表,并将目标设置为当前群组
1042
+ filteredData[awemeId] = {
1043
+ ...data[awemeId],
1044
+ targets: [
1045
+ {
1046
+ groupId: currentGroupId,
1047
+ botId: currentBotId
1048
+ }
1049
+ ]
1050
+ };
1051
+ }
1052
+ }
1053
+ // 使用过滤后的数据进行推送
1054
+ await this.getdata(filteredData);
1055
+ }
1056
+ else {
1057
+ // 全部强制推送,保持原有逻辑
1058
+ await this.getdata(data);
1059
+ }
1060
+ }
1061
+ /**
1062
+ * 检查并更新备注信息
1063
+ */
1064
+ async checkremark() {
1065
+ // 读取配置文件内容
1066
+ const config = Config_1.Config.pushlist;
1067
+ const updateList = [];
1068
+ if (Config_1.Config.pushlist.douyin === null || Config_1.Config.pushlist.douyin.length === 0)
1069
+ return true;
1070
+ // 遍历配置文件中的用户列表,收集需要更新备注信息的用户
1071
+ for (const i of Config_1.Config.pushlist.douyin) {
1072
+ const remark = i.remark;
1073
+ const sec_uid = i.sec_uid;
1074
+ if (remark === undefined || remark === '') {
1075
+ updateList.push({ sec_uid });
1076
+ }
1077
+ }
1078
+ // 如果有需要更新备注的用户,则逐个获取备注信息并更新到配置文件中
1079
+ if (updateList.length > 0) {
1080
+ for (const i of updateList) {
1081
+ // 从外部数据源获取用户备注信息
1082
+ const userinfo = await this.amagi.douyin.fetcher.fetchUserProfile({ sec_uid: i.sec_uid });
1083
+ const remark = userinfo.data.user.nickname;
1084
+ // 在配置文件中找到对应的用户,并更新其备注信息
1085
+ const matchingItemIndex = config.douyin.findIndex((item) => item.sec_uid === i.sec_uid);
1086
+ if (matchingItemIndex !== -1) {
1087
+ config.douyin[matchingItemIndex].remark = remark;
1088
+ }
1089
+ }
1090
+ // 将更新后的配置文件内容写回文件
1091
+ Config_1.Config.Modify('pushlist', 'douyin', config.douyin);
1092
+ }
1093
+ return false;
1094
+ }
1095
+ /**
1096
+ * 格式化数字
1097
+ */
1098
+ count(num) {
1099
+ if (num > 10000) {
1100
+ return (num / 10000).toFixed(1) + '万';
1101
+ }
1102
+ return num.toString();
1103
+ }
1104
+ }
1105
+ exports.DouYinpush = DouYinpush;
1106
+ /**
1107
+ * 判断标题是否有屏蔽词或屏蔽标签
1108
+ * @param PushItem 推送项
1109
+ * @returns 是否应该跳过推送
1110
+ */
1111
+ const skipDynamic = async (PushItem) => {
1112
+ // 直播动态不做内容过滤
1113
+ if (PushItem.pushType === 'live' || 'liveStatus' in PushItem.Detail_Data) {
1114
+ return false;
1115
+ }
1116
+ const tags = [];
1117
+ // 提取标签
1118
+ if (PushItem.Detail_Data.text_extra) {
1119
+ for (const item of PushItem.Detail_Data.text_extra) {
1120
+ if (item.hashtag_name) {
1121
+ tags.push(item.hashtag_name);
1122
+ }
1123
+ }
1124
+ }
1125
+ node_karin_1.logger.debug(`检查作品是否需要过滤:${PushItem.Detail_Data.share_url}`);
1126
+ const shouldFilter = await module_1.douyinDB.shouldFilter(PushItem, tags);
1127
+ return shouldFilter;
1128
+ };