blockmine 1.6.1 → 1.6.3

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 CHANGED
@@ -131,6 +131,7 @@
131
131
  git clone https://github.com/blockmineJS/blockmine.git
132
132
  cd blockmine
133
133
  npm install
134
+ npm run build
134
135
  ```
135
136
 
136
137
  ### 2. Запуск в режиме разработки
@@ -402,6 +402,33 @@ router.post('/:pluginName/fs', resolvePluginPath, async (req, res) => {
402
402
  res.status(200).json({ message: 'Renamed successfully.' });
403
403
  break;
404
404
 
405
+ case 'move':
406
+ if (!newPath) return res.status(400).json({ error: 'New path is required for move operation.' });
407
+ const safeMoveNewPath = path.resolve(req.pluginPath, newPath);
408
+ if (!safeMoveNewPath.startsWith(req.pluginPath)) return res.status(403).json({ error: 'Access denied: New path is outside of plugin directory.' });
409
+ if (!await fse.pathExists(safePath)) return res.status(404).json({ error: 'Source file or folder not found.' });
410
+
411
+ if (safeMoveNewPath.startsWith(safePath + path.sep)) {
412
+ return res.status(400).json({ error: 'Cannot move folder into itself.' });
413
+ }
414
+
415
+ let finalPath = safeMoveNewPath;
416
+ let counter = 1;
417
+ while (await fse.pathExists(finalPath)) {
418
+ const ext = path.extname(safeMoveNewPath);
419
+ const base = path.basename(safeMoveNewPath, ext);
420
+ const dir = path.dirname(safeMoveNewPath);
421
+ finalPath = path.join(dir, `${base} (${counter})${ext}`);
422
+ counter++;
423
+ }
424
+
425
+ await fse.move(safePath, finalPath);
426
+ res.status(200).json({
427
+ message: 'Moved successfully.',
428
+ newPath: path.relative(req.pluginPath, finalPath)
429
+ });
430
+ break;
431
+
405
432
  default:
406
433
  res.status(400).json({ error: 'Invalid operation specified.' });
407
434
  }
@@ -608,18 +635,23 @@ router.post('/:pluginName/create-pr', resolvePluginPath, async (req, res) => {
608
635
 
609
636
  let branchExists = false;
610
637
  try {
611
- cp.execSync(`git ls-remote --heads origin ${branch}`, { stdio: 'pipe' });
612
- branchExists = true;
613
- console.log(`[Plugin IDE] Ветка ${branch} уже существует, переключаемся на неё`);
638
+ cp.execSync(`git checkout -b ${branch}`, { stdio: 'pipe' });
639
+ console.log(`[Plugin IDE] Создана новая ветка ${branch}`);
614
640
  } catch (e) {
615
- console.log(`[Plugin IDE] Ветка ${branch} не существует, создаём новую`);
616
- }
617
-
618
- if (branchExists) {
619
- cp.execSync(`git checkout -b ${branch} origin/${branch}`);
620
- cp.execSync(`git pull origin ${branch}`);
621
- } else {
622
- cp.execSync(`git checkout -b ${branch}`);
641
+ try {
642
+ cp.execSync(`git checkout ${branch}`, { stdio: 'pipe' });
643
+ console.log(`[Plugin IDE] Переключились на существующую ветку ${branch}`);
644
+ } catch (e2) {
645
+ try {
646
+ cp.execSync(`git fetch origin ${branch}`, { stdio: 'pipe' });
647
+ cp.execSync(`git checkout -b ${branch} origin/${branch}`, { stdio: 'pipe' });
648
+ branchExists = true;
649
+ console.log(`[Plugin IDE] Создана ветка ${branch} из удаленной`);
650
+ } catch (e3) {
651
+ cp.execSync(`git checkout -B ${branch}`, { stdio: 'pipe' });
652
+ console.log(`[Plugin IDE] Принудительно создана ветка ${branch}`);
653
+ }
654
+ }
623
655
  }
624
656
 
625
657
  const files = await fse.readdir(req.pluginPath);
@@ -420,6 +420,10 @@ process.on('message', async (message) => {
420
420
  messageHandledByCustomParser = false;
421
421
  const rawMessageText = jsonMsg.toString();
422
422
  bot.events.emit('core:raw_message', rawMessageText, jsonMsg);
423
+
424
+ sendEvent('raw_message', {
425
+ rawText: rawMessageText
426
+ });
423
427
  });
424
428
 
425
429
  bot.events.on('chat:message', (data) => {
@@ -145,6 +145,9 @@ class EventGraphManager {
145
145
  context.message = args.message;
146
146
  context.chat_type = args.chatType;
147
147
  break;
148
+ case 'raw_message':
149
+ context.rawText = args.rawText;
150
+ break;
148
151
  case 'playerJoined':
149
152
  case 'playerLeft':
150
153
  context.user = args.user;
@@ -379,7 +379,13 @@ class GraphExecutionEngine {
379
379
  else result = this.context[pinId];
380
380
  break;
381
381
  case 'event:chat':
382
- if (pinId === 'user') result = { username: this.context.username };
382
+ if (pinId === 'username') result = this.context.username;
383
+ else if (pinId === 'message') result = this.context.message;
384
+ else if (pinId === 'chatType') result = this.context.chat_type;
385
+ else result = this.context[pinId];
386
+ break;
387
+ case 'event:raw_message':
388
+ if (pinId === 'rawText') result = this.context.rawText;
383
389
  else result = this.context[pinId];
384
390
  break;
385
391
  case 'event:playerJoined':
@@ -129,7 +129,23 @@ class NodeRegistry {
129
129
  { id: 'username', type: 'String', name: 'Игрок' },
130
130
  { id: 'message', type: 'String', name: 'Сообщение' },
131
131
  { id: 'chatType', type: 'String', name: 'Тип чата' },
132
- { id: 'raw', type: 'String', name: 'Raw JSON' },
132
+ ]
133
+ }
134
+ });
135
+
136
+ this.registerNodeType({
137
+ type: 'event:raw_message',
138
+ name: 'Событие: Сырое сообщение',
139
+ label: '📝 Сырое сообщение',
140
+ description: 'Срабатывает при получении любого сообщения в сыром виде (до парсинга).',
141
+ category: 'События',
142
+ graphType: event,
143
+ isEvent: true,
144
+ pins: {
145
+ inputs: [],
146
+ outputs: [
147
+ { id: 'exec', type: 'Exec', name: 'Выполнить' },
148
+ { id: 'rawText', type: 'String', name: 'Сырой текст' },
133
149
  ]
134
150
  }
135
151
  });