karin-plugin-qgroup-file2openlist 0.0.15 → 0.0.19

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.
@@ -0,0 +1,63 @@
1
+ import {
2
+ ensurePluginResources
3
+ } from "../chunk-QB3GSENE.js";
4
+ import {
5
+ dir
6
+ } from "../chunk-IZS467MR.js";
7
+
8
+ // src/apps/help.ts
9
+ import path from "path";
10
+ import { karin, logger, render, segment } from "node-karin";
11
+ var formatDateTime = (date) => {
12
+ try {
13
+ return date.toLocaleString("zh-CN", {
14
+ year: "numeric",
15
+ month: "2-digit",
16
+ day: "2-digit",
17
+ hour: "2-digit",
18
+ minute: "2-digit",
19
+ hour12: false
20
+ });
21
+ } catch {
22
+ return date.toISOString();
23
+ }
24
+ };
25
+ var helpImage = karin.command(/^#?(群文件帮助|同步群文件帮助|openlist帮助)$/i, async (e) => {
26
+ try {
27
+ await ensurePluginResources();
28
+ const html = path.join(dir.defResourcesDir, "template", "help.html");
29
+ const img = await render.render({
30
+ name: "qgroup-help",
31
+ encoding: "base64",
32
+ file: html,
33
+ type: "png",
34
+ data: {
35
+ name: dir.name,
36
+ version: dir.version,
37
+ generatedAt: formatDateTime(/* @__PURE__ */ new Date())
38
+ },
39
+ setViewport: {
40
+ width: 900,
41
+ height: 720,
42
+ deviceScaleFactor: 2
43
+ },
44
+ pageGotoParams: {
45
+ waitUntil: "networkidle2"
46
+ }
47
+ });
48
+ await e.reply(segment.image(`base64://${img}`));
49
+ return true;
50
+ } catch (error) {
51
+ logger.error(error);
52
+ await e.reply(`\u5E2E\u52A9\u56FE\u6E32\u67D3\u5931\u8D25\uFF1A${error?.message ?? String(error)}`);
53
+ return true;
54
+ }
55
+ }, {
56
+ priority: 9999,
57
+ log: true,
58
+ name: "\u7FA4\u6587\u4EF6\u5E2E\u52A9",
59
+ permission: "all"
60
+ });
61
+ export {
62
+ helpImage
63
+ };
@@ -1,3 +1,6 @@
1
+ import {
2
+ ensurePluginResources
3
+ } from "../chunk-QB3GSENE.js";
1
4
  import {
2
5
  config
3
6
  } from "../chunk-5WVKHIPK.js";
