@wahaha216/koishi-plugin-jmcomic 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.d.ts +1 -0
- package/lib/index.js +34 -16
- package/package.json +1 -1
- package/readme.md +9 -0
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -33,14 +33,14 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
33
33
|
// src/locales/zh-CN.yml
|
|
34
34
|
var require_zh_CN = __commonJS({
|
|
35
35
|
"src/locales/zh-CN.yml"(exports2, module2) {
|
|
36
|
-
module2.exports = { commands: { jm: { description: "下载JM漫画,无需python!", examples: "jm 114514", messages: { empty: "JMID 不能为空", formatError: "JMID 格式错误", notFound: "找不到该车牌", pleaseWait: "正在获取,请等待亿会" } } }, _config: [{ $desc: "基础设置", url: "JM域名", sendMethod: "发送方式", retryCount: "重试次数限制", password: "密码,留空则不加密", fileName: "文件名定义<br>`{{name}}`:标题<br>`{{id}}`:章节或者本子ID<br>`{{index}}`:多章节本子自动填充`1` 、 `2`" }, { level: "压缩级别,0~9,0为仅存储" }, { $desc: "缓存设置", cache: "缓存文件" }, { autoDelete: "自动删除缓存,**依赖cron服务**" }, { cron: "5位cron表达式", deleteInStart: "启动时检测", keepDays: "缓存保留时间(天)" }, { $desc: "开发者选项", debug: "调试模式,输出更多信息" }] };
|
|
36
|
+
module2.exports = { commands: { jm: { description: "下载JM漫画,无需python!", examples: "jm 114514", messages: { empty: "JMID 不能为空", formatError: "JMID 格式错误", notFound: "找不到该车牌", pleaseWait: "正在获取,请等待亿会" } } }, _config: [{ $desc: "基础设置", url: "JM域名", sendMethod: "发送方式", fileMethod: "文件获取方式<br>`buffer`: 读取成buffer后发送给bot实现端<br>`file`: 以`file:///` 本地路径形式发送,如docker环境,请在bot实现端同时映射/koishi目录", retryCount: "重试次数限制", password: "密码,留空则不加密", fileName: "文件名定义<br>`{{name}}`:标题<br>`{{id}}`:章节或者本子ID<br>`{{index}}`:多章节本子自动填充`1` 、 `2`" }, { level: "压缩级别,0~9,0为仅存储" }, { $desc: "缓存设置", cache: "缓存文件" }, { autoDelete: "自动删除缓存,**依赖cron服务**" }, { cron: "5位cron表达式", deleteInStart: "启动时检测", keepDays: "缓存保留时间(天)" }, { $desc: "开发者选项", debug: "调试模式,输出更多信息" }] };
|
|
37
37
|
}
|
|
38
38
|
});
|
|
39
39
|
|
|
40
40
|
// src/locales/en-US.yml
|
|
41
41
|
var require_en_US = __commonJS({
|
|
42
42
|
"src/locales/en-US.yml"(exports2, module2) {
|
|
43
|
-
module2.exports = { commands: { jm: { description: "Download JM comics without python!", examples: "jm 114514", messages: { empty: "JM ID cannot be empty", formatError: "JM ID format error", notFound: "The JM ID cannot be found", pleaseWait: "Getting it, please wait" } } }, _config: [{ $desc: "Basic settings", url: "JM domain name", sendMethod: "Send method", retryCount: "Retry limit", password: "Password, leave blank without encryption", fileName: "File name definition<br>`{{name}}`: Title<br>`{{id}}`: Chapter or Book ID<br>`{{index}}`: Multi-chapter book auto-filling `_1` `_2`" }, { level: "Compression level, 0~9, 0 is only stores" }, { $desc: "Cache settings", cache: "Cache files" }, { autoDelete: "Automatically delete cache, **need cron services**" }, { cron: "5-bit cron expression", deleteInStart: "Detection on startup", keepDays: "Cache retention time (days)" }, { $desc: "Developer Options", debug: "Debug mode, output more information" }] };
|
|
43
|
+
module2.exports = { commands: { jm: { description: "Download JM comics without python!", examples: "jm 114514", messages: { empty: "JM ID cannot be empty", formatError: "JM ID format error", notFound: "The JM ID cannot be found", pleaseWait: "Getting it, please wait" } } }, _config: [{ $desc: "Basic settings", url: "JM domain name", sendMethod: "Send method", fileMethod: "File acquisition method<br>`buffer`: Read as buffer and send it to the bot implementation.<br>`file`: Send it in the local path of `file:///`. For example, if in the docker environment, please map the `/koishi` directory at the bot implementation.", retryCount: "Retry limit", password: "Password, leave blank without encryption", fileName: "File name definition<br>`{{name}}`: Title<br>`{{id}}`: Chapter or Book ID<br>`{{index}}`: Multi-chapter book auto-filling `_1` `_2`" }, { level: "Compression level, 0~9, 0 is only stores" }, { $desc: "Cache settings", cache: "Cache files" }, { autoDelete: "Automatically delete cache, **need cron services**" }, { cron: "5-bit cron expression", deleteInStart: "Detection on startup", keepDays: "Cache retention time (days)" }, { $desc: "Developer Options", debug: "Debug mode, output more information" }] };
|
|
44
44
|
}
|
|
45
45
|
});
|
|
46
46
|
|
|
@@ -251,7 +251,7 @@ async function deleteFewDaysAgoFolders(path, days) {
|
|
|
251
251
|
}
|
|
252
252
|
__name(deleteFewDaysAgoFolders, "deleteFewDaysAgoFolders");
|
|
253
253
|
function formatFileName(originName, name2, id, index) {
|
|
254
|
-
return originName.replaceAll("{{name}}", name2).replaceAll("{{id}}", id).replaceAll("{{index}}", index ? `${index}` : "");
|
|
254
|
+
return originName.replaceAll("{{name}}", name2).replaceAll("{{id}}", id).replaceAll("{{index}}", index ? `${index}` : "").trim();
|
|
255
255
|
}
|
|
256
256
|
__name(formatFileName, "formatFileName");
|
|
257
257
|
|
|
@@ -1037,6 +1037,7 @@ var Config = import_koishi.Schema.intersect([
|
|
|
1037
1037
|
import_koishi.Schema.object({
|
|
1038
1038
|
retryCount: import_koishi.Schema.number().min(1).max(5).default(5),
|
|
1039
1039
|
sendMethod: import_koishi.Schema.union(["zip", "pdf"]).default("pdf"),
|
|
1040
|
+
fileMethod: import_koishi.Schema.union(["buffer", "file"]).default("buffer"),
|
|
1040
1041
|
password: import_koishi.Schema.string(),
|
|
1041
1042
|
fileName: import_koishi.Schema.string().default("{{name}} ({{id}})_{{index}}")
|
|
1042
1043
|
}),
|
|
@@ -1130,18 +1131,23 @@ async function apply(ctx, config) {
|
|
|
1130
1131
|
filePath = await jmClient.albumToPdf(album, config.password);
|
|
1131
1132
|
}
|
|
1132
1133
|
if (typeof filePath === "string") {
|
|
1133
|
-
const buffer = await (0, import_promises3.readFile)(filePath);
|
|
1134
1134
|
const { fileName, ext, dir } = getFileInfo(filePath);
|
|
1135
1135
|
const name2 = formatFileName(config.fileName, fileName, albumId);
|
|
1136
1136
|
if (debug) logger.info(`文件名:${name2}.${ext}`);
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1137
|
+
if (config.fileMethod === "buffer") {
|
|
1138
|
+
const buffer = await (0, import_promises3.readFile)(filePath);
|
|
1139
|
+
await session.send([
|
|
1140
|
+
import_koishi.h.file(buffer, ext, { title: `${name2}.${ext}` })
|
|
1141
|
+
]);
|
|
1142
|
+
} else {
|
|
1143
|
+
await session.send([
|
|
1144
|
+
import_koishi.h.file(`file:///${filePath}`, { title: `${name2}.${ext}` })
|
|
1145
|
+
]);
|
|
1146
|
+
}
|
|
1140
1147
|
if (!config.cache) (0, import_promises3.rm)(dir, { recursive: true });
|
|
1141
1148
|
} else {
|
|
1142
1149
|
let fileDir;
|
|
1143
1150
|
for (const [index, p] of filePath.entries()) {
|
|
1144
|
-
const buffer = await (0, import_promises3.readFile)(p);
|
|
1145
1151
|
const { fileName, ext, dir } = getFileInfo(p);
|
|
1146
1152
|
const name2 = formatFileName(
|
|
1147
1153
|
config.fileName,
|
|
@@ -1150,9 +1156,16 @@ async function apply(ctx, config) {
|
|
|
1150
1156
|
index + 1
|
|
1151
1157
|
);
|
|
1152
1158
|
if (debug) logger.info(`文件名:${name2}.${ext}`);
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1159
|
+
if (config.fileMethod === "buffer") {
|
|
1160
|
+
const buffer = await (0, import_promises3.readFile)(p);
|
|
1161
|
+
await session.send([
|
|
1162
|
+
import_koishi.h.file(buffer, ext, { title: `${name2}.${ext}` })
|
|
1163
|
+
]);
|
|
1164
|
+
} else {
|
|
1165
|
+
await session.send([
|
|
1166
|
+
import_koishi.h.file(`file:///${p}`, { title: `${name2}.${ext}` })
|
|
1167
|
+
]);
|
|
1168
|
+
}
|
|
1156
1169
|
fileDir = dir;
|
|
1157
1170
|
}
|
|
1158
1171
|
if (!config.cache) (0, import_promises3.rm)(fileDir, { recursive: true });
|
|
@@ -1195,14 +1208,19 @@ async function apply(ctx, config) {
|
|
|
1195
1208
|
} else {
|
|
1196
1209
|
filePath = await jmClient.photoToPdf(photo, photoName);
|
|
1197
1210
|
}
|
|
1198
|
-
const buffer = await (0, import_promises3.readFile)(filePath);
|
|
1199
1211
|
const { fileName, ext, dir } = getFileInfo(filePath);
|
|
1200
1212
|
const name2 = formatFileName(config.fileName, fileName, photoId);
|
|
1201
|
-
if (debug) logger.info(`文件名:${filePath}`);
|
|
1202
1213
|
if (debug) logger.info(`文件名:${name2}.${ext}`);
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1214
|
+
if (config.fileMethod === "buffer") {
|
|
1215
|
+
const buffer = await (0, import_promises3.readFile)(filePath);
|
|
1216
|
+
await session.send([
|
|
1217
|
+
import_koishi.h.file(buffer, ext, { title: `${name2} (${photoId}).${ext}` })
|
|
1218
|
+
]);
|
|
1219
|
+
} else {
|
|
1220
|
+
await session.send([
|
|
1221
|
+
import_koishi.h.file(`file:///${filePath}`, { title: `${name2}.${ext}` })
|
|
1222
|
+
]);
|
|
1223
|
+
}
|
|
1206
1224
|
if (!config.cache) (0, import_promises3.rm)(dir, { recursive: true });
|
|
1207
1225
|
} catch (error) {
|
|
1208
1226
|
if (error instanceof Error) {
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -16,11 +16,20 @@ jm photo xxxxxx
|
|
|
16
16
|
|
|
17
17
|
## 更新日志
|
|
18
18
|
|
|
19
|
+
<details>
|
|
20
|
+
<summary>0.0.4</summary>
|
|
21
|
+
1.文件名移除前后空格
|
|
22
|
+
|
|
23
|
+
2.新增文件发送配置,用于配置文件是以 buffer 读取后发送还是以本地地址的形式发送。docker 中使用 file 形式需要在 bot 实现端同时映射/koishi 目录
|
|
24
|
+
|
|
25
|
+
</details>
|
|
26
|
+
|
|
19
27
|
<details>
|
|
20
28
|
<summary>0.0.3</summary>
|
|
21
29
|
忘了给自动删除做判断
|
|
22
30
|
</details>
|
|
23
31
|
|
|
32
|
+
<details>
|
|
24
33
|
<summary>0.0.2</summary>
|
|
25
34
|
依赖从peerDependencies移动到dependencies
|
|
26
35
|
</details>
|