koishi-plugin-githubsth 1.0.1-test2 → 1.0.1-test4

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
@@ -53,6 +53,7 @@ exports.inject = {
53
53
  };
54
54
  __exportStar(require("./config"), exports);
55
55
  function apply(ctx, config) {
56
+ console.log('[GithubSth] Plugin loading...');
56
57
  // 本地化
57
58
  ctx.i18n.define('zh-CN', zh_CN_1.default);
58
59
  // 数据库
@@ -64,10 +65,9 @@ function apply(ctx, config) {
64
65
  // admin and subscribe are already loaded in commands/index.ts, remove duplicate loading here
65
66
  try {
66
67
  ctx.plugin(commands, config);
67
- // 加载成功日志
68
- console.log('githubsth plugin loaded');
68
+ console.log('[GithubSth] Plugin loaded successfully');
69
69
  }
70
70
  catch (e) {
71
- console.error('githubsth plugin failed to load:', e);
71
+ console.error('[GithubSth] Plugin failed to load:', e);
72
72
  }
73
73
  }
@@ -1,7 +1,7 @@
1
1
  import { Context, Service, h } from 'koishi';
2
2
  declare module 'koishi' {
3
3
  interface Context {
4
- formatter: Formatter;
4
+ githubsthFormatter: Formatter;
5
5
  }
6
6
  }
7
7
  export declare class Formatter extends Service {
@@ -4,7 +4,7 @@ exports.Formatter = void 0;
4
4
  const koishi_1 = require("koishi");
5
5
  class Formatter extends koishi_1.Service {
6
6
  constructor(ctx) {
7
- super(ctx, 'formatter');
7
+ super(ctx, 'githubsthFormatter');
8
8
  }
9
9
  formatPush(payload) {
10
10
  const { repository, pusher, commits, compare } = payload;
@@ -2,7 +2,7 @@ import { Context, Service } from 'koishi';
2
2
  import { Config } from '../config';
3
3
  declare module 'koishi' {
4
4
  interface Context {
5
- notifier: Notifier;
5
+ githubsthNotifier: Notifier;
6
6
  }
7
7
  }
8
8
  export declare class Notifier extends Service {
@@ -5,7 +5,7 @@ const koishi_1 = require("koishi");
5
5
  class Notifier extends koishi_1.Service {
6
6
  // @ts-ignore
7
7
  constructor(ctx, config) {
8
- super(ctx, 'notifier', true);
8
+ super(ctx, 'githubsthNotifier', true);
9
9
  this.config = config;
10
10
  this.registerListeners();
11
11
  }
@@ -22,6 +22,8 @@ class Notifier extends koishi_1.Service {
22
22
  this.ctx.on('github/pull_request_review', (payload) => this.handleEvent('pull_request_review', payload));
23
23
  }
24
24
  async handleEvent(event, payload) {
25
+ // FORCE LOG for debugging
26
+ console.log(`[GithubSth] Received event: ${event}`);
25
27
  let repoName = payload.repository?.full_name;
26
28
  // Try to fallback if repoName is missing
27
29
  if (!repoName && payload.issue?.repository_url) {
@@ -34,11 +36,13 @@ class Notifier extends koishi_1.Service {
34
36
  repoName = payload.pull_request.base.repo.full_name;
35
37
  }
36
38
  if (!repoName) {
39
+ console.log(`[GithubSth] Missing repo info for event: ${event}`);
37
40
  if (this.config.debug) {
38
41
  this.ctx.logger('notifier').warn(`Event ${event} missing repository info. Keys: ${Object.keys(payload).join(', ')}`);
39
42
  }
40
43
  return;
41
44
  }
45
+ console.log(`[GithubSth] Processing event ${event} for ${repoName}`);
42
46
  if (this.config.debug) {
43
47
  this.ctx.logger('notifier').info(`Received event ${event} for ${repoName}`);
44
48
  this.ctx.logger('notifier').debug(JSON.stringify(payload, null, 2));
@@ -60,50 +64,52 @@ class Notifier extends koishi_1.Service {
60
64
  return true;
61
65
  });
62
66
  if (matchedRules.length === 0) {
67
+ console.log(`[GithubSth] No matching rules for ${repoName}`);
63
68
  if (this.config.debug) {
64
69
  this.ctx.logger('notifier').debug(`No matching rules for ${repoName} (event: ${event})`);
65
70
  }
66
71
  return;
67
72
  }
73
+ console.log(`[GithubSth] Found ${matchedRules.length} matching rules for ${repoName}`);
68
74
  if (this.config.debug) {
69
75
  this.ctx.logger('notifier').debug(`Found ${matchedRules.length} matching rules for ${repoName}`);
70
76
  }
71
77
  let message = null;
72
78
  // Ensure formatter is loaded
73
- if (!this.ctx.formatter) {
79
+ if (!this.ctx.githubsthFormatter) {
74
80
  this.ctx.logger('notifier').warn('Formatter service not available');
75
81
  return;
76
82
  }
77
83
  switch (event) {
78
84
  case 'push':
79
- message = this.ctx.formatter.formatPush(payload);
85
+ message = this.ctx.githubsthFormatter.formatPush(payload);
80
86
  break;
81
87
  case 'issues':
82
- message = this.ctx.formatter.formatIssue(payload);
88
+ message = this.ctx.githubsthFormatter.formatIssue(payload);
83
89
  break;
84
90
  case 'pull_request':
85
- message = this.ctx.formatter.formatPullRequest(payload);
91
+ message = this.ctx.githubsthFormatter.formatPullRequest(payload);
86
92
  break;
87
93
  case 'star':
88
- message = this.ctx.formatter.formatStar(payload);
94
+ message = this.ctx.githubsthFormatter.formatStar(payload);
89
95
  break;
90
96
  case 'fork':
91
- message = this.ctx.formatter.formatFork(payload);
97
+ message = this.ctx.githubsthFormatter.formatFork(payload);
92
98
  break;
93
99
  case 'release':
94
- message = this.ctx.formatter.formatRelease(payload);
100
+ message = this.ctx.githubsthFormatter.formatRelease(payload);
95
101
  break;
96
102
  case 'discussion':
97
- message = this.ctx.formatter.formatDiscussion(payload);
103
+ message = this.ctx.githubsthFormatter.formatDiscussion(payload);
98
104
  break;
99
105
  case 'workflow_run':
100
- message = this.ctx.formatter.formatWorkflowRun(payload);
106
+ message = this.ctx.githubsthFormatter.formatWorkflowRun(payload);
101
107
  break;
102
108
  case 'issue_comment':
103
- message = this.ctx.formatter.formatIssueComment(payload);
109
+ message = this.ctx.githubsthFormatter.formatIssueComment(payload);
104
110
  break;
105
111
  case 'pull_request_review':
106
- message = this.ctx.formatter.formatPullRequestReview(payload);
112
+ message = this.ctx.githubsthFormatter.formatPullRequestReview(payload);
107
113
  break;
108
114
  }
109
115
  if (!message) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "koishi-plugin-githubsth",
3
- "version": "1.0.1-test2",
3
+ "version": "1.0.1-test4",
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",