smart-bot-factory 0.3.10__py3-none-any.whl → 1.0.0__py3-none-any.whl

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.

Potentially problematic release.


This version of smart-bot-factory might be problematic. Click here for more details.

@@ -7,7 +7,7 @@ import logging
7
7
  import re
8
8
  from datetime import datetime, timedelta, timezone
9
9
  from functools import wraps
10
- from typing import Any, Callable, Dict, Union
10
+ from typing import Any, Callable, Dict, Optional, Union
11
11
 
12
12
  logger = logging.getLogger(__name__)
13
13
 
@@ -2176,12 +2176,13 @@ async def check_event_already_processed(
2176
2176
  return False
2177
2177
 
2178
2178
 
2179
- async def process_admin_event(event: Dict):
2179
+ async def process_admin_event(event: Dict, single_user_id: Optional[int] = None):
2180
2180
  """
2181
2181
  Обрабатывает одно админское событие - скачивает файлы из Storage и отправляет пользователям
2182
2182
 
2183
2183
  Args:
2184
2184
  event: Событие из БД с данными для отправки
2185
+ single_user_id: ID пользователя для тестовой отправки. Если указан, сообщение будет отправлено только ему
2185
2186
  """
2186
2187
  import json
2187
2188
  import shutil
@@ -2265,17 +2266,20 @@ async def process_admin_event(event: Dict):
2265
2266
  raise
2266
2267
 
2267
2268
  # 2. Получаем пользователей
2268
- users = await supabase_client.get_users_by_segment(segment)
2269
-
2270
- if not users:
2271
- logger.warning(f"⚠️ Нет пользователей для сегмента '{segment}'")
2272
- return {
2273
- "success_count": 0,
2274
- "failed_count": 0,
2275
- "total_users": 0,
2276
- "segment": segment or "Все",
2277
- "warning": "Нет пользователей",
2278
- }
2269
+ if single_user_id:
2270
+ users = [{"telegram_id": single_user_id}]
2271
+ logger.info(f"🔍 Тестовая отправка для пользователя {single_user_id}")
2272
+ else:
2273
+ users = await supabase_client.get_users_by_segment(segment)
2274
+ if not users:
2275
+ logger.warning(f"⚠️ Нет пользователей для сегмента '{segment}'")
2276
+ return {
2277
+ "success_count": 0,
2278
+ "failed_count": 0,
2279
+ "total_users": 0,
2280
+ "segment": segment or "Все",
2281
+ "warning": "Нет пользователей",
2282
+ }
2279
2283
 
2280
2284
  success_count = 0
2281
2285
  failed_count = 0
@@ -4,4 +4,4 @@ Event модули smart_bot_factory
4
4
 
5
5
  from ..core.decorators import event_handler, global_handler, schedule_task
6
6
 
7
- __all__ = ["event_handler", "schedule_task", "global_handler"]
7
+ __all__ = ["event_handler", "schedule_task", "global_handler"]
@@ -79,7 +79,7 @@ async def timeup_handler(message: Message, state: FSMContext):
79
79
  """Обработчик команды /timeup (или /вперед) - тестирование запланированных событий"""
80
80
  from datetime import datetime
81
81
 
82
- from ..core.decorators import process_scheduled_event, update_event_result
82
+ from ..core.decorators import process_scheduled_event, update_event_result, process_admin_event
83
83
 
84
84
  supabase_client = get_global_var("supabase_client")
85
85
 
@@ -148,22 +148,27 @@ async def timeup_handler(message: Message, state: FSMContext):
148
148
  )
149
149
 
150
150
  # Выполняем событие
151
- if event_category != "admin_event":
151
+ if event_category == "admin_event":
152
+ # Для админских событий используем тестовую отправку только текущему пользователю
153
+ await process_admin_event(event, single_user_id=message.from_user.id)
154
+ # Не отмечаем админское событие как выполненное при тестовой отправке
155
+ success_count += 1
156
+ results.append(f"✅ {event_label} (тестовая отправка)")
157
+ logger.info(f"✅ Событие {event_id} протестировано для пользователя {message.from_user.id}")
158
+ else:
152
159
  await process_scheduled_event(event)
153
-
154
- # Помечаем как выполненное
155
- if event_category != "admin_event" or event_category != "global_handler":
156
- await update_event_result(
157
- event_id,
158
- "completed",
159
- {
160
- "executed": True,
161
- "test_mode": True,
162
- "tested_by_user": message.from_user.id,
163
- "tested_at": datetime.now().isoformat(),
164
- },
165
- )
166
- if event_category != "admin_event":
160
+ # Помечаем как выполненное только не-админские события
161
+ if event_category != "global_handler":
162
+ await update_event_result(
163
+ event_id,
164
+ "completed",
165
+ {
166
+ "executed": True,
167
+ "test_mode": True,
168
+ "tested_by_user": message.from_user.id,
169
+ "tested_at": datetime.now().isoformat(),
170
+ },
171
+ )
167
172
  success_count += 1
168
173
  results.append(f"✅ {event_label}")
169
174
  logger.info(f"✅ Событие {event_id} успешно выполнено")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: smart-bot-factory
3
- Version: 0.3.10
3
+ Version: 1.0.0
4
4
  Summary: Библиотека для создания умных чат-ботов
5
5
  Author-email: Kopatych <eserov73@gmail.com>
6
6
  License: MIT
@@ -31,7 +31,7 @@ smart_bot_factory/configs/growthmed-october-24/welcome_file/welcome_file_msg.txt
31
31
  smart_bot_factory/configs/growthmed-october-24/welcome_file/Чек лист по 152ФЗ и 323ФЗ для медицины.pdf,sha256=BiAiQHNnQXJPMsks9AeL6s0beEjRFkRMJLMlAn4WorA,5284954
