@wahaha216/koishi-plugin-jmcomic 0.0.4 → 0.0.6

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,3 @@
1
+ export declare class AlbumNotExistError extends Error {
2
+ constructor(message?: string);
3
+ }
@@ -0,0 +1,3 @@
1
+ export declare class PhotoNotExistError extends Error {
2
+ constructor(message?: string);
3
+ }
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: "发送方式", 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: "调试模式,输出更多信息" }] };
36
+ module2.exports = { commands: { jm: { description: "下载JM漫画,无需python!", examples: "jm album 本子数字ID\njm album info 本子数字ID\njm photo 本子章节数字ID", album: { examples: "jm album 数字ID", messages: { notExistError: "找不到该ID对应的本子", mysqlError: "已尝试所有备用地址,但是JM坏掉了" }, info: { examples: "jm album info 本子数字ID", messages: { notExistError: "找不到该ID对应的本子", mysqlError: "已尝试所有备用地址,但是JM坏掉了" } } }, photo: { examples: "jm photo 本子章节数字ID", messages: { notExistError: "找不到该ID对应的章节", mysqlError: "已尝试所有备用地址,但是JM坏掉了" } } } }, _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", 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" }] };
43
+ module2.exports = { commands: { jm: { description: "Download JM comics without python!", examples: "jm album albumID\njm album info albumID\njm photo photoID", album: { examples: "jm album albumID", messages: { notExistError: "albumID not found", mysqlError: "All alternate addresses have been tried. But no response." }, info: { examples: "jm album info albumID", messages: { notExistError: "albumID not found", mysqlError: "All alternate addresses have been tried. But no response." } } }, photo: { examples: "jm photo photoID", messages: { notExistError: "photoID not found", mysqlError: "All alternate addresses have been tried. But no response." } } } }, _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
 
@@ -702,6 +702,30 @@ __name(archiverImage, "archiverImage");
702
702
  var import_path2 = require("path");
703
703
  var import_sharp2 = __toESM(require("sharp"));
704
704
  var import_muhammara = require("muhammara");
705
+
706
+ // src/error/albumNotExist.error.ts
707
+ var AlbumNotExistError = class extends Error {
708
+ static {
709
+ __name(this, "AlbumNotExistError");
710
+ }
711
+ constructor(message) {
712
+ super(message);
713
+ this.name = "AlbumNotExistError";
714
+ }
715
+ };
716
+
717
+ // src/error/photoNotExist.error.ts
718
+ var PhotoNotExistError = class extends Error {
719
+ static {
720
+ __name(this, "PhotoNotExistError");
721
+ }
722
+ constructor(message) {
723
+ super(message);
724
+ this.name = "PhotoNotExistError";
725
+ }
726
+ };
727
+
728
+ // src/entity/JMAppClient.ts
705
729
  var JMAppClient = class _JMAppClient extends JMClientAbstract {
706
730
  static {
707
731
  __name(this, "JMAppClient");
@@ -748,6 +772,7 @@ var JMAppClient = class _JMAppClient extends JMClientAbstract {
748
772
  responseType: "json"
749
773
  });
750
774
  const album_json = this.decodeBase64(res.data, timestamp);
775
+ if (!album_json.name) throw new AlbumNotExistError();
751
776
  const album = JMAppAlbum.fromJson(album_json);
752
777
  const series = album.getSeries();
753
778
  const photos = [];
@@ -773,6 +798,7 @@ var JMAppClient = class _JMAppClient extends JMClientAbstract {
773
798
  responseType: "json"
774
799
  });
775
800
  const photo_json = this.decodeBase64(res.data, timestamp);
801
+ if (!photo_json.name) throw new PhotoNotExistError();
776
802
  const photo = JMAppPhoto.fromJson(photo_json);
777
803
  const images = photo.getImages();
778
804
  const image_ids = images.map((image) => image.split(".")[0]);
@@ -794,9 +820,11 @@ var JMAppClient = class _JMAppClient extends JMClientAbstract {
794
820
  let path = `${this.root}/${type}/${id}/origin`;
795
821
  if (debug) {
796
822
  logger.info(`开始下载: ${id}`);
797
- logger.info(`单章节: ${single ? "" : "否"}`);
798
- logger.info(`子章节: ${albumId ? "是" : "否"}`);
799
- logger.info(`本子ID:${albumId}`);
823
+ if (type === "album") {
824
+ logger.info(`单章节: ${single ? "是" : "否"}`);
825
+ logger.info(`子章节: ${albumId ? "是" : "否"}`);
826
+ logger.info(`本子ID: ${albumId}`);
827
+ }
800
828
  }
801
829
  if (type === "album") {
802
830
  if (single) {
@@ -1171,13 +1199,16 @@ async function apply(ctx, config) {
1171
1199
  if (!config.cache) (0, import_promises3.rm)(fileDir, { recursive: true });
1172
1200
  }
1173
1201
  } catch (error) {
1174
- if (error instanceof Error) {
1175
- if (error.message.includes("Could not connect to mysql")) {
1176
- await session.send([
1177
- import_koishi.h.quote(messageId),
1178
- import_koishi.h.text("已尝试所有可能,但是JM坏掉了")
1179
- ]);
1180
- }
1202
+ if (error instanceof AlbumNotExistError) {
1203
+ await session.send([
1204
+ import_koishi.h.quote(messageId),
1205
+ import_koishi.h.text(session.text(".notExistError"))
1206
+ ]);
1207
+ } else if (error instanceof MySqlError) {
1208
+ await session.send([
1209
+ import_koishi.h.quote(messageId),
1210
+ import_koishi.h.text(session.text(".mysqlError"))
1211
+ ]);
1181
1212
  } else {
1182
1213
  throw new Error(error);
1183
1214
  }
@@ -1223,13 +1254,16 @@ async function apply(ctx, config) {
1223
1254
  }
1224
1255
  if (!config.cache) (0, import_promises3.rm)(dir, { recursive: true });
1225
1256
  } catch (error) {
1226
- if (error instanceof Error) {
1227
- if (error.message.includes("Could not connect to mysql")) {
1228
- await session.send([
1229
- import_koishi.h.quote(messageId),
1230
- import_koishi.h.text("已尝试所有可能,但是JM坏掉了")
1231
- ]);
1232
- }
1257
+ if (error instanceof PhotoNotExistError) {
1258
+ await session.send([
1259
+ import_koishi.h.quote(messageId),
1260
+ import_koishi.h.text(session.text(".notExistError"))
1261
+ ]);
1262
+ } else if (error instanceof MySqlError) {
1263
+ await session.send([
1264
+ import_koishi.h.quote(messageId),
1265
+ import_koishi.h.text(session.text(".mysqlError"))
1266
+ ]);
1233
1267
  } else {
1234
1268
  throw new Error(error);
1235
1269
  }
@@ -1264,13 +1298,16 @@ async function apply(ctx, config) {
1264
1298
  import_koishi.h.text(`观看数:${album.getTotalViews()}`)
1265
1299
  ]);
1266
1300
  } catch (error) {
1267
- if (error instanceof Error) {
1268
- if (error.message.includes("Could not connect to mysql")) {
1269
- await session.send([
1270
- import_koishi.h.quote(messageId),
1271
- import_koishi.h.text("已尝试所有可能,但是JM坏掉了")
1272
- ]);
1273
- }
1301
+ if (error instanceof AlbumNotExistError) {
1302
+ await session.send([
1303
+ import_koishi.h.quote(messageId),
1304
+ import_koishi.h.text(session.text(".notExistError"))
1305
+ ]);
1306
+ } else if (error instanceof MySqlError) {
1307
+ await session.send([
1308
+ import_koishi.h.quote(messageId),
1309
+ import_koishi.h.text(session.text(".mysqlError"))
1310
+ ]);
1274
1311
  } else {
1275
1312
  throw new Error(error);
1276
1313
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@wahaha216/koishi-plugin-jmcomic",
3
3
  "description": "下载JM本子,无需python。支持pdf、zip加密。",
4
- "version": "0.0.4",
4
+ "version": "0.0.6",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [
package/readme.md CHANGED
@@ -16,6 +16,16 @@ jm photo xxxxxx
16
16
 
17
17
  ## 更新日志
18
18
 
19
+ <details>
20
+ <summary>0.0.6</summary>
21
+ 添加了一些错误提示
22
+ </details>
23
+
24
+ <details>
25
+ <summary>0.0.5</summary>
26
+ 修改使用示例
27
+ </details>
28
+
19
29
  <details>
20
30
  <summary>0.0.4</summary>
21
31
  1.文件名移除前后空格