@metatell/bot-cli 0.0.6 → 0.0.8
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/README.md +52 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +19 -13
- package/dist/commands/connect.js +31 -86
- package/dist/commands/inspect.js +51 -108
- package/dist/commands/interactive.js +105 -185
- package/dist/index.js +3 -9
- package/dist/types.js +1 -2
- package/dist/utils/commands.js +216 -359
- package/dist/utils/url.js +13 -17
- package/package.json +9 -9
package/dist/utils/commands.js
CHANGED
|
@@ -1,373 +1,230 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* Command parser and executor for CLI commands
|
|
4
3
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
4
|
+
export class CommandParser {
|
|
5
|
+
async execute(input, client) {
|
|
6
|
+
const parts = input.split(/\s+/);
|
|
7
|
+
const command = parts[0].toLowerCase();
|
|
8
|
+
const args = parts.slice(1);
|
|
9
|
+
switch (command) {
|
|
10
|
+
case '/help':
|
|
11
|
+
case '/?':
|
|
12
|
+
return this.showHelp();
|
|
13
|
+
case '/say':
|
|
14
|
+
return this.say(args, client);
|
|
15
|
+
case '/move':
|
|
16
|
+
return this.move(args, client);
|
|
17
|
+
case '/look':
|
|
18
|
+
return this.look(args, client);
|
|
19
|
+
case '/nearby':
|
|
20
|
+
return this.nearby(args, client);
|
|
21
|
+
case '/users':
|
|
22
|
+
return this.listUsers(client);
|
|
23
|
+
case '/status':
|
|
24
|
+
return this.showStatus(client);
|
|
25
|
+
case '/info':
|
|
26
|
+
return this.showInfo(client);
|
|
27
|
+
case '/anime':
|
|
28
|
+
case '/animation':
|
|
29
|
+
return this.playAnimation(args, client);
|
|
30
|
+
case '/stop':
|
|
31
|
+
return this.stopAnimation(client);
|
|
32
|
+
case '/avatar':
|
|
33
|
+
return this.changeAvatar(args, client);
|
|
34
|
+
case '/assets':
|
|
35
|
+
return this.listAssets(client);
|
|
36
|
+
case '/animations':
|
|
37
|
+
return this.listAnimations(client);
|
|
38
|
+
default:
|
|
39
|
+
return {
|
|
40
|
+
success: false,
|
|
41
|
+
message: `Unknown command: ${command}. Type /help for commands.`,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
45
44
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
case '/users':
|
|
66
|
-
return [2 /*return*/, this.listUsers(client)];
|
|
67
|
-
case '/status':
|
|
68
|
-
return [2 /*return*/, this.showStatus(client)];
|
|
69
|
-
case '/info':
|
|
70
|
-
return [2 /*return*/, this.showInfo(client)];
|
|
71
|
-
case '/anime':
|
|
72
|
-
case '/animation':
|
|
73
|
-
return [2 /*return*/, this.playAnimation(args, client)];
|
|
74
|
-
case '/stop':
|
|
75
|
-
return [2 /*return*/, this.stopAnimation(client)];
|
|
76
|
-
case '/avatar':
|
|
77
|
-
return [2 /*return*/, this.changeAvatar(args, client)];
|
|
78
|
-
case '/assets':
|
|
79
|
-
return [2 /*return*/, this.listAssets(client)];
|
|
80
|
-
case '/animations':
|
|
81
|
-
return [2 /*return*/, this.listAnimations(client)];
|
|
82
|
-
default:
|
|
83
|
-
return [2 /*return*/, {
|
|
84
|
-
success: false,
|
|
85
|
-
message: "Unknown command: ".concat(command, ". Type /help for commands."),
|
|
86
|
-
}];
|
|
87
|
-
}
|
|
88
|
-
return [2 /*return*/];
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
};
|
|
92
|
-
CommandParser.prototype.showHelp = function () {
|
|
93
|
-
var help = "\nAvailable commands:\n /help, /? - Show this help\n /say <message> - Send a message\n /move <x> <y> <z> - Move avatar to position\n /look <x> <y> <z> - Look at position\n /look @<username> - Look at user\n /nearby [radius] - Show nearby users (default: 10)\n /users - List all users\n /status - Show connection status\n /info - Show bot info\n /avatar <id> - Change avatar\n /assets - List available avatars\n /anime <name> - Play animation\n /animations - List available animations\n /stop - Stop current animation\n quit, exit - Exit the program\n";
|
|
45
|
+
showHelp() {
|
|
46
|
+
const help = `
|
|
47
|
+
Available commands:
|
|
48
|
+
/help, /? - Show this help
|
|
49
|
+
/say <message> - Send a message
|
|
50
|
+
/move <x> <y> <z> - Move avatar to position
|
|
51
|
+
/look <x> <y> <z> - Look at position
|
|
52
|
+
/look @<username> - Look at user
|
|
53
|
+
/nearby [radius] - Show nearby users (default: 10)
|
|
54
|
+
/users - List all users
|
|
55
|
+
/status - Show connection status
|
|
56
|
+
/info - Show bot info
|
|
57
|
+
/avatar <id> - Change avatar
|
|
58
|
+
/assets - List available avatars
|
|
59
|
+
/anime <name> - Play animation
|
|
60
|
+
/animations - List available animations
|
|
61
|
+
/stop - Stop current animation
|
|
62
|
+
quit, exit - Exit the program
|
|
63
|
+
`;
|
|
94
64
|
console.log(help);
|
|
95
65
|
return { success: true };
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
return [2 /*return*/, { success: true, message: 'Looking at user (position tracking not yet implemented)' }];
|
|
161
|
-
case 2:
|
|
162
|
-
// 座標を見る場合
|
|
163
|
-
if (args.length !== 3) {
|
|
164
|
-
return [2 /*return*/, { success: false, message: 'Usage: /look <x> <y> <z>' }];
|
|
165
|
-
}
|
|
166
|
-
x = parseFloat(args[0]);
|
|
167
|
-
y = parseFloat(args[1]);
|
|
168
|
-
z = parseFloat(args[2]);
|
|
169
|
-
if (Number.isNaN(x) || Number.isNaN(y) || Number.isNaN(z)) {
|
|
170
|
-
return [2 /*return*/, { success: false, message: 'Invalid coordinates. Must be numbers.' }];
|
|
171
|
-
}
|
|
172
|
-
// 指定座標を見る
|
|
173
|
-
return [4 /*yield*/, client.avatar.lookAt({ x: x, y: y, z: z })];
|
|
174
|
-
case 3:
|
|
175
|
-
// 指定座標を見る
|
|
176
|
-
_a.sent();
|
|
177
|
-
console.log("[Looking at] x:".concat(x, " y:").concat(y, " z:").concat(z));
|
|
178
|
-
return [2 /*return*/, { success: true }];
|
|
179
|
-
}
|
|
180
|
-
});
|
|
181
|
-
});
|
|
182
|
-
};
|
|
183
|
-
CommandParser.prototype.nearby = function (args, client) {
|
|
184
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
185
|
-
var radius, nearbyUsers;
|
|
186
|
-
return __generator(this, function (_a) {
|
|
187
|
-
switch (_a.label) {
|
|
188
|
-
case 0:
|
|
189
|
-
radius = args.length > 0 ? parseFloat(args[0]) : 10;
|
|
190
|
-
if (Number.isNaN(radius)) {
|
|
191
|
-
return [2 /*return*/, { success: false, message: 'Invalid radius. Must be a number.' }];
|
|
192
|
-
}
|
|
193
|
-
return [4 /*yield*/, client.room.getNearbyUsers(radius)];
|
|
194
|
-
case 1:
|
|
195
|
-
nearbyUsers = _a.sent();
|
|
196
|
-
console.log("[Nearby users within ".concat(radius, "m]"));
|
|
197
|
-
nearbyUsers.forEach(function (u) {
|
|
198
|
-
console.log("- ".concat(u.name || 'Anonymous', " (").concat(u.id, ")").concat(u.isBot ? ' [Bot]' : ''));
|
|
199
|
-
});
|
|
200
|
-
return [2 /*return*/, { success: true }];
|
|
201
|
-
}
|
|
202
|
-
});
|
|
66
|
+
}
|
|
67
|
+
async say(args, client) {
|
|
68
|
+
if (args.length === 0) {
|
|
69
|
+
return { success: false, message: 'Usage: /say <message>' };
|
|
70
|
+
}
|
|
71
|
+
const message = args.join(' ');
|
|
72
|
+
await client.chat.send(message);
|
|
73
|
+
console.log('[Sent]', message);
|
|
74
|
+
return { success: true };
|
|
75
|
+
}
|
|
76
|
+
async move(args, client) {
|
|
77
|
+
if (args.length !== 3) {
|
|
78
|
+
return { success: false, message: 'Usage: /move <x> <y> <z>' };
|
|
79
|
+
}
|
|
80
|
+
const x = parseFloat(args[0]);
|
|
81
|
+
const y = parseFloat(args[1]);
|
|
82
|
+
const z = parseFloat(args[2]);
|
|
83
|
+
if (Number.isNaN(x) || Number.isNaN(y) || Number.isNaN(z)) {
|
|
84
|
+
return { success: false, message: 'Invalid coordinates. Must be numbers.' };
|
|
85
|
+
}
|
|
86
|
+
await client.avatar.moveTo({ x, y, z });
|
|
87
|
+
console.log(`[Moved to] x:${x} y:${y} z:${z}`);
|
|
88
|
+
return { success: true };
|
|
89
|
+
}
|
|
90
|
+
async look(args, client) {
|
|
91
|
+
if (args.length === 0) {
|
|
92
|
+
return { success: false, message: 'Usage: /look <x> <y> <z> or /look @<username>' };
|
|
93
|
+
}
|
|
94
|
+
// ユーザーを見る場合
|
|
95
|
+
if (args[0].startsWith('@')) {
|
|
96
|
+
const username = args[0].substring(1);
|
|
97
|
+
const users = await client.room.getUsers();
|
|
98
|
+
const targetUser = users.find((u) => u.name?.toLowerCase() === username.toLowerCase());
|
|
99
|
+
if (!targetUser) {
|
|
100
|
+
return { success: false, message: `User not found: ${username}` };
|
|
101
|
+
}
|
|
102
|
+
// TODO: ユーザーの位置を取得して見る機能はSDKに未実装
|
|
103
|
+
console.log(`[Looking at] ${targetUser.name}`);
|
|
104
|
+
return { success: true, message: 'Looking at user (position tracking not yet implemented)' };
|
|
105
|
+
}
|
|
106
|
+
// 座標を見る場合
|
|
107
|
+
if (args.length !== 3) {
|
|
108
|
+
return { success: false, message: 'Usage: /look <x> <y> <z>' };
|
|
109
|
+
}
|
|
110
|
+
const x = parseFloat(args[0]);
|
|
111
|
+
const y = parseFloat(args[1]);
|
|
112
|
+
const z = parseFloat(args[2]);
|
|
113
|
+
if (Number.isNaN(x) || Number.isNaN(y) || Number.isNaN(z)) {
|
|
114
|
+
return { success: false, message: 'Invalid coordinates. Must be numbers.' };
|
|
115
|
+
}
|
|
116
|
+
// 指定座標を見る
|
|
117
|
+
await client.avatar.lookAt({ x, y, z });
|
|
118
|
+
console.log(`[Looking at] x:${x} y:${y} z:${z}`);
|
|
119
|
+
return { success: true };
|
|
120
|
+
}
|
|
121
|
+
async nearby(args, client) {
|
|
122
|
+
const radius = args.length > 0 ? parseFloat(args[0]) : 10;
|
|
123
|
+
if (Number.isNaN(radius)) {
|
|
124
|
+
return { success: false, message: 'Invalid radius. Must be a number.' };
|
|
125
|
+
}
|
|
126
|
+
const nearbyUsers = await client.room.getNearbyUsers(radius);
|
|
127
|
+
console.log(`[Nearby users within ${radius}m]`);
|
|
128
|
+
nearbyUsers.forEach((u) => {
|
|
129
|
+
console.log(`- ${u.name || 'Anonymous'} (${u.id})${u.isBot ? ' [Bot]' : ''}`);
|
|
203
130
|
});
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
case 1:
|
|
212
|
-
users = _a.sent();
|
|
213
|
-
console.log("[Users (".concat(users.length, ")]"));
|
|
214
|
-
users.forEach(function (u) {
|
|
215
|
-
console.log("- ".concat(u.name || 'Anonymous', " (").concat(u.id, ")").concat(u.isBot ? ' [Bot]' : ''));
|
|
216
|
-
});
|
|
217
|
-
return [2 /*return*/, { success: true }];
|
|
218
|
-
}
|
|
219
|
-
});
|
|
131
|
+
return { success: true };
|
|
132
|
+
}
|
|
133
|
+
async listUsers(client) {
|
|
134
|
+
const users = await client.room.getUsers();
|
|
135
|
+
console.log(`[Users (${users.length})]`);
|
|
136
|
+
users.forEach((u) => {
|
|
137
|
+
console.log(`- ${u.name || 'Anonymous'} (${u.id})${u.isBot ? ' [Bot]' : ''}`);
|
|
220
138
|
});
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
139
|
+
return { success: true };
|
|
140
|
+
}
|
|
141
|
+
showStatus(client) {
|
|
142
|
+
const status = client.getStatus();
|
|
143
|
+
const sessionId = client.getSessionId();
|
|
225
144
|
console.log('[Status]');
|
|
226
|
-
console.log(
|
|
227
|
-
console.log(
|
|
228
|
-
console.log(
|
|
145
|
+
console.log(`Connected: ${status.connected}`);
|
|
146
|
+
console.log(`Connecting: ${status.connecting}`);
|
|
147
|
+
console.log(`Session ID: ${sessionId || 'N/A'}`);
|
|
229
148
|
return { success: true };
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
_a.sent();
|
|
264
|
-
console.log("[Avatar changed to] ".concat(avatarId));
|
|
265
|
-
return [2 /*return*/, { success: true }];
|
|
266
|
-
case 3:
|
|
267
|
-
error_1 = _a.sent();
|
|
268
|
-
errorMessage = error_1 instanceof Error ? error_1.message : 'Unknown error';
|
|
269
|
-
console.error('[Error]', errorMessage);
|
|
270
|
-
return [2 /*return*/, {
|
|
271
|
-
success: false,
|
|
272
|
-
message: "Failed to change avatar: ".concat(errorMessage),
|
|
273
|
-
}];
|
|
274
|
-
case 4: return [2 /*return*/];
|
|
275
|
-
}
|
|
276
|
-
});
|
|
277
|
-
});
|
|
278
|
-
};
|
|
279
|
-
CommandParser.prototype.listAssets = function (client) {
|
|
280
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
281
|
-
var assets;
|
|
282
|
-
return __generator(this, function (_a) {
|
|
283
|
-
switch (_a.label) {
|
|
284
|
-
case 0: return [4 /*yield*/, client.avatar.getAvailableAssets()];
|
|
285
|
-
case 1:
|
|
286
|
-
assets = _a.sent();
|
|
287
|
-
console.log("[Available avatars (".concat(assets.length, ")]"));
|
|
288
|
-
assets.forEach(function (asset) {
|
|
289
|
-
console.log("- ".concat(asset.id, ": ").concat(asset.name));
|
|
290
|
-
});
|
|
291
|
-
return [2 /*return*/, { success: true }];
|
|
292
|
-
}
|
|
293
|
-
});
|
|
294
|
-
});
|
|
295
|
-
};
|
|
296
|
-
CommandParser.prototype.playAnimation = function (args, client) {
|
|
297
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
298
|
-
var animationName, error_2;
|
|
299
|
-
return __generator(this, function (_a) {
|
|
300
|
-
switch (_a.label) {
|
|
301
|
-
case 0:
|
|
302
|
-
if (args.length === 0) {
|
|
303
|
-
return [2 /*return*/, { success: false, message: 'Usage: /anime <name>' }];
|
|
304
|
-
}
|
|
305
|
-
animationName = args.join(' ');
|
|
306
|
-
_a.label = 1;
|
|
307
|
-
case 1:
|
|
308
|
-
_a.trys.push([1, 3, , 4]);
|
|
309
|
-
return [4 /*yield*/, client.avatar.play({
|
|
310
|
-
name: animationName,
|
|
311
|
-
id: animationName,
|
|
312
|
-
loop: false,
|
|
313
|
-
})];
|
|
314
|
-
case 2:
|
|
315
|
-
_a.sent();
|
|
316
|
-
console.log("[Playing animation] ".concat(animationName));
|
|
317
|
-
return [2 /*return*/, { success: true }];
|
|
318
|
-
case 3:
|
|
319
|
-
error_2 = _a.sent();
|
|
320
|
-
return [2 /*return*/, {
|
|
321
|
-
success: false,
|
|
322
|
-
message: "Failed to play animation: ".concat(error_2 instanceof Error ? error_2.message : 'Unknown error'),
|
|
323
|
-
}];
|
|
324
|
-
case 4: return [2 /*return*/];
|
|
325
|
-
}
|
|
326
|
-
});
|
|
149
|
+
}
|
|
150
|
+
async showInfo(client) {
|
|
151
|
+
const info = await client.getInfo();
|
|
152
|
+
console.log('[Bot Info]');
|
|
153
|
+
console.log(`Name: ${info.name}`);
|
|
154
|
+
console.log(`Version: ${info.version}`);
|
|
155
|
+
console.log(`Room ID: ${info.roomId}`);
|
|
156
|
+
return { success: true };
|
|
157
|
+
}
|
|
158
|
+
async changeAvatar(args, client) {
|
|
159
|
+
if (args.length === 0) {
|
|
160
|
+
return { success: false, message: 'Usage: /avatar <id>' };
|
|
161
|
+
}
|
|
162
|
+
const avatarId = args[0];
|
|
163
|
+
try {
|
|
164
|
+
await client.avatar.select(avatarId);
|
|
165
|
+
console.log(`[Avatar changed to] ${avatarId}`);
|
|
166
|
+
return { success: true };
|
|
167
|
+
}
|
|
168
|
+
catch (error) {
|
|
169
|
+
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
170
|
+
console.error('[Error]', errorMessage);
|
|
171
|
+
return {
|
|
172
|
+
success: false,
|
|
173
|
+
message: `Failed to change avatar: ${errorMessage}`,
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
async listAssets(client) {
|
|
178
|
+
const assets = await client.avatar.getAvailableAssets();
|
|
179
|
+
console.log(`[Available avatars (${assets.length})]`);
|
|
180
|
+
assets.forEach((asset) => {
|
|
181
|
+
console.log(`- ${asset.id}: ${asset.name}`);
|
|
327
182
|
});
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
return
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
})];
|
|
341
|
-
case 1:
|
|
342
|
-
_b.sent();
|
|
343
|
-
console.log('[Stopped animation]');
|
|
344
|
-
return [2 /*return*/, { success: true }];
|
|
345
|
-
case 2:
|
|
346
|
-
_a = _b.sent();
|
|
347
|
-
return [2 /*return*/, { success: true, message: 'Animation stopped' }];
|
|
348
|
-
case 3: return [2 /*return*/];
|
|
349
|
-
}
|
|
183
|
+
return { success: true };
|
|
184
|
+
}
|
|
185
|
+
async playAnimation(args, client) {
|
|
186
|
+
if (args.length === 0) {
|
|
187
|
+
return { success: false, message: 'Usage: /anime <name>' };
|
|
188
|
+
}
|
|
189
|
+
const animationName = args.join(' ');
|
|
190
|
+
try {
|
|
191
|
+
await client.avatar.play({
|
|
192
|
+
name: animationName,
|
|
193
|
+
id: animationName,
|
|
194
|
+
loop: false,
|
|
350
195
|
});
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
196
|
+
console.log(`[Playing animation] ${animationName}`);
|
|
197
|
+
return { success: true };
|
|
198
|
+
}
|
|
199
|
+
catch (error) {
|
|
200
|
+
return {
|
|
201
|
+
success: false,
|
|
202
|
+
message: `Failed to play animation: ${error instanceof Error ? error.message : 'Unknown error'}`,
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
async stopAnimation(client) {
|
|
207
|
+
// アイドルアニメーションに戻す
|
|
208
|
+
try {
|
|
209
|
+
await client.avatar.play({
|
|
210
|
+
name: 'idle',
|
|
211
|
+
id: 'idle',
|
|
212
|
+
loop: true,
|
|
368
213
|
});
|
|
214
|
+
console.log('[Stopped animation]');
|
|
215
|
+
return { success: true };
|
|
216
|
+
}
|
|
217
|
+
catch {
|
|
218
|
+
return { success: true, message: 'Animation stopped' };
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
async listAnimations(client) {
|
|
222
|
+
const animations = await client.avatar.getAvailableAnimations();
|
|
223
|
+
console.log(`[Available animations (${animations.length})]`);
|
|
224
|
+
animations.forEach((anim) => {
|
|
225
|
+
const duration = anim.duration ? ` (${anim.duration.toFixed(1)}s)` : '';
|
|
226
|
+
console.log(`- ${anim.id || anim.name}: ${anim.name}${duration}`);
|
|
369
227
|
});
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
}
|
|
373
|
-
exports.CommandParser = CommandParser;
|
|
228
|
+
return { success: true };
|
|
229
|
+
}
|
|
230
|
+
}
|