kotori-plugin-github 1.3.0 → 1.3.1

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.js CHANGED
@@ -1,14 +1,12 @@
1
-
2
1
  /**
3
- * @Package kotori-plugin-github
4
- * @Version 1.3.0
5
- * @Author Hotaru <me@hotaru.icu>
6
- * @Copyright 2024 Hotaru. All rights reserved.
7
- * @License GPL-3.0
8
- * @Link https://github.com/kotorijs/kotori
9
- * @Date 2024/8/8 20:54:08
10
- */
11
-
2
+ * @Package kotori-plugin-github
3
+ * @Version 1.3.1
4
+ * @Author Hotaru <me@hotaru.icu>
5
+ * @Copyright 2024-2025 Hotaru. All rights reserved.
6
+ * @License GPL-3.0
7
+ * @Link https://github.com/kotorijs/kotori
8
+ * @Date 2026/2/14 15:32:16
9
+ */
12
10
  "use strict";
13
11
  var __defProp = Object.defineProperty;
14
12
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -27,53 +25,51 @@ var __copyProps = (to, from, except, desc) => {
27
25
  return to;
28
26
  };
29
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
- var src_exports = {};
31
- __export(src_exports, {
28
+ var index_exports = {};
29
+ __export(index_exports, {
32
30
  lang: () => lang,
33
31
  main: () => main
34
32
  });
35
- module.exports = __toCommonJS(src_exports);
36
- var import_kotori_bot = require("kotori-bot");
33
+ module.exports = __toCommonJS(index_exports);
37
34
  var import_node_url = require("node:url");
35
+ var import_kotori_bot = require("kotori-bot");
38
36
  const HEAD_URL = "https://opengraph.githubassets.com/c9f4179f4d560950b2355c82aa2b7750bffd945744f9b8ea3f93cc24779745a0";
39
- const githubSchema = import_kotori_bot.Tsu.Union(
40
- import_kotori_bot.Tsu.Object({
41
- full_name: import_kotori_bot.Tsu.String(),
42
- description: import_kotori_bot.Tsu.String().default("corei18n.template.empty"),
43
- language: import_kotori_bot.Tsu.String().default("corei18n.template.empty"),
44
- owner: import_kotori_bot.Tsu.Object({ login: import_kotori_bot.Tsu.String().default("corei18n.template.empty") }).default({
45
- login: "corei18n.template.empty"
46
- }),
47
- created_at: import_kotori_bot.Tsu.String(),
48
- updated_at: import_kotori_bot.Tsu.String(),
49
- pushed_at: import_kotori_bot.Tsu.String(),
50
- license: import_kotori_bot.Tsu.Object({ name: import_kotori_bot.Tsu.String().default("corei18n.template.empty") }).default({
51
- name: "corei18n.template.empty"
52
- })
37
+ const githubSchema = import_kotori_bot.Tsu.Object({
38
+ full_name: import_kotori_bot.Tsu.String(),
39
+ description: import_kotori_bot.Tsu.String().default("corei18n.template.empty"),
40
+ language: import_kotori_bot.Tsu.String().default("corei18n.template.empty"),
41
+ owner: import_kotori_bot.Tsu.Object({ login: import_kotori_bot.Tsu.String().default("corei18n.template.empty") }).default({
42
+ login: "corei18n.template.empty"
53
43
  }),
54
- import_kotori_bot.Tsu.Object({})
55
- );
44
+ created_at: import_kotori_bot.Tsu.String(),
45
+ updated_at: import_kotori_bot.Tsu.String(),
46
+ pushed_at: import_kotori_bot.Tsu.String(),
47
+ license: import_kotori_bot.Tsu.Object({ name: import_kotori_bot.Tsu.String().default("corei18n.template.empty") }).default({
48
+ name: "corei18n.template.empty"
49
+ })
50
+ });
56
51
  const lang = [__dirname, "../locales"];
57
52
  function main(ctx) {
58
53
  ctx.command("github <content> - github.descr.github").action(async ({ args: [content] }, session) => {
59
54
  if (content.split("/").length === 2) {
60
- const res = githubSchema.parse(await ctx.http.get(`https://api.github.com/repos/${content}`));
61
- if (!("full_name" in res)) {
55
+ try {
56
+ const res = githubSchema.parse(await ctx.http.get(`https://api.github.com/repos/${content}`));
57
+ session.quick([
58
+ "github.msg.github",
59
+ {
60
+ name: res.full_name,
61
+ description: res.description,
62
+ language: res.language,
63
+ author: res.owner?.login,
64
+ create: res.created_at,
65
+ update: res.updated_at,
66
+ push: res.pushed_at,
67
+ license: res.license ? res.license.name : "BOT_RESULT.EMPTY"
68
+ }
69
+ ]);
70
+ } catch {
62
71
  return session.format("github.msg.github.fail", { input: content });
63
72
  }
64
- session.quick([
65
- "github.msg.github",
66
- {
67
- name: res.full_name,
68
- description: res.description,
69
- language: res.language,
70
- author: res.owner?.login,
71
- create: res.created_at,
72
- update: res.updated_at,
73
- push: res.pushed_at,
74
- license: res.license ? res.license.name : "BOT_RESULT.EMPTY"
75
- }
76
- ]);
77
73
  }
78
74
  return import_kotori_bot.Messages.image(`${HEAD_URL}/${content}`);
79
75
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kotori-plugin-github",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "description": "github repository searching",
5
5
  "main": "lib/index.js",
6
6
  "keywords": [
@@ -17,7 +17,7 @@
17
17
  ],
18
18
  "author": "Hotaru <me@hotaru.icu>",
19
19
  "peerDependencies": {
20
- "kotori-bot": "^1.6.0-rc.1"
20
+ "kotori-bot": "^1.7.3"
21
21
  },
22
22
  "kotori": {
23
23
  "meta": {