@@ -9,6 +12,7 @@ import {
9
12
  import { karin, render, segment, logger } from "node-karin";
10
13
  var image = karin.command(/^#?测试渲染$/, async (e) => {
11
14
  try {
15
+ await ensurePluginResources();
12
16
  const html = dir.defResourcesDir + "/template/test.html";
13
17
  const image2 = dir.defResourcesDir + "/image/\u542F\u7A0B\u5BA3\u53D1.png";
14
18
  const img = await render.render({
@@ -43,6 +47,7 @@ var image = karin.command(/^#?测试渲染$/, async (e) => {
43
47
  var renderUrl = karin.command(/^#?渲染/, async (e) => {
44
48
  const file = e.msg.replace(/^#?渲染/, "").trim();
45
49
  try {
50
+ await ensurePluginResources();
46
51
  const img = await render.render({
47
52
  name: "render",
48
53
  encoding: "base64",
@@ -0,0 +1,36 @@
1
+ import {
2
+ dir
3
+ } from "./chunk-IZS467MR.js";
4
+
5
+ // src/utils/resources.ts
6
+ import fs from "fs";
7
+ import path from "path";
8
+ import { createPluginDir, getAllFilesSync } from "node-karin";
9
+ var ensurePromise = null;
10
+ var ensurePluginResources = async () => {
11
+ if (ensurePromise) return ensurePromise;
12
+ ensurePromise = (async () => {
13
+ const sourceDir = path.join(dir.pluginDir, "resources");
14
+ const targetDir = dir.defResourcesDir;
15
+ if (!fs.existsSync(sourceDir)) return;
16
+ await createPluginDir(dir.name, ["resources"]);
17
+ const files = getAllFilesSync(sourceDir, { returnType: "rel" });
18
+ for (const rel of files) {
19
+ const normalizedRel = rel.replaceAll("\\", "/");
20
+ const shouldOverwrite = normalizedRel.startsWith("template/");
21
+ const sourcePath = path.join(sourceDir, rel);
22
+ const targetPath = path.join(targetDir, rel);
23
+ if (fs.existsSync(targetPath) && !shouldOverwrite) continue;
24
+ fs.mkdirSync(path.dirname(targetPath), { recursive: true });
25
+ fs.copyFileSync(sourcePath, targetPath);
26
+ }
27
+ })().catch((error) => {
28
+ ensurePromise = null;
29
+ throw error;
30
+ });
31
+ return ensurePromise;
32
+ };
33
+
34
+ export {
35
+ ensurePluginResources
36
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "karin-plugin-qgroup-file2openlist",
3
- "version": "0.0.15",
3
+ "version": "0.0.19",
4
4
  "author": "429",
5
5
  "type": "module",
6
6
  "description": "karin plugin for QGroupFile backup",
@@ -0,0 +1,204 @@
1
+ <!DOCTYPE html>
2
+ <html lang="zh-CN">
3
+
4
+ <head>
5
+ <meta charset="UTF-8" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <title>{{name}} 帮助</title>
8
+ <style>
9
+ :root {
10
+ --bg: #ffffff;
11
+ --fg: #0f0f0f;
12
+ --muted: #666666;
13
+ --line: #0f0f0f;
14
+ --soft: #f3f3f3;
15
+ }
16
+
17
+ * {
18
+ box-sizing: border-box;
19
+ }
20
+
21
+ body {
22
+ width: 900px;
23
+ height: 720px;
24
+ margin: 0;
25
+ padding: 0;
26
+ background: var(--bg);
27
+ color: var(--fg);
28
+ font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
29
+ position: relative;
30
+ }
31
+
32
+ .wrap {
33
+ padding: 40px 44px;
34
+ }
35
+
36
+ .header {
37
+ display: flex;
38
+ align-items: baseline;
39
+ justify-content: space-between;
40
+ gap: 16px;
41
+ padding-bottom: 18px;
42
+ border-bottom: 3px solid var(--line);
43
+ }
44
+
45
+ .title {
46
+ font-size: 30px;
47
+ font-weight: 800;
48
+ letter-spacing: 0.3px;
49
+ line-height: 1.1;
50
+ }
51
+
52
+ .meta {
53
+ text-align: right;
54
+ color: var(--muted);
55
+ font-size: 12px;
56
+ line-height: 1.6;
57
+ }
58
+
59
+ .mono {
60
+ font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
61
+ }
62
+
63
+ .section {
64
+ margin-top: 22px;
65
+ padding: 18px;
66
+ background: var(--soft);
67
+ border: 2px solid var(--line);
68
+ }
69
+
70
+ .section-title {
71
+ font-weight: 800;
72
+ font-size: 14px;
73
+ margin: 0 0 12px 0;
74
+ }
75
+
76
+ .cmd {
77
+ display: flex;
78
+ gap: 14px;
79
+ padding: 10px 0;
80
+ border-top: 1px solid rgba(15, 15, 15, 0.15);
81
+ }
82
+
83
+ .cmd:first-of-type {
84
+ border-top: none;
85
+ padding-top: 0;
86
+ }
87
+
88
+ .cmd-key {
89
+ width: 190px;
90
+ flex: 0 0 auto;
91
+ font-weight: 800;
92
+ font-size: 13px;
93
+ white-space: nowrap;
94
+ }
95
+
96
+ .cmd-desc {
97
+ flex: 1 1 auto;
98
+ color: #1c1c1c;
99
+ font-size: 13px;
100
+ line-height: 1.55;
101
+ }
102
+
103
+ .tips {
104
+ margin-top: 16px;
105
+ padding: 0;
106
+ list-style: none;
107
+ color: var(--muted);
108
+ font-size: 12px;
109
+ line-height: 1.7;
110
+ }
111
+
112
+ .tips li {
113
+ display: flex;
114
+ gap: 10px;
115
+ padding: 6px 0;
116
+ border-top: 1px dashed rgba(15, 15, 15, 0.25);
117
+ }
118
+
119
+ .tips li:first-child {
120
+ border-top: none;
121
+ padding-top: 0;
122
+ }
123
+
124
+ .dot {
125
+ width: 10px;
126
+ height: 10px;
127
+ border: 2px solid var(--line);
128
+ margin-top: 4px;
129
+ flex: 0 0 auto;
130
+ }
131
+
132
+ .footer {
133
+ position: absolute;
134
+ left: 44px;
135
+ right: 44px;
136
+ bottom: 26px;
137
+ display: flex;
138
+ justify-content: space-between;
139
+ gap: 12px;
140
+ color: var(--muted);
141
+ font-size: 11px;
142
+ letter-spacing: 0.2px;
143
+ }
144
+
145
+ .badge {
146
+ display: inline-block;
147
+ padding: 4px 8px;
148
+ border: 1px solid rgba(15, 15, 15, 0.35);
149
+ background: #fff;
150
+ color: #111;
151
+ border-radius: 999px;
152
+ }
153
+ </style>
154
+ </head>
155
+
156
+ <body>
157
+ <div class="wrap">
158
+ <div class="header">
159
+ <div>
160
+ <div class="title">群文件同步 · 帮助</div>
161
+ <div class="meta">插件:<span class="mono">{{name}}</span> <span class="badge mono">v{{version}}</span></div>
162
+ </div>
163
+ <div class="meta">
164
+ <div>黑白模式 · 简洁指令卡</div>
165
+ <div>{{generatedAt}}</div>
166
+ </div>
167
+ </div>
168
+
169
+ <div class="section">
170
+ <div class="section-title">常用命令</div>
171
+
172
+ <div class="cmd">
173
+ <div class="cmd-key mono">#同步群文件</div>
174
+ <div class="cmd-desc">把群文件同步到 OpenList(默认增量)。群内建议管理员/群主使用。</div>
175
+ </div>
176
+ <div class="cmd">
177
+ <div class="cmd-key mono">#导出群文件</div>
178
+ <div class="cmd-desc">导出群文件列表(可用于排查缺失/重复)。</div>
179
+ </div>
180
+ <div class="cmd">
181
+ <div class="cmd-key mono">#群同步配置</div>
182
+ <div class="cmd-desc">查看/设置当前群的同步目标目录、模式等参数。</div>
183
+ </div>
184
+ <div class="cmd">
185
+ <div class="cmd-key mono">#群文件帮助</div>
186
+ <div class="cmd-desc">发送本帮助图片。</div>
187
+ </div>
188
+
189
+ <ul class="tips">
190
+ <li><span class="dot"></span><span>试试:<span class="mono">#同步群文件 --help</span> 查看参数说明。</span></li>
191
+ <li><span class="dot"></span><span>全量同步:<span class="mono">#同步群文件 --mode=full</span>(文件多时更慢)。</span></li>
192
+ <li><span class="dot"></span><span>自定义目标目录:<span class="mono">#同步群文件 --to=/qq/群号</span></span></li>
193
+ <li><span class="dot"></span><span>只想先验证连通性:先少量同步或先跑导出。</span></li>
194
+ </ul>
195
+ </div>
196
+ </div>
197
+
198
+ <div class="footer">
199
+ <div>提示:此图由前端模板渲染生成</div>
200
+ <div class="mono">#群文件帮助</div>
201
+ </div>
202
+ </body>
203
+
204
+ </html>