koishi-plugin-githubsth 1.0.5 → 1.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.
@@ -5,12 +5,12 @@ function apply(ctx) {
5
5
  const logger = ctx.logger('githubsth');
6
6
  const repoRegex = /^[\w-]+\/[\w-.]+$/;
7
7
  ctx.command('githubsth.trust', '管理信任仓库', { authority: 3 }).alias('gh.trust');
8
- ctx.command('githubsth.trust.add <repo>', '添加信任仓库')
8
+ ctx.command('githubsth.trust.add <repo>', '添加信任仓库', { authority: 3 })
9
9
  .action(async ({ session }, repo) => {
10
10
  if (!repo)
11
- return '请指定仓库名称(owner/repo)。';
11
+ return '请指定仓库(owner/repo)。';
12
12
  if (!repoRegex.test(repo))
13
- return '仓库名称格式不正确(应为 owner/repo)。';
13
+ return '仓库格式错误,应为 owner/repo';
14
14
  try {
15
15
  logger.debug(`Adding trusted repo: ${repo}`);
16
16
  const existing = await ctx.database.get('github_trusted_repo', { repo });
@@ -22,43 +22,47 @@ function apply(ctx) {
22
22
  addedBy: session?.userId || 'unknown',
23
23
  addedAt: new Date(),
24
24
  });
25
- return `已添加信任仓库: ${repo}`;
25
+ return `已添加信任仓库:${repo}`;
26
26
  }
27
27
  catch (e) {
28
28
  logger.warn('Failed to add trusted repo:', e);
29
29
  if (e.code === 'SQLITE_CONSTRAINT')
30
30
  return '该仓库已在信任列表中。';
31
- return `添加失败: ${e.message}`;
31
+ return `添加失败:${e.message}`;
32
32
  }
33
33
  });
34
- ctx.command('githubsth.trust.remove <repo>', '移除信任仓库')
34
+ ctx.command('githubsth.trust.remove <repo>', '移除信任仓库', { authority: 3 })
35
35
  .action(async (_, repo) => {
36
36
  if (!repo)
37
- return '请指定仓库名称(owner/repo)。';
37
+ return '请指定仓库(owner/repo)。';
38
38
  const result = await ctx.database.remove('github_trusted_repo', { repo });
39
39
  if (result.matched === 0)
40
40
  return '未找到该信任仓库。';
41
- return `已移除信任仓库: ${repo}`;
41
+ return `已移除信任仓库:${repo}`;
42
42
  });
43
- ctx.command('githubsth.trust.list', '列出所有信任仓库')
43
+ ctx.command('githubsth.trust.list', '列出所有信任仓库', { authority: 3 })
44
44
  .action(async () => {
45
45
  const repos = await ctx.database.get('github_trusted_repo', {});
46
46
  if (repos.length === 0)
47
47
  return '暂无信任仓库。';
48
48
  return repos.map((r) => `${r.repo} [${r.enabled ? '启用' : '禁用'}]`).join('\n');
49
49
  });
50
- ctx.command('githubsth.trust.enable <repo>', '启用信任仓库')
50
+ ctx.command('githubsth.trust.enable <repo>', '启用信任仓库', { authority: 3 })
51
51
  .action(async (_, repo) => {
52
+ if (!repo)
53
+ return '请指定仓库(owner/repo)。';
52
54
  const result = await ctx.database.set('github_trusted_repo', { repo }, { enabled: true });
53
55
  if (result.matched === 0)
54
56
  return '未找到该信任仓库。';
55
- return `已启用信任仓库: ${repo}`;
57
+ return `已启用信任仓库:${repo}`;
56
58
  });
57
- ctx.command('githubsth.trust.disable <repo>', '禁用信任仓库')
59
+ ctx.command('githubsth.trust.disable <repo>', '禁用信任仓库', { authority: 3 })
58
60
  .action(async (_, repo) => {
61
+ if (!repo)
62
+ return '请指定仓库(owner/repo)。';
59
63
  const result = await ctx.database.set('github_trusted_repo', { repo }, { enabled: false });
60
64
  if (result.matched === 0)
61
65
  return '未找到该信任仓库。';
62
- return `已禁用信任仓库: ${repo}`;
66
+ return `已禁用信任仓库:${repo}`;
63
67
  });
64
68
  }
