blockmine 1.5.7 → 1.5.9

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
@@ -97,8 +97,7 @@
97
97
  Это сердце No-Code автоматизации в BlockMine. Редактор позволяет вам создавать логику, перетаскивая и соединяя функциональные блоки (ноды).
98
98
 
99
99
  * **Создание команд**: Спроектируйте полноценную команду с аргументами, проверками прав и сложной логикой, не прикасаясь к коду.
100
- * **Обработка событий**: Создавайте графы, которые реагируют на игровые события (например, вход игрока, сообщение в чате, появление моба) и выполняют заданные действия.
101
- * **Наглядность**: Весь поток выполнения виден на одном экране, что упрощает понимание и отладку логики.
100
+ * **Обработка событий**: Создавайте ноды, которые реагируют на игровые события (например, вход игрока, сообщение в чате, появление моба) и выполняют заданные действия.
102
101
 
103
102
  ### 🔌 Плагины
104
103
  Плагины — это способ программного расширения функциональности. Они могут добавлять новые команды, новые ноды для визуального редактора или работать в фоновом режиме.
@@ -143,4 +142,4 @@ npm run dev
143
142
  ```
144
143
 
145
144
  * **Бэкенд** будет доступен на `http://localhost:3001`.
146
- * **Фронтенд** с горячей перезагрузкой будет доступен на `http://localhost:5173`. Открывайте этот адрес для разработки.
145
+ * **Фронтенд** с горячей перезагрузкой будет доступен на `http://localhost:5173`. Открывайте этот адрес для разработки.
@@ -1,5 +1,5 @@
1
1
  const express = require('express');
2
- const { PrismaClient } = require('@prisma/client');
2
+ const prisma = require('../../lib/prisma');
3
3
  const path = require('path');
4
4
  const fs = require('fs/promises');
5
5
  const { botManager, pluginManager } = require('../../core/services');
@@ -16,7 +16,6 @@ const multer = require('multer');
16
16
  const archiver = require('archiver');
17
17
  const AdmZip = require('adm-zip');
18
18
 
19
- const prisma = new PrismaClient();
20
19
  const upload = multer({ storage: multer.memoryStorage() });
21
20
 
22
21
  const router = express.Router();
@@ -173,16 +172,26 @@ router.post('/:id/start', authorize('bot:start_stop'), async (req, res) => {
173
172
  try {
174
173
  const botId = parseInt(req.params.id, 10);
175
174
  const botConfig = await prisma.bot.findUnique({ where: { id: botId }, include: { server: true } });
176
- if (!botConfig) return res.status(404).json({ error: 'Бот не найден' });
177
- const result = await botManager.startBot(botConfig);
178
- res.json(result);
179
- } catch (error) { res.status(500).json({ error: 'Ошибка при запуске бота: ' + error.message }); }
175
+ if (!botConfig) {
176
+ return res.status(404).json({ success: false, message: 'Бот не найден' });
177
+ }
178
+ botManager.startBot(botConfig);
179
+ res.status(202).json({ success: true, message: 'Команда на запуск отправлена.' });
180
+ } catch (error) {
181
+ console.error(`[API] Ошибка запуска бота ${req.params.id}:`, error);
182
+ res.status(500).json({ success: false, message: 'Ошибка при запуске бота: ' + error.message });
183
+ }
180
184
  });
181
185
 
182
186
  router.post('/:id/stop', authorize('bot:start_stop'), (req, res) => {
183
- const botId = parseInt(req.params.id, 10);
184
- const result = botManager.stopBot(botId);
185
- res.json(result);
187
+ try {
188
+ const botId = parseInt(req.params.id, 10);
189
+ botManager.stopBot(botId);
190
+ res.status(202).json({ success: true, message: 'Команда на остановку отправлена.' });
191
+ } catch (error) {
192
+ console.error(`[API] Ошибка остановки бота ${req.params.id}:`, error);
193
+ res.status(500).json({ success: false, message: 'Ошибка при остановке бота: ' + error.message });
194
+ }
186
195
  });
187
196
 
188
197
  router.post('/:id/chat', authorize('bot:interact'), (req, res) => {
@@ -868,7 +877,6 @@ router.post('/:botId/commands/import', authorize('management:edit'), async (req,
868
877
  const graph = JSON.parse(finalGraphJson);
869
878
  const nodeIdMap = new Map();
870
879
 
871
- // Рандомизация ID узлов
872
880
  if (graph.nodes) {
873
881
  graph.nodes.forEach(node => {
874
882
  const oldId = node.id;
@@ -878,7 +886,6 @@ router.post('/:botId/commands/import', authorize('management:edit'), async (req,
878
886
  });
879
887
  }
880
888
 
881
- // Обновление и рандомизация ID связей
882
889
  if (graph.connections) {
883
890
  graph.connections.forEach(conn => {
884
891
  conn.id = `edge-${randomUUID()}`;