claude-notification-plugin 1.0.22 → 1.0.24
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/bin/install.js +46 -30
- package/notifier/notifier.js +11 -2
- package/package.json +2 -3
package/bin/install.js
CHANGED
|
@@ -80,30 +80,55 @@ async function main () {
|
|
|
80
80
|
console.log('==================================');
|
|
81
81
|
console.log('');
|
|
82
82
|
|
|
83
|
-
//
|
|
84
|
-
let
|
|
85
|
-
|
|
83
|
+
// Load existing config
|
|
84
|
+
let existing = {};
|
|
85
|
+
if (fs.existsSync(configPath)) {
|
|
86
|
+
try {
|
|
87
|
+
existing = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
|
|
88
|
+
} catch {
|
|
89
|
+
// ignore malformed config
|
|
90
|
+
}
|
|
91
|
+
}
|
|
86
92
|
|
|
87
|
-
const
|
|
93
|
+
const existingToken = existing.telegram?.token || '';
|
|
94
|
+
const existingChatId = existing.telegram?.chatId || '';
|
|
88
95
|
|
|
89
|
-
|
|
90
|
-
|
|
96
|
+
// Telegram setup
|
|
97
|
+
let token = existingToken;
|
|
98
|
+
let chatId = existingChatId;
|
|
99
|
+
|
|
100
|
+
if (existingToken) {
|
|
101
|
+
const masked = existingToken.slice(0, 6) + '...' + existingToken.slice(-4);
|
|
102
|
+
console.log(`Telegram token found: ${masked}`);
|
|
103
|
+
const reuse = await ask(rl, 'Keep existing token? (Y/n): ');
|
|
104
|
+
if (reuse.toLowerCase() === 'n') {
|
|
105
|
+
token = await ask(rl, 'New Bot Token: ');
|
|
106
|
+
chatId = ''; // reset chatId when token changes
|
|
107
|
+
}
|
|
108
|
+
} else {
|
|
109
|
+
const useTelegram = await ask(rl, 'Configure Telegram? (y/N): ');
|
|
110
|
+
if (useTelegram.toLowerCase() === 'y') {
|
|
111
|
+
token = await ask(rl, 'Bot Token: ');
|
|
112
|
+
}
|
|
113
|
+
}
|
|
91
114
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
115
|
+
// Fetch chatId if we have a token but no chatId
|
|
116
|
+
if (token && !chatId) {
|
|
117
|
+
console.log('');
|
|
118
|
+
console.log('Send any message to your bot in Telegram, then press Enter.');
|
|
119
|
+
await ask(rl, '');
|
|
96
120
|
|
|
97
|
-
|
|
98
|
-
|
|
121
|
+
console.log('Fetching Chat ID...');
|
|
122
|
+
chatId = await fetchChatId(token);
|
|
99
123
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
124
|
+
if (chatId) {
|
|
125
|
+
console.log('Chat ID detected: ' + chatId);
|
|
126
|
+
} else {
|
|
127
|
+
console.log('Could not detect Chat ID automatically.');
|
|
128
|
+
chatId = await ask(rl, 'Enter Chat ID manually: ');
|
|
106
129
|
}
|
|
130
|
+
} else if (token && chatId) {
|
|
131
|
+
console.log(`Chat ID: ${chatId}`);
|
|
107
132
|
}
|
|
108
133
|
|
|
109
134
|
rl.close();
|
|
@@ -133,16 +158,7 @@ async function main () {
|
|
|
133
158
|
debug: false,
|
|
134
159
|
};
|
|
135
160
|
|
|
136
|
-
//
|
|
137
|
-
let existing = {};
|
|
138
|
-
if (fs.existsSync(configPath)) {
|
|
139
|
-
try {
|
|
140
|
-
existing = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
|
|
141
|
-
} catch {
|
|
142
|
-
// ignore malformed config
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
161
|
+
// Merge defaults with existing config (user values take priority)
|
|
146
162
|
const config = { ...defaults, ...existing };
|
|
147
163
|
// Deep-merge nested objects
|
|
148
164
|
for (const key of Object.keys(defaults)) {
|
|
@@ -191,10 +207,10 @@ async function main () {
|
|
|
191
207
|
console.log('');
|
|
192
208
|
console.log('Config: ' + configPath);
|
|
193
209
|
|
|
194
|
-
if (token) {
|
|
210
|
+
if (config.telegram.token && config.telegram.chatId) {
|
|
195
211
|
console.log('Telegram: configured');
|
|
196
212
|
} else {
|
|
197
|
-
console.log('Telegram:
|
|
213
|
+
console.log('Telegram: not configured (edit config later)');
|
|
198
214
|
}
|
|
199
215
|
|
|
200
216
|
console.log('');
|
package/notifier/notifier.js
CHANGED
|
@@ -6,7 +6,7 @@ import path from 'path';
|
|
|
6
6
|
import process from 'process';
|
|
7
7
|
import notifier from 'node-notifier';
|
|
8
8
|
import player from 'play-sound';
|
|
9
|
-
import
|
|
9
|
+
import { spawn } from 'child_process';
|
|
10
10
|
|
|
11
11
|
const audio = player({});
|
|
12
12
|
|
|
@@ -251,7 +251,16 @@ function speakResult (config, duration) {
|
|
|
251
251
|
return;
|
|
252
252
|
}
|
|
253
253
|
try {
|
|
254
|
-
|
|
254
|
+
const text = getVoicePhrase(duration);
|
|
255
|
+
const psCommand = [
|
|
256
|
+
'Add-Type -AssemblyName System.Speech;',
|
|
257
|
+
'$s = New-Object System.Speech.Synthesis.SpeechSynthesizer;',
|
|
258
|
+
`$s.Speak("${text.replace(/"/g, '`"')}");`,
|
|
259
|
+
].join('');
|
|
260
|
+
spawn('powershell', ['-Command', psCommand], {
|
|
261
|
+
stdio: 'ignore',
|
|
262
|
+
windowsHide: true,
|
|
263
|
+
});
|
|
255
264
|
} catch {
|
|
256
265
|
// silent fail
|
|
257
266
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-notification-plugin",
|
|
3
3
|
"productName": "claude-notification-plugin",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.24",
|
|
5
5
|
"description": "Telegram and Windows notifications for Claude Code task completion",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"engines": {
|
|
@@ -44,8 +44,7 @@
|
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"node-notifier": "^10.0.1",
|
|
47
|
-
"play-sound": "^1.1.6"
|
|
48
|
-
"say": "^0.16.0"
|
|
47
|
+
"play-sound": "^1.1.6"
|
|
49
48
|
},
|
|
50
49
|
"devDependencies": {
|
|
51
50
|
"eslint-plugin-import": "^2.31.0"
|