koishi-plugin-githubsth 1.0.1-test8 → 1.0.1-test9

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.
@@ -23,8 +23,52 @@ class Notifier extends koishi_1.Service {
23
23
  this.ctx.on('github/workflow-run', (payload) => this.handleEvent('workflow_run', payload));
24
24
  this.ctx.on('github/issue_comment', (payload) => this.handleEvent('issue_comment', payload));
25
25
  this.ctx.on('github/issue-comment', (payload) => this.handleEvent('issue_comment', payload));
26
- this.ctx.on('github/pull_request_review', (payload) => this.handleEvent('pull_request_review', payload));
27
26
  this.ctx.on('github/pull-request-review', (payload) => this.handleEvent('pull_request_review', payload));
27
+ // Fallback: Listen to message-created for adapters that map webhooks to messages
28
+ this.ctx.on('message-created', (session) => {
29
+ if (session.platform !== 'github')
30
+ return;
31
+ // Try to find raw payload in session
32
+ // adapter-github might put it in session.content (parsed) or some extra field
33
+ // We'll try to find the raw JSON.
34
+ // Based on common adapter patterns, it might be in session.event._data or similar if it's a raw event wrapped
35
+ // But for message-created, session IS the event wrapper.
36
+ // Let's inspect the session for debugging first
37
+ if (this.config.debug) {
38
+ this.ctx.logger('githubsth').info(`[Debug] Message session keys: ${Object.keys(session).join(', ')}`);
39
+ }
40
+ // If we can't find the payload easily, we might need to rely on the adapter emitting proper events.
41
+ // But since we are here, let's try to see if 'payload' or 'extra' exists.
42
+ const payload = session.payload || session.extra || session.data;
43
+ if (payload) {
44
+ this.ctx.logger('githubsth').info('Found payload in session, attempting to handle');
45
+ // Infer event type
46
+ let eventType = 'unknown';
47
+ if (payload.issue && payload.comment)
48
+ eventType = 'issue_comment';
49
+ else if (payload.issue)
50
+ eventType = 'issues';
51
+ else if (payload.pull_request && payload.review)
52
+ eventType = 'pull_request_review';
53
+ else if (payload.pull_request)
54
+ eventType = 'pull_request';
55
+ else if (payload.commits)
56
+ eventType = 'push';
57
+ else if (payload.starred_at !== undefined || (payload.action === 'started'))
58
+ eventType = 'star'; // star event usually has action 'created' but check payload structure
59
+ else if (payload.forkee)
60
+ eventType = 'fork';
61
+ else if (payload.release)
62
+ eventType = 'release';
63
+ else if (payload.discussion)
64
+ eventType = 'discussion';
65
+ else if (payload.workflow_run)
66
+ eventType = 'workflow_run';
67
+ if (eventType !== 'unknown') {
68
+ this.handleEvent(eventType, payload);
69
+ }
70
+ }
71
+ });
28
72
  }
29
73
  async handleEvent(event, payload) {
30
74
  // FORCE LOG for debugging
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "koishi-plugin-githubsth",
3
- "version": "1.0.1-test8",
3
+ "version": "1.0.1-test9",
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",