@wahaha216/koishi-plugin-jmcomic 0.0.2 → 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 +35 -18
- package/package.json +1 -1
- package/readme.md +13 -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
|
|
|
@@ -1035,9 +1035,9 @@ var JMAppClient = class _JMAppClient extends JMClientAbstract {
|
|
|
1035
1035
|
var name = "jmcomic";
|
|
1036
1036
|
var Config = import_koishi.Schema.intersect([
|
|
1037
1037
|
import_koishi.Schema.object({
|
|
1038
|
-
// url: Schema.string().required().default("18comic-mygo.vip"),
|
|
1039
1038
|
retryCount: import_koishi.Schema.number().min(1).max(5).default(5),
|
|
1040
1039
|
sendMethod: import_koishi.Schema.union(["zip", "pdf"]).default("pdf"),
|
|
1040
|
+
fileMethod: import_koishi.Schema.union(["buffer", "file"]).default("buffer"),
|
|
1041
1041
|
password: import_koishi.Schema.string(),
|
|
1042
1042
|
fileName: import_koishi.Schema.string().default("{{name}} ({{id}})_{{index}}")
|
|
1043
1043
|
}),
|
|
@@ -1097,7 +1097,7 @@ async function apply(ctx, config) {
|
|
|
1097
1097
|
const photoPath = (0, import_path3.join)(ctx.baseDir, "data", "jmcomic", "photo");
|
|
1098
1098
|
await deleteFewDaysAgoFolders(photoPath, config.keepDays);
|
|
1099
1099
|
}, "scheduleFn");
|
|
1100
|
-
if (ctx.cron) {
|
|
1100
|
+
if (config.autoDelete && ctx.cron) {
|
|
1101
1101
|
ctx.cron(config.cron, scheduleFn);
|
|
1102
1102
|
}
|
|
1103
1103
|
if (config.autoDelete && config.deleteInStart) scheduleFn();
|
|
@@ -1131,18 +1131,23 @@ async function apply(ctx, config) {
|
|
|
1131
1131
|
filePath = await jmClient.albumToPdf(album, config.password);
|
|
1132
1132
|
}
|
|
1133
1133
|
if (typeof filePath === "string") {
|
|
1134
|
-
const buffer = await (0, import_promises3.readFile)(filePath);
|
|
1135
1134
|
const { fileName, ext, dir } = getFileInfo(filePath);
|
|
1136
1135
|
const name2 = formatFileName(config.fileName, fileName, albumId);
|
|
1137
1136
|
if (debug) logger.info(`文件名:${name2}.${ext}`);
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
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
|
+
}
|
|
1141
1147
|
if (!config.cache) (0, import_promises3.rm)(dir, { recursive: true });
|
|
1142
1148
|
} else {
|
|
1143
1149
|
let fileDir;
|
|
1144
1150
|
for (const [index, p] of filePath.entries()) {
|
|
1145
|
-
const buffer = await (0, import_promises3.readFile)(p);
|
|
1146
1151
|
const { fileName, ext, dir } = getFileInfo(p);
|
|
1147
1152
|
const name2 = formatFileName(
|
|
1148
1153
|
config.fileName,
|
|
@@ -1151,9 +1156,16 @@ async function apply(ctx, config) {
|
|
|
1151
1156
|
index + 1
|
|
1152
1157
|
);
|
|
1153
1158
|
if (debug) logger.info(`文件名:${name2}.${ext}`);
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
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
|
+
}
|
|
1157
1169
|
fileDir = dir;
|
|
1158
1170
|
}
|
|
1159
1171
|
if (!config.cache) (0, import_promises3.rm)(fileDir, { recursive: true });
|
|
@@ -1196,14 +1208,19 @@ async function apply(ctx, config) {
|
|
|
1196
1208
|
} else {
|
|
1197
1209
|
filePath = await jmClient.photoToPdf(photo, photoName);
|
|
1198
1210
|
}
|
|
1199
|
-
const buffer = await (0, import_promises3.readFile)(filePath);
|
|
1200
1211
|
const { fileName, ext, dir } = getFileInfo(filePath);
|
|
1201
1212
|
const name2 = formatFileName(config.fileName, fileName, photoId);
|
|
1202
|
-
if (debug) logger.info(`文件名:${filePath}`);
|
|
1203
1213
|
if (debug) logger.info(`文件名:${name2}.${ext}`);
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
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
|
+
}
|
|
1207
1224
|
if (!config.cache) (0, import_promises3.rm)(dir, { recursive: true });
|
|
1208
1225
|
} catch (error) {
|
|
1209
1226
|
if (error instanceof Error) {
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -16,6 +16,19 @@ 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
|
+
|
|
27
|
+
<details>
|
|
28
|
+
<summary>0.0.3</summary>
|
|
29
|
+
忘了给自动删除做判断
|
|
30
|
+
</details>
|
|
31
|
+
|
|
19
32
|
<details>
|
|
20
33
|
<summary>0.0.2</summary>
|
|
21
34
|
依赖从peerDependencies移动到dependencies
|