blockmine 1.16.2 → 1.17.0

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.
@@ -175,14 +175,19 @@ process.on('message', async (message) => {
175
175
 
176
176
  if (config.proxyHost && config.proxyPort) {
177
177
  sendLog(`[System] Используется прокси: ${config.proxyHost}:${config.proxyPort}`);
178
+
179
+ // Очищаем пароль от лишних символов
180
+ const cleanProxyPassword = config.proxyPassword ? config.proxyPassword.trim() : null;
181
+ const cleanProxyUsername = config.proxyUsername ? config.proxyUsername.trim() : null;
182
+
178
183
  botOptions.connect = (client) => {
179
184
  SocksClient.createConnection({
180
185
  proxy: {
181
186
  host: config.proxyHost,
182
187
  port: config.proxyPort,
183
188
  type: 5,
184
- userId: config.proxyUsername,
185
- password: config.proxyPassword
189
+ userId: cleanProxyUsername,
190
+ password: cleanProxyPassword
186
191
  },
187
192
  command: 'connect',
188
193
  destination: {
@@ -194,6 +199,7 @@ process.on('message', async (message) => {
194
199
  client.emit('connect');
195
200
  }).catch(err => {
196
201
  sendLog(`[Proxy Error] ${err.message}`);
202
+ sendLog(`[Debug] Full proxy error: ${JSON.stringify(err)}`);
197
203
  client.emit('error', err);
198
204
  });
199
205
  }
@@ -699,29 +705,52 @@ process.on('message', async (message) => {
699
705
  if (message.username && bot && bot.config) {
700
706
  UserService.clearCache(message.username, bot.config.id);
701
707
  }
708
+ } else if (message.type === 'invalidate_all_user_cache') {
709
+ if (bot && bot.config) {
710
+ for (const [cacheKey, user] of UserService.cache.entries()) {
711
+ if (cacheKey.startsWith(`${bot.config.id}:`)) {
712
+ UserService.cache.delete(cacheKey);
713
+ }
714
+ }
715
+ sendLog(`[BotProcess] Кэш пользователей очищен для бота ${bot.config.id}`);
716
+ }
702
717
  } else if (message.type === 'handle_permission_error') {
703
718
  const { commandName, username, typeChat } = message;
704
719
  const commandInstance = bot.commands.get(commandName);
705
720
  if (commandInstance) {
706
- commandInstance.onInsufficientPermissions(bot, typeChat, { username });
721
+ if (commandInstance.onInsufficientPermissions !== Command.prototype.onInsufficientPermissions) {
722
+ commandInstance.onInsufficientPermissions(bot, typeChat, { username });
723
+ } else {
724
+ bot.api.sendMessage(typeChat, `У вас нет прав для выполнения команды ${commandName}.`, username);
725
+ }
707
726
  }
708
727
  } else if (message.type === 'handle_wrong_chat') {
709
728
  const { commandName, username, typeChat } = message;
710
729
  const commandInstance = bot.commands.get(commandName);
711
730
  if (commandInstance) {
712
- commandInstance.onWrongChatType(bot, typeChat, { username });
731
+ if (commandInstance.onWrongChatType !== Command.prototype.onWrongChatType) {
732
+ commandInstance.onWrongChatType(bot, typeChat, { username });
733
+ } else {
734
+ bot.api.sendMessage('private', `Команду ${commandName} нельзя использовать в этом типе чата - ${typeChat}.`, username);
735
+ }
713
736
  }
714
737
  } else if (message.type === 'handle_cooldown') {
715
738
  const { commandName, username, typeChat, timeLeft } = message;
716
739
  const commandInstance = bot.commands.get(commandName);
717
740
  if (commandInstance) {
718
- commandInstance.onCooldown(bot, typeChat, { username }, timeLeft);
741
+ if (commandInstance.onCooldown !== Command.prototype.onCooldown) {
742
+ commandInstance.onCooldown(bot, typeChat, { username }, timeLeft);
743
+ } else {
744
+ bot.api.sendMessage(typeChat, `Команду ${commandName} можно будет использовать через ${timeLeft} сек.`, username);
745
+ }
719
746
  }
720
747
  } else if (message.type === 'handle_blacklist') {
721
748
  const { commandName, username, typeChat } = message;
722
749
  const commandInstance = bot.commands.get(commandName);
723
750
  if (commandInstance) {
724
- commandInstance.onBlacklisted(bot, typeChat, { username });
751
+ if (commandInstance.onBlacklisted !== Command.prototype.onBlacklisted) {
752
+ commandInstance.onBlacklisted(bot, typeChat, { username });
753
+ }
725
754
  }
726
755
  } else if (message.type === 'action') {
727
756
  if (message.name === 'lookAt' && bot && message.payload.position) {
@@ -787,10 +816,6 @@ process.on('SIGINT', () => {
787
816
  setTimeout(() => process.exit(0), 100);
788
817
  });
789
818
 
790
- // process.on('SIGKILL', () => {
791
- // sendLog('[System] Получен сигнал SIGKILL. Принудительное завершение...');
792
- // process.exit(0);
793
- // });
794
819
 
795
820
  function serializeEntity(entity) {
796
821
  if (!entity) return null;
@@ -19,6 +19,26 @@ class DevCommand extends Command {
19
19
  });
20
20
  }
21
21
 
22
+ // Переопределяем метод для кастомного сообщения при отсутствии прав
23
+ onInsufficientPermissions(bot, typeChat, user) {
24
+ bot.api.sendMessage(typeChat, `${user.username}, у вас нет прав для этой команды.`, user.username);
25
+ }
26
+
27
+ // Переопределяем метод для неправильного типа чата
28
+ onWrongChatType(bot, typeChat, user) {
29
+ bot.api.sendMessage('private', `${user.username}, команду dev нельзя использовать в чате типа "${typeChat}"`, user.username);
30
+ }
31
+
32
+ // Переопределяем метод для кулдауна
33
+ onCooldown(bot, typeChat, user, timeLeft) {
34
+ bot.api.sendMessage(typeChat, `${user.username}, подождите еще ${timeLeft} секунд перед повторным использованием команды.`, user.username);
35
+ }
36
+
37
+ // Переопределяем метод для черного списка (по умолчанию ничего не отправляется)
38
+ onBlacklisted(bot, typeChat, user) {
39
+ bot.api.sendMessage(typeChat, `${user.username}, вы находитесь в черном списке.`, user.username);
40
+ }
41
+
22
42
  async handler(bot, typeChat, user) {
23
43
  if (!appVersion) {
24
44
  try {
@@ -20,6 +20,7 @@ const eventGraphsRouter = require('./api/routes/eventGraphs');
20
20
  const TaskScheduler = require('./core/TaskScheduler');
21
21
  const panelRoutes = require('./api/routes/panel');
22
22
  const changelogRoutes = require('./api/routes/changelog');
23
+ const logsRoutes = require('./api/routes/logs');
23
24
 
24
25
  const app = express();
25
26
  const server = http.createServer(app);
@@ -61,6 +62,7 @@ app.use('/api/permissions', permissionsRoutes);
61
62
  app.use('/api/search', searchRoutes);
62
63
  app.use('/api/panel', panelRoutes);
63
64
  app.use('/api/changelog', changelogRoutes);
65
+ app.use('/api/logs', logsRoutes);
64
66
 
65
67
  app.use(express.static(frontendPath));
66
68