qwen-alpha 1.0.16 → 1.0.18

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
@@ -274,7 +274,7 @@ chmod -R 755 ~/.qwen-alpha/
274
274
 
275
275
  ## 📞 Контакты
276
276
 
277
- - **Telegram**: @QwenAlphaRobot (бот)
277
+ - **Telegram**: [@QwenAlphaRobot](https://t.me/QwenAlphaRobot) (бот)
278
278
  - **GitHub**: https://github.com/JeBance/QwenAlpha/issues
279
279
 
280
280
  ---
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qwen-alpha",
3
- "version": "1.0.16",
3
+ "version": "1.0.18",
4
4
  "description": "Telegram bot for Qwen Code integration — AI-powered code review, bug detection, and code generation",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -50,6 +50,8 @@ async function adminHandler(ctx) {
50
50
  **Управление пользователями:**
51
51
  /admin ban <user_id> — забанить
52
52
  /admin unban <user_id> — разбанить
53
+ /admin lock — заблокировать бота для всех кроме админов
54
+ /admin unlock — разблокировать бота
53
55
 
54
56
  **Сессии:**
55
57
  /admin sessions list — список сессий
@@ -128,7 +130,7 @@ async function adminHandler(ctx) {
128
130
  await ctx.reply('❌ Usage: /admin unban <user_id>');
129
131
  return;
130
132
  }
131
-
133
+
132
134
  const success = userService.unban(targetId);
133
135
  if (success) {
134
136
  await ctx.reply(`✅ Пользователь ${targetId} разбанен.`);
@@ -138,7 +140,31 @@ async function adminHandler(ctx) {
138
140
  }
139
141
  break;
140
142
  }
141
-
143
+
144
+ case 'lock': {
145
+ // Блокировка всех пользователей кроме админов
146
+ const settings = storeManager.get('settings');
147
+ const data = settings.getData();
148
+ data.locked = true;
149
+ settings.setData(data);
150
+
151
+ await ctx.reply('🔒 **Бот заблокирован для всех пользователей кроме админов.**\n\nИспользуйте /admin unlock для разблокировки.', { parse_mode: 'Markdown' });
152
+ logger.info({ userId }, 'Bot locked for all users except admins');
153
+ break;
154
+ }
155
+
156
+ case 'unlock': {
157
+ // Разблокировка бота
158
+ const settings = storeManager.get('settings');
159
+ const data = settings.getData();
160
+ data.locked = false;
161
+ settings.setData(data);
162
+
163
+ await ctx.reply('🔓 **Бот разблокирован.**\n\nВсе пользователи могут снова использовать бота.', { parse_mode: 'Markdown' });
164
+ logger.info({ userId }, 'Bot unlocked for all users');
165
+ break;
166
+ }
167
+
142
168
  case 'sessions': {
143
169
  const subCommand = args[2];
144
170
 
@@ -1,5 +1,6 @@
1
1
  const userService = require('../../services/db/users');
2
2
  const adminService = require('../../services/db/admins');
3
+ const { storeManager } = require('../../services/db');
3
4
  const { logger } = require('../../utils/logger');
4
5
  const config = require('../../config');
5
6
 
@@ -51,7 +52,17 @@ async function authMiddleware(ctx, next) {
51
52
  await ctx.reply('⛔ Ваш аккаунт заблокирован.');
52
53
  return;
53
54
  }
55
+
56
+ // Проверка блокировки бота (lock mode)
57
+ const settings = storeManager.get('settings');
58
+ const settingsData = settings.getData();
54
59
 
60
+ if (settingsData.locked && !adminService.isAdmin(userId)) {
61
+ logger.warn({ userId }, 'User blocked by lock mode');
62
+ await ctx.reply('🔒 Бот временно заблокирован администратором. Попробуйте позже.');
63
+ return;
64
+ }
65
+
55
66
  // Регистрация супер-админа (первый пользователь)
56
67
  const isNewSuperAdmin = adminService.registerSuperAdmin(userId);
57
68
  if (isNewSuperAdmin) {
@@ -169,11 +169,14 @@ class QwenService {
169
169
 
170
170
  for (const msg of messages) {
171
171
  // Сначала проверяем result сообщение (оно содержит финальный ответ)
172
- if (msg.type === 'result' && msg.result) {
173
- // result должен быть строкой, а не объектом
174
- if (typeof msg.result === 'string' && msg.result.length < 10000) {
172
+ if (msg.type === 'result') {
173
+ logger.debug({ resultType: typeof msg.result, resultLength: msg.result?.length, result: msg.result?.substring?.(0, 100) }, 'Checking result message');
174
+
175
+ // result должен быть строкой
176
+ if (typeof msg.result === 'string') {
175
177
  textContents.push(msg.result);
176
178
  hasResult = true;
179
+ logger.info({ resultLength: msg.result.length }, 'Found result text');
177
180
  break;
178
181
  }
179
182
  }