@@ -188,8 +188,8 @@ function apply(ctx, config) {
188
188
  return subs
189
189
  .map((sub) => session?.text('commands.githubsth.render.messages.repo_style_item', [
190
190
  sub.repo,
191
- sub.renderTheme || '(default)',
192
- sub.renderStyle || '(default)',
191
+ sub.renderTheme || '默认',
192
+ sub.renderStyle || '默认',
193
193
  ]) || `${sub.repo}`)
194
194
  .join('\n');
195
195
  });
@@ -13,9 +13,9 @@ function apply(ctx, config) {
13
13
  ctx.command('githubsth.subscribe <repo> [events:text]', '订阅 GitHub 仓库事件')
14
14
  .alias('gh.sub')
15
15
  .usage(`
16
- Subscribe GitHub repository notifications. If events are omitted, default events are used: ${defaultConfigEvents.join(', ')}
16
+ 订阅 GitHub 仓库通知。若省略 events,将使用默认事件:${defaultConfigEvents.join(', ')}
17
17
 
18
- Examples:
18
+ 示例:
19
19
  - gh.sub koishijs/koishi
20
20
  - gh.sub koishijs/koishi push,issues,star
21
21
  `)
@@ -31,7 +31,7 @@ Examples:
31
31
  return session?.text('commands.githubsth.subscribe.messages.repo_not_trusted');
32
32
  let events;
33
33
  if (eventsStr) {
34
- events = eventsStr.split(/[,,\s]+/).map((e) => e.trim()).filter(Boolean).map((e) => e.replace(/-/g, '_'));
34
+ events = eventsStr.split(/[,\s]+/).map((e) => e.trim()).filter(Boolean).map((e) => e.replace(/-/g, '_'));
35
35
  const invalidEvents = events.filter((e) => !validEvents.includes(e) && e !== '*');
36
36
  if (invalidEvents.length) {
37
37
  return session?.text('commands.githubsth.subscribe.messages.invalid_events', [invalidEvents.join(', '), validEvents.join(', ')]);
@@ -94,8 +94,8 @@ Examples:
94
94
  .map((sub) => session?.text('commands.githubsth.list.messages.item', [
95
95
  sub.repo,
96
96
  sub.events.join(', '),
97
- sub.renderTheme || '(default)',
98
- sub.renderStyle || '(default)',
97
+ sub.renderTheme || '默认',
98
+ sub.renderStyle || '默认',
99
99
  ]) || `${sub.repo} [${sub.events.join(', ')}]`)
100
100
  .join('\n');
101
101
  });
package/lib/config.js CHANGED
@@ -3,56 +3,56 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Config = void 0;
4
4
  const koishi_1 = require("koishi");
5
5
  const renderThemeSchema = koishi_1.Schema.union([
6
- koishi_1.Schema.const('github-light').description('GitHub Light'),
7
- koishi_1.Schema.const('github-dark').description('GitHub Dark'),
8
- koishi_1.Schema.const('aurora').description('Aurora'),
9
- koishi_1.Schema.const('sunset').description('Sunset'),
10
- koishi_1.Schema.const('matrix').description('Matrix'),
11
- koishi_1.Schema.const('compact').description('Compact (legacy)'),
12
- koishi_1.Schema.const('card').description('Card (legacy)'),
13
- koishi_1.Schema.const('terminal').description('Terminal (legacy)'),
6
+ koishi_1.Schema.const('github-light').description('GitHub 亮色'),
7
+ koishi_1.Schema.const('github-dark').description('GitHub 暗色'),
8
+ koishi_1.Schema.const('aurora').description('极光主题'),
9
+ koishi_1.Schema.const('sunset').description('落日主题'),
10
+ koishi_1.Schema.const('matrix').description('矩阵主题'),
11
+ koishi_1.Schema.const('compact').description('紧凑主题(兼容)'),
12
+ koishi_1.Schema.const('card').description('卡片主题(兼容)'),
13
+ koishi_1.Schema.const('terminal').description('终端主题(兼容)'),
14
14
  ]);
15
15
  const renderStyleSchema = koishi_1.Schema.union([
16
- koishi_1.Schema.const('auto').description('Follow theme default style'),
17
- koishi_1.Schema.const('github').description('GitHub style'),
18
- koishi_1.Schema.const('glass').description('Glass style'),
19
- koishi_1.Schema.const('neon').description('Neon style'),
20
- koishi_1.Schema.const('compact').description('Compact style'),
21
- koishi_1.Schema.const('card').description('Card style'),
22
- koishi_1.Schema.const('terminal').description('Terminal style'),
16
+ koishi_1.Schema.const('auto').description('跟随主题默认排版'),
17
+ koishi_1.Schema.const('github').description('GitHub 排版'),
18
+ koishi_1.Schema.const('glass').description('玻璃排版'),
19
+ koishi_1.Schema.const('neon').description('霓虹排版'),
20
+ koishi_1.Schema.const('compact').description('紧凑排版'),
21
+ koishi_1.Schema.const('card').description('卡片排版'),
22
+ koishi_1.Schema.const('terminal').description('终端排版'),
23
23
  ]);
24
24
  exports.Config = koishi_1.Schema.object({
25
- defaultOwner: koishi_1.Schema.string().description('Default repository owner.'),
26
- defaultRepo: koishi_1.Schema.string().description('Default repository name.'),
27
- debug: koishi_1.Schema.boolean().default(false).description('Enable debug logs.'),
28
- logUnhandledEvents: koishi_1.Schema.boolean().default(false).description('Log unhandled webhook events.'),
29
- enableSessionFallback: koishi_1.Schema.boolean().default(true).description('Enable message-created fallback parser.'),
30
- dedupRetentionHours: koishi_1.Schema.number().min(1).max(720).default(72).description('Dedup record retention in hours.'),
31
- sendRetryCount: koishi_1.Schema.number().min(0).max(10).default(2).description('Retry count for sending message.'),
32
- sendRetryBaseDelayMs: koishi_1.Schema.number().min(100).max(30000).default(800).description('Base retry delay in ms.'),
25
+ defaultOwner: koishi_1.Schema.string().description('默认仓库拥有者。'),
26
+ defaultRepo: koishi_1.Schema.string().description('默认仓库名称。'),
27
+ debug: koishi_1.Schema.boolean().default(false).description('启用调试日志。'),
28
+ logUnhandledEvents: koishi_1.Schema.boolean().default(false).description('记录未处理的 Webhook 事件。'),
29
+ enableSessionFallback: koishi_1.Schema.boolean().default(true).description('启用消息会话兜底解析。'),
30
+ dedupRetentionHours: koishi_1.Schema.number().min(1).max(720).default(72).description('幂等去重记录保留时长(小时)。'),
31
+ sendRetryCount: koishi_1.Schema.number().min(0).max(10).default(2).description('发送失败重试次数。'),
32
+ sendRetryBaseDelayMs: koishi_1.Schema.number().min(100).max(30000).default(800).description('重试基准退避间隔(毫秒)。'),
33
33
  formatterLocale: koishi_1.Schema.union([
34
- koishi_1.Schema.const('zh-CN').description('Chinese'),
35
- koishi_1.Schema.const('en-US').description('English'),
36
- ]).default('zh-CN').description('Formatter locale.'),
34
+ koishi_1.Schema.const('zh-CN').description('中文'),
35
+ koishi_1.Schema.const('en-US').description('英文'),
36
+ ]).default('zh-CN').description('通知文案语言。'),
37
37
  renderMode: koishi_1.Schema.union([
38
- koishi_1.Schema.const('auto').description('Prefer image, fallback by policy'),
39
- koishi_1.Schema.const('image').description('Image only'),
40
- koishi_1.Schema.const('text').description('Text only'),
41
- ]).default('auto').description('Render mode.'),
38
+ koishi_1.Schema.const('auto').description('优先图片,失败按策略回退'),
39
+ koishi_1.Schema.const('image').description('仅图片'),
40
+ koishi_1.Schema.const('text').description('仅文本'),
41
+ ]).default('auto').description('渲染模式。'),
42
42
  renderFallback: koishi_1.Schema.union([
43
- koishi_1.Schema.const('text').description('Fallback to text when image fails'),
44
- koishi_1.Schema.const('drop').description('Drop message when image fails'),
45
- ]).default('text').description('Fallback policy for image render failure.'),
46
- renderTheme: renderThemeSchema.default('github-dark').description('Default render theme.'),
47
- renderStyle: renderStyleSchema.default('auto').description('Default render style.'),
48
- renderWidth: koishi_1.Schema.number().min(480).max(1600).default(860).description('Image width in px.'),
49
- renderTimeoutMs: koishi_1.Schema.number().min(1000).max(60000).default(12000).description('Image render timeout in ms.'),
50
- digestEnabled: koishi_1.Schema.boolean().default(false).description('Enable digest mode for batched notifications.'),
51
- digestWindowSec: koishi_1.Schema.number().min(5).max(3600).default(60).description('Digest window in seconds.'),
52
- digestMaxItems: koishi_1.Schema.number().min(2).max(100).default(12).description('Max events per digest message.'),
43
+ koishi_1.Schema.const('text').description('图片失败时回退文本'),
44
+ koishi_1.Schema.const('drop').description('图片失败时丢弃本条消息'),
45
+ ]).default('text').description('图片渲染失败回退策略。'),
46
+ renderTheme: renderThemeSchema.default('github-dark').description('默认主题。'),
47
+ renderStyle: renderStyleSchema.default('auto').description('默认排版样式。'),
48
+ renderWidth: koishi_1.Schema.number().min(480).max(1600).default(860).description('图片宽度(像素)。'),
49
+ renderTimeoutMs: koishi_1.Schema.number().min(1000).max(60000).default(12000).description('图片渲染超时(毫秒)。'),
50
+ digestEnabled: koishi_1.Schema.boolean().default(false).description('启用 Digest 聚合推送。'),
51
+ digestWindowSec: koishi_1.Schema.number().min(5).max(3600).default(60).description('Digest 聚合窗口(秒)。'),
52
+ digestMaxItems: koishi_1.Schema.number().min(2).max(100).default(12).description('每条 Digest 最大事件数。'),
53
53
  defaultEvents: koishi_1.Schema.array(koishi_1.Schema.string())
54
54
  .default(['push', 'issues', 'issue_comment', 'pull_request', 'pull_request_review', 'release', 'star', 'fork'])
55
- .description('Default events used by subscribe command.'),
55
+ .description('订阅命令默认事件列表。'),
56
56
  rules: koishi_1.Schema.array(koishi_1.Schema.object({
57
57
  repo: koishi_1.Schema.string().required(),
58
58
  channelId: koishi_1.Schema.string().required(),
@@ -60,5 +60,5 @@ exports.Config = koishi_1.Schema.object({
60
60
  events: koishi_1.Schema.array(koishi_1.Schema.string()).default(['push', 'issues', 'pull_request', 'issue_comment', 'pull_request_review']),
61
61
  renderTheme: renderThemeSchema,
62
62
  renderStyle: renderStyleSchema,
63
- })).hidden().description('Deprecated compatibility field, use db subscriptions.'),
63
+ })).hidden().description('已弃用兼容字段,请使用数据库订阅。'),
64
64
  });
@@ -3,35 +3,35 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = {
4
4
  commands: {
5
5
  githubsth: {
6
- description: 'GitHub 订阅通知插件',
6
+ description: 'GitHub 订阅通知',
7
7
  },
8
8
  'githubsth.repo': {
9
9
  description: '获取仓库信息',
10
10
  messages: {
11
- repo_info: '仓库: {0}/{1}\n描述: {2}\nStars: {3}',
12
- error: '获取仓库信息失败: {0}',
13
- specify_repo: '请指定仓库名称(owner/repo)。',
14
- not_found: '未找到仓库或无权限访问。',
11
+ repo_info: '仓库:{0}/{1}\n描述:{2}\nStars{3}',
12
+ error: '获取仓库信息失败:{0}',
13
+ specify_repo: '请指定仓库,格式为 owner/repo',
14
+ not_found: '仓库不存在或无权限访问。',
15
15
  },
16
16
  },
17
17
  'githubsth.subscribe': {
18
18
  description: '订阅 GitHub 仓库事件',
19
19
  messages: {
20
- specify_repo: '请指定仓库(owner/repo)。',
20
+ specify_repo: '请指定仓库,格式为 owner/repo',
21
21
  invalid_repo: '仓库格式错误,应为 owner/repo。',
22
- run_in_channel: '请在群聊/频道中执行该命令。',
22
+ run_in_channel: '请在群聊或频道中执行该命令。',
23
23
  repo_not_trusted: '该仓库不在信任列表中,请先由管理员添加。',
24
24
  invalid_events: '无效事件:{0}\n可选事件:{1}',
25
25
  updated: '已更新订阅:{0}\n事件:{1}',
26
- created: '已订阅 {0}\n事件:{1}',
26
+ created: '已订阅:{0}\n事件:{1}',
27
27
  failed: '订阅失败,请稍后重试。',
28
28
  },
29
29
  },
30
30
  'githubsth.unsubscribe': {
31
31
  description: '取消订阅 GitHub 仓库',
32
32
  messages: {
33
- specify_repo: '请指定仓库(owner/repo)。',
34
- run_in_channel: '请在群聊/频道中执行该命令。',
33
+ specify_repo: '请指定仓库,格式为 owner/repo',
34
+ run_in_channel: '请在群聊或频道中执行该命令。',
35
35
  not_found: '未找到该订阅。',
36
36
  success: '已取消订阅:{0}',
37
37
  },
@@ -39,19 +39,19 @@ exports.default = {
39
39
  'githubsth.list': {
40
40
  description: '查看当前频道订阅',
41
41
  messages: {
42
- run_in_channel: '请在群聊/频道中执行该命令。',
42
+ run_in_channel: '请在群聊或频道中执行该命令。',
43
43
  empty: '当前频道没有订阅。',
44
- item: '{0} [{1}] theme={2} style={3}',
44
+ item: '{0} [{1}] 主题={2} 样式={3}',
45
45
  },
46
46
  },
47
47
  'githubsth.render': {
48
48
  description: '渲染设置',
49
49
  messages: {
50
50
  invalid_mode: '无效模式。可选:{0}',
51
- mode_set: '运行时渲染模式已设置为 {0}(配置默认值 {1})。',
52
- invalid_theme: '无效主题。请先执行 githubsth.render.themes',
51
+ mode_set: '运行时渲染模式已设为 {0}(配置默认:{1})。',
52
+ invalid_theme: '无效主题,请先执行 githubsth.render.themes 查看列表。',
53
53
  theme_set: '默认主题已设置为:{0}',
54
- invalid_style: '无效样式。请先执行 githubsth.render.styles',
54
+ invalid_style: '无效样式,请先执行 githubsth.render.styles 查看列表。',
55
55
  style_set: '默认样式已设置为:{0}',
56
56
  invalid_width: '请提供有效的宽度数字。',
57
57
  width_set: '图片宽度已设置为 {0}px',
@@ -61,13 +61,13 @@ exports.default = {
61
61
  digest_window_set: 'Digest 窗口已设置为 {0}s',
62
62
  invalid_count: '请提供有效的数量。',
63
63
  digest_max_set: 'Digest 最大条目已设置为 {0}',
64
- themes_list: '主题列表:\n- {0}',
65
- styles_list: '样式列表:\n- {0}',
66
- status_text: 'mode: {0} (configured: {1})\nfallback: {2}\ntheme(default): {3}\nstyle(default): {4}\nwidth: {5}\ntimeout: {6}ms\ndigest: {7} ({8}s, max {9})\npuppeteer: {10}',
64
+ themes_list: '主题列表:\n- {0}',
65
+ styles_list: '样式列表:\n- {0}',
66
+ status_text: '当前模式:{0}(配置默认:{1})\n回退策略:{2}\n默认主题:{3}\n默认样式:{4}\n图片宽度:{5}\n渲染超时:{6}ms\nDigest:{7}(窗口 {8}s,最多 {9} 条)\nPuppeteer:{10}',
67
67
  unknown_event: '未知事件 {0},已回退到 issue_comment。',
68
68
  unknown_theme: '未知主题 {0},已回退到默认主题。',
69
69
  unknown_style: '未知样式 {0},已回退到默认样式。',
70
- preview_failed: '预览失败,请检查 puppeteer 或渲染设置。',
70
+ preview_failed: '预览失败,请检查 puppeteer 或渲染配置。',
71
71
  repo_required: '请提供仓库(owner/repo)。',
72
72
  no_sub_in_channel: '当前频道没有该仓库订阅。',
73
73
  repo_theme_set: '订阅主题已设置:{0} -> {1}',
@@ -75,7 +75,7 @@ exports.default = {
75
75
  repo_style_set: '订阅样式已设置:{0} -> {1}',
76
76
  repo_style_cleared: '订阅样式已清除:{0}',
77
77
  no_matched_subs: '没有匹配的订阅。',
78
- repo_style_item: '{0} => theme={1} style={2}',
78
+ repo_style_item: '{0} => 主题={1} 样式={2}',
79
79
  },
80
80
  },
81
81
  'githubsth.trust': {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "koishi-plugin-githubsth",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "Github Subscriptions Notifications, push notifications for GitHub subscriptions For koishi",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",