thinkncollab-shell 0.0.9 → 0.0.10
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/package.json +1 -1
- package/src/commands/message/say.js +21 -15
- package/src/core/shell.js +2 -2
- package/src/core/websocket.js +14 -13
package/package.json
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
Say Command
|
|
3
|
-
|
|
4
3
|
Usage: say <message>
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
*/
|
|
7
5
|
const chalk = require('chalk');
|
|
8
6
|
|
|
9
7
|
module.exports = {
|
|
@@ -12,30 +10,38 @@ module.exports = {
|
|
|
12
10
|
aliases: ['msg', 'm', 'send'],
|
|
13
11
|
requiresAuth: true,
|
|
14
12
|
requiresRoom: true,
|
|
15
|
-
|
|
13
|
+
|
|
16
14
|
async execute(args, shell) {
|
|
17
|
-
const message = args.join(' ');
|
|
18
|
-
|
|
15
|
+
const message = args.join(' ').trim();
|
|
19
16
|
if (!message) {
|
|
20
17
|
console.log(chalk.red('❌ Usage: say <message>'));
|
|
21
18
|
return;
|
|
22
19
|
}
|
|
23
|
-
|
|
20
|
+
|
|
21
|
+
const room = shell.ws.getCurrentRoom?.();
|
|
22
|
+
if (!room) {
|
|
23
|
+
console.log(chalk.red('❌ Not in any room. Use: join <room-id>'));
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
|
|
24
27
|
try {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
// Clear typing indicator
|
|
28
|
+
// Stop typing indicator if active
|
|
28
29
|
if (shell.isTyping) {
|
|
29
|
-
shell.
|
|
30
|
+
shell.ws.socket?.emit('thinknsh:typing', { roomId: room, typing: false });
|
|
30
31
|
shell.isTyping = false;
|
|
31
32
|
clearTimeout(shell.typingTimeout);
|
|
32
33
|
}
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
|
|
35
|
+
await shell.ws.sendMessage(message);
|
|
36
|
+
|
|
35
37
|
const user = shell.api.getUser();
|
|
36
38
|
const time = new Date().toLocaleTimeString();
|
|
37
|
-
console.log(
|
|
38
|
-
|
|
39
|
+
console.log(
|
|
40
|
+
chalk.dim(`[${time}] `) +
|
|
41
|
+
chalk.green(`${user?.name || 'You'}: `) +
|
|
42
|
+
chalk.white(message)
|
|
43
|
+
);
|
|
44
|
+
|
|
39
45
|
} catch (error) {
|
|
40
46
|
console.log(chalk.red(`❌ Failed to send: ${error.message}`));
|
|
41
47
|
}
|
package/src/core/shell.js
CHANGED
|
@@ -652,7 +652,7 @@ async execute(input) {
|
|
|
652
652
|
stdio: 'inherit'
|
|
653
653
|
});
|
|
654
654
|
child.on('close', (code) => {
|
|
655
|
-
// Update currentDir in case command changed it (cd won't but others might)
|
|
655
|
+
// Update currentDir in case command changed it (cd won't but others might) http://localhost:3001
|
|
656
656
|
try { this.currentDir = process.cwd(); } catch {}
|
|
657
657
|
process.stdout.write('\r\n');
|
|
658
658
|
resolve();
|
|
@@ -668,7 +668,7 @@ async execute(input) {
|
|
|
668
668
|
try { const figlet = require('figlet'); console.log(chalk.cyan(figlet.textSync('ThinkNCollab', { font: 'Standard' }))); } catch {}
|
|
669
669
|
console.log(chalk.cyan(`
|
|
670
670
|
╔══════════════════════════════════════════════════════╗
|
|
671
|
-
║ ThinkNCollab Shell v0.0.
|
|
671
|
+
║ ThinkNCollab Shell v0.0.10 ║
|
|
672
672
|
║ Type 'help' for commands ║
|
|
673
673
|
╚══════════════════════════════════════════════════════╝`));
|
|
674
674
|
}
|
package/src/core/websocket.js
CHANGED
|
@@ -113,6 +113,7 @@ class WebSocketManager extends EventEmitter {
|
|
|
113
113
|
* { userId, name, userType } ← legacy
|
|
114
114
|
*/
|
|
115
115
|
setUser(user, token = null) {
|
|
116
|
+
this._user = user;
|
|
116
117
|
if (!user) return;
|
|
117
118
|
|
|
118
119
|
if (token) this._authToken = token;
|
|
@@ -295,27 +296,27 @@ class WebSocketManager extends EventEmitter {
|
|
|
295
296
|
return Promise.resolve({ success: true });
|
|
296
297
|
}
|
|
297
298
|
|
|
298
|
-
|
|
299
|
+
sendMessage(message, replyTo = null) {
|
|
300
|
+
return new Promise((resolve, reject) => {
|
|
301
|
+
if (!this.socket?.connected) return reject(new Error('Not connected'));
|
|
299
302
|
|
|
300
|
-
|
|
301
|
-
if (!
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
}
|
|
305
|
-
if (!this.roomId) return Promise.reject(new Error('Not in a room — run: join <room-id>'));
|
|
306
|
-
if (!this.currentUser) return Promise.reject(new Error('Not logged in — run: login'));
|
|
303
|
+
const roomId = this.roomId;
|
|
304
|
+
if (!roomId) return reject(new Error('Not in any room. Use: join <room-id>'));
|
|
305
|
+
|
|
306
|
+
if (!this.currentUser) return reject(new Error('Not authenticated. Run: login'));
|
|
307
307
|
|
|
308
308
|
this.socket.emit('thinknsh:message', {
|
|
309
|
-
roomId
|
|
309
|
+
roomId,
|
|
310
310
|
userId: this.currentUser.userId,
|
|
311
311
|
name: this.currentUser.name,
|
|
312
|
-
userType: this.currentUser.userType,
|
|
312
|
+
userType: this.currentUser.userType || 'User',
|
|
313
313
|
message,
|
|
314
|
+
replyTo: replyTo || null
|
|
314
315
|
});
|
|
315
316
|
|
|
316
|
-
|
|
317
|
-
}
|
|
318
|
-
|
|
317
|
+
resolve();
|
|
318
|
+
});
|
|
319
|
+
}
|
|
319
320
|
// ─── History ──────────────────────────────────────────────────────────────
|
|
320
321
|
|
|
321
322
|
getHistory(limit = 30, skip = 0) {
|