32
32
  smart_bot_factory/core/bot_utils.py,sha256=vbWb4wUkG-FlQIGTQ6RLoSSVg_LRVTzpnX3tyowsbqY,52032
33
33
  smart_bot_factory/core/conversation_manager.py,sha256=ga0ThoDpvov97x5KLcHpL8aRlEZB1XRw3JPrexIb-jk,29506
34
- smart_bot_factory/core/decorators.py,sha256=1FwJMjSM-QEgX3hX_LEW0A6VS3TWXBRIwwpPxK2pZuA,108247
34
+ smart_bot_factory/core/decorators.py,sha256=9TjB9mTp2fvopSgFOJOsQ326K220QHK87ZPoNa5BV_g,108733
35
35
  smart_bot_factory/core/message_sender.py,sha256=gK0HbjLumAu5_Vr29DnOQkwbPGGmQrtkgW1dVt_9Bb8,32518
36
36
  smart_bot_factory/core/router.py,sha256=66sCp7Okyu1ceIQPpxFF88-NizTD1N7rR4ZAdwDYmi8,16285
37
37
  smart_bot_factory/core/router_manager.py,sha256=x-cc4zhZUVPCTUH980GdlE_-JjHRtYnPdEBiWnf3ka8,10156
@@ -40,8 +40,8 @@ smart_bot_factory/creation/__init__.py,sha256=lHFgYIjOLvdsDAW8eLMp8zfFUCd-6wepvU
40
40
  smart_bot_factory/creation/bot_builder.py,sha256=-gF53eCaWBRKoUbRGR-PDHpqLWlceQ9FLUdEqQRt6lw,42929
41
41
  smart_bot_factory/creation/bot_testing.py,sha256=aMPSgj2o2zl6yWiV1a6RMmSJfiwMYp-_0ZkmJ6aFZVs,54561
42
42
  smart_bot_factory/dashboard/__init__.py,sha256=Qie1pJgzprBlCPrZVQLhVs1JR5-YrpzfcBvHHD3OLJk,94
43
- smart_bot_factory/event/__init__.py,sha256=E5u8Pjul_T0E77Ftmj-mqrip05w7KwUXlF1WMc5_lIs,192
44
- smart_bot_factory/handlers/handlers.py,sha256=za41yxSfsSwARnuI-l57JO90HN2knOXIqkbgq_z-MOA,63623
43
+ smart_bot_factory/event/__init__.py,sha256=eWKoiZ_DD-jTL9Tjv11ucQat8P8AhP3xWmQs29pd4ZA,190
44
+ smart_bot_factory/handlers/handlers.py,sha256=F7qgSrz_8kXDvolYmJPofF06PZRucsA6lI11iQCjbzk,64372
45
45
  smart_bot_factory/integrations/openai_client.py,sha256=R04qglOWNu3yQ32QRMRMzO01T6luWTp83H3OJMvD-uM,24316
46
46
  smart_bot_factory/integrations/supabase_client.py,sha256=7Yip9din4PDqFD1X2pkKB4KYAhmf04LUzxo9SnOrVg4,68415
47
47
  smart_bot_factory/message/__init__.py,sha256=neUUYAs8ITz3cV1B_T0P9_3XZvvn8cZ2VDpDqrf6lrc,1940
@@ -52,8 +52,8 @@ smart_bot_factory/utils/__init__.py,sha256=RgP2IAMFsJF7fxhhg8JLfhbGg9mO63xQM-NEa
52
52
  smart_bot_factory/utils/debug_routing.py,sha256=wV9BFwNmjBbF3rNI7UBdGsTf1bIT5XVQIGnxwIxhNYA,4707
53
53
  smart_bot_factory/utils/prompt_loader.py,sha256=YClbQjvRgTWCD42Rr92g77zzVEVMUgrqStI6YETC0c4,20022
54
54
  smart_bot_factory/utils/user_prompt_loader.py,sha256=lq1eQ4Hb2qN22osOjaFtkGdEc4OgpFPrzPNpPhsm5kA,2353
55
- smart_bot_factory-0.3.10.dist-info/METADATA,sha256=1rn8juhuHmHF0Vf9tmqucWYj0JW-acIjzvIMlvLfvFI,40749
56
- smart_bot_factory-0.3.10.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
57
- smart_bot_factory-0.3.10.dist-info/entry_points.txt,sha256=ybKEAI0WSb7WoRiey7QE-HHfn88UGV7nxLDxXq7b7SU,50
58
- smart_bot_factory-0.3.10.dist-info/licenses/LICENSE,sha256=OrK3cwdUTzNzIhJvSPtJaVMoYIyC_sSx5EFE_FDMvGs,1092
59
- smart_bot_factory-0.3.10.dist-info/RECORD,,
55
+ smart_bot_factory-1.0.0.dist-info/METADATA,sha256=9k7A5Gl3rfnCS-i9HJp2ZNXBMJCbLDOu8hlGobF0nM8,40748
56
+ smart_bot_factory-1.0.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
57
+ smart_bot_factory-1.0.0.dist-info/entry_points.txt,sha256=ybKEAI0WSb7WoRiey7QE-HHfn88UGV7nxLDxXq7b7SU,50
58
+ smart_bot_factory-1.0.0.dist-info/licenses/LICENSE,sha256=OrK3cwdUTzNzIhJvSPtJaVMoYIyC_sSx5EFE_FDMvGs,1092
59
+ smart_bot_factory-1.0.0.dist-info/RECORD,,