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('
|
|
71
|
+
console.error('[GithubSth] Plugin failed to load:', e);
|
|
72
72
|
}
|
|
73
73
|
}
|
|
@@ -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, '
|
|
7
|
+
super(ctx, 'githubsthFormatter');
|
|
8
8
|
}
|
|
9
9
|
formatPush(payload) {
|
|
10
10
|
const { repository, pusher, commits, compare } = payload;
|
package/lib/services/notifier.js
CHANGED
|
@@ -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, '
|
|
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.
|
|
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.
|
|
85
|
+
message = this.ctx.githubsthFormatter.formatPush(payload);
|
|
80
86
|
break;
|
|
81
87
|
case 'issues':
|
|
82
|
-
message = this.ctx.
|
|
88
|
+
message = this.ctx.githubsthFormatter.formatIssue(payload);
|
|
83
89
|
break;
|
|
84
90
|
case 'pull_request':
|
|
85
|
-
message = this.ctx.
|
|
91
|
+
message = this.ctx.githubsthFormatter.formatPullRequest(payload);
|
|
86
92
|
break;
|
|
87
93
|
case 'star':
|
|
88
|
-
message = this.ctx.
|
|
94
|
+
message = this.ctx.githubsthFormatter.formatStar(payload);
|
|
89
95
|
break;
|
|
90
96
|
case 'fork':
|
|
91
|
-
message = this.ctx.
|
|
97
|
+
message = this.ctx.githubsthFormatter.formatFork(payload);
|
|
92
98
|
break;
|
|
93
99
|
case 'release':
|
|
94
|
-
message = this.ctx.
|
|
100
|
+
message = this.ctx.githubsthFormatter.formatRelease(payload);
|
|
95
101
|
break;
|
|
96
102
|
case 'discussion':
|
|
97
|
-
message = this.ctx.
|
|
103
|
+
message = this.ctx.githubsthFormatter.formatDiscussion(payload);
|
|
98
104
|
break;
|
|
99
105
|
case 'workflow_run':
|
|
100
|
-
message = this.ctx.
|
|
106
|
+
message = this.ctx.githubsthFormatter.formatWorkflowRun(payload);
|
|
101
107
|
break;
|
|
102
108
|
case 'issue_comment':
|
|
103
|
-
message = this.ctx.
|
|
109
|
+
message = this.ctx.githubsthFormatter.formatIssueComment(payload);
|
|
104
110
|
break;
|
|
105
111
|
case 'pull_request_review':
|
|
106
|
-
message = this.ctx.
|
|
112
|
+
message = this.ctx.githubsthFormatter.formatPullRequestReview(payload);
|
|
107
113
|
break;
|
|
108
114
|
}
|
|
109
115
|
if (!message) {
|
package/package.json
CHANGED