smart-bot-factory 0.3.6__py3-none-any.whl → 0.3.7__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.
- smart_bot_factory/core/bot_utils.py +14 -0
- smart_bot_factory/core/decorators.py +32 -6
- smart_bot_factory/handlers/handlers.py +16 -4
- {smart_bot_factory-0.3.6.dist-info → smart_bot_factory-0.3.7.dist-info}/METADATA +1 -1
- {smart_bot_factory-0.3.6.dist-info → smart_bot_factory-0.3.7.dist-info}/RECORD +8 -8
- {smart_bot_factory-0.3.6.dist-info → smart_bot_factory-0.3.7.dist-info}/WHEEL +0 -0
- {smart_bot_factory-0.3.6.dist-info → smart_bot_factory-0.3.7.dist-info}/entry_points.txt +0 -0
- {smart_bot_factory-0.3.6.dist-info → smart_bot_factory-0.3.7.dist-info}/licenses/LICENSE +0 -0
|
@@ -255,6 +255,10 @@ async def process_events(session_id: str, events: list, user_id: int) -> bool:
|
|
|
255
255
|
# if session_id:
|
|
256
256
|
# check_query = check_query.eq('session_id', session_id)
|
|
257
257
|
|
|
258
|
+
# 🆕 Фильтруем по bot_id если указан
|
|
259
|
+
if supabase_client.bot_id:
|
|
260
|
+
check_query = check_query.eq('bot_id', supabase_client.bot_id)
|
|
261
|
+
|
|
258
262
|
existing = check_query.execute()
|
|
259
263
|
|
|
260
264
|
logger.info(f" 🔍 Проверка БД: найдено {len(existing.data) if existing.data else 0} выполненных событий '{event_type}' для user_id={user_id}")
|
|
@@ -291,6 +295,11 @@ async def process_events(session_id: str, events: list, user_id: int) -> bool:
|
|
|
291
295
|
'result_data': __import__('json').dumps(result, ensure_ascii=False) if result else None,
|
|
292
296
|
'info_dashboard': info_dashboard_json # Добавится только если есть поле 'info'
|
|
293
297
|
}
|
|
298
|
+
|
|
299
|
+
# 🆕 Добавляем bot_id если указан
|
|
300
|
+
if supabase_client.bot_id:
|
|
301
|
+
event_record['bot_id'] = supabase_client.bot_id
|
|
302
|
+
|
|
294
303
|
response = supabase_client.client.table('scheduled_events').insert(event_record).execute()
|
|
295
304
|
event_id = response.data[0]['id']
|
|
296
305
|
|
|
@@ -311,6 +320,11 @@ async def process_events(session_id: str, events: list, user_id: int) -> bool:
|
|
|
311
320
|
'session_id': session_id,
|
|
312
321
|
'last_error': str(e)
|
|
313
322
|
}
|
|
323
|
+
|
|
324
|
+
# 🆕 Добавляем bot_id если указан
|
|
325
|
+
if supabase_client.bot_id:
|
|
326
|
+
event_record['bot_id'] = supabase_client.bot_id
|
|
327
|
+
|
|
314
328
|
supabase_client.client.table('scheduled_events').insert(event_record).execute()
|
|
315
329
|
raise
|
|
316
330
|
|
|
@@ -1135,6 +1135,10 @@ async def save_immediate_event(
|
|
|
1135
1135
|
'session_id': session_id
|
|
1136
1136
|
}
|
|
1137
1137
|
|
|
1138
|
+
# 🆕 Добавляем bot_id если указан
|
|
1139
|
+
if supabase_client.bot_id:
|
|
1140
|
+
event_record['bot_id'] = supabase_client.bot_id
|
|
1141
|
+
|
|
1138
1142
|
try:
|
|
1139
1143
|
response = supabase_client.client.table('scheduled_events').insert(event_record).execute()
|
|
1140
1144
|
event_id = response.data[0]['id']
|
|
@@ -1187,6 +1191,10 @@ async def save_scheduled_task(
|
|
|
1187
1191
|
'session_id': session_id
|
|
1188
1192
|
}
|
|
1189
1193
|
|
|
1194
|
+
# 🆕 Добавляем bot_id если указан
|
|
1195
|
+
if supabase_client.bot_id:
|
|
1196
|
+
event_record['bot_id'] = supabase_client.bot_id
|
|
1197
|
+
|
|
1190
1198
|
try:
|
|
1191
1199
|
response = supabase_client.client.table('scheduled_events').insert(event_record).execute()
|
|
1192
1200
|
event_id = response.data[0]['id']
|
|
@@ -1241,6 +1249,10 @@ async def save_global_event(
|
|
|
1241
1249
|
'status': status
|
|
1242
1250
|
}
|
|
1243
1251
|
|
|
1252
|
+
# 🆕 Добавляем bot_id если указан (глобальные события тоже привязаны к боту)
|
|
1253
|
+
if supabase_client.bot_id:
|
|
1254
|
+
event_record['bot_id'] = supabase_client.bot_id
|
|
1255
|
+
|
|
1244
1256
|
try:
|
|
1245
1257
|
response = supabase_client.client.table('scheduled_events').insert(event_record).execute()
|
|
1246
1258
|
event_id = response.data[0]['id']
|
|
@@ -1303,13 +1315,18 @@ async def get_pending_events(limit: int = 50) -> list:
|
|
|
1303
1315
|
try:
|
|
1304
1316
|
now = datetime.now(timezone.utc).isoformat()
|
|
1305
1317
|
|
|
1306
|
-
|
|
1318
|
+
query = supabase_client.client.table('scheduled_events')\
|
|
1307
1319
|
.select('*')\
|
|
1308
1320
|
.in_('status', ['pending', 'immediate'])\
|
|
1309
1321
|
.or_(f'scheduled_at.is.null,scheduled_at.lte.{now}')\
|
|
1310
1322
|
.order('created_at')\
|
|
1311
|
-
.limit(limit)
|
|
1312
|
-
|
|
1323
|
+
.limit(limit)
|
|
1324
|
+
|
|
1325
|
+
# 🆕 Фильтруем по bot_id если указан
|
|
1326
|
+
if supabase_client.bot_id:
|
|
1327
|
+
query = query.eq('bot_id', supabase_client.bot_id)
|
|
1328
|
+
|
|
1329
|
+
response = query.execute()
|
|
1313
1330
|
|
|
1314
1331
|
return response.data
|
|
1315
1332
|
except Exception as e:
|
|
@@ -1328,13 +1345,18 @@ async def get_pending_events_in_next_minute(limit: int = 100) -> list:
|
|
|
1328
1345
|
now = datetime.now(timezone.utc)
|
|
1329
1346
|
next_minute = now + timedelta(seconds=60)
|
|
1330
1347
|
|
|
1331
|
-
|
|
1348
|
+
query = supabase_client.client.table('scheduled_events')\
|
|
1332
1349
|
.select('*')\
|
|
1333
1350
|
.in_('status', ['pending', 'immediate'])\
|
|
1334
1351
|
.or_(f'scheduled_at.is.null,scheduled_at.lte.{next_minute.isoformat()}')\
|
|
1335
1352
|
.order('created_at')\
|
|
1336
|
-
.limit(limit)
|
|
1337
|
-
|
|
1353
|
+
.limit(limit)
|
|
1354
|
+
|
|
1355
|
+
# 🆕 Фильтруем по bot_id если указан
|
|
1356
|
+
if supabase_client.bot_id:
|
|
1357
|
+
query = query.eq('bot_id', supabase_client.bot_id)
|
|
1358
|
+
|
|
1359
|
+
response = query.execute()
|
|
1338
1360
|
|
|
1339
1361
|
return response.data
|
|
1340
1362
|
except Exception as e:
|
|
@@ -1705,6 +1727,10 @@ async def check_event_already_processed(event_type: str, user_id: int = None, se
|
|
|
1705
1727
|
if session_id:
|
|
1706
1728
|
query = query.eq('session_id', session_id)
|
|
1707
1729
|
|
|
1730
|
+
# 🆕 Фильтруем по bot_id если указан
|
|
1731
|
+
if supabase_client.bot_id:
|
|
1732
|
+
query = query.eq('bot_id', supabase_client.bot_id)
|
|
1733
|
+
|
|
1708
1734
|
response = query.execute()
|
|
1709
1735
|
|
|
1710
1736
|
if response.data:
|
|
@@ -77,14 +77,26 @@ async def timeup_handler(message: Message, state: FSMContext):
|
|
|
77
77
|
|
|
78
78
|
# Получаем события для этого пользователя И глобальные события (user_id = null)
|
|
79
79
|
# 1. События пользователя
|
|
80
|
-
|
|
80
|
+
user_events_query = supabase_client.client.table('scheduled_events').select(
|
|
81
81
|
'*'
|
|
82
|
-
).eq('user_id', message.from_user.id).in_('status', ['pending', 'immediate'])
|
|
82
|
+
).eq('user_id', message.from_user.id).in_('status', ['pending', 'immediate'])
|
|
83
|
+
|
|
84
|
+
# 🆕 Фильтруем по bot_id если указан
|
|
85
|
+
if supabase_client.bot_id:
|
|
86
|
+
user_events_query = user_events_query.eq('bot_id', supabase_client.bot_id)
|
|
87
|
+
|
|
88
|
+
user_events = user_events_query.execute()
|
|
83
89
|
|
|
84
90
|
# 2. Глобальные события (без user_id)
|
|
85
|
-
|
|
91
|
+
global_events_query = supabase_client.client.table('scheduled_events').select(
|
|
86
92
|
'*'
|
|
87
|
-
).is_('user_id', 'null').in_('status', ['pending', 'immediate'])
|
|
93
|
+
).is_('user_id', 'null').in_('status', ['pending', 'immediate'])
|
|
94
|
+
|
|
95
|
+
# 🆕 Фильтруем по bot_id если указан
|
|
96
|
+
if supabase_client.bot_id:
|
|
97
|
+
global_events_query = global_events_query.eq('bot_id', supabase_client.bot_id)
|
|
98
|
+
|
|
99
|
+
global_events = global_events_query.execute()
|
|
88
100
|
|
|
89
101
|
# Объединяем события
|
|
90
102
|
all_events = (user_events.data or []) + (global_events.data or [])
|
|
@@ -29,9 +29,9 @@ smart_bot_factory/configs/growthmed-october-24/tests/realistic_scenarios.yaml,sh
|
|
|
29
29
|
smart_bot_factory/configs/growthmed-october-24/tests/scenario_examples.yaml,sha256=bzDulOU4a2LyWlcHzlQU8GYhOky2WTfyizGfjX4ioMY,2436
|
|
30
30
|
smart_bot_factory/configs/growthmed-october-24/welcome_file/welcome_file_msg.txt,sha256=Db21Mm0r8SBWFdX9EeIF2FZtLQ2cvuwVlSRJd2KEYCg,922
|
|
31
31
|
smart_bot_factory/configs/growthmed-october-24/welcome_file/Чек лист по 152ФЗ и 323ФЗ для медицины.pdf,sha256=BiAiQHNnQXJPMsks9AeL6s0beEjRFkRMJLMlAn4WorA,5284954
|
|
32
|
-
smart_bot_factory/core/bot_utils.py,sha256=
|
|
32
|
+
smart_bot_factory/core/bot_utils.py,sha256=vblk94k8cXvc-3iS3UOZvnU2NtXXKYgt3vzkioca-ac,48395
|
|
33
33
|
smart_bot_factory/core/conversation_manager.py,sha256=eoHL7MCEz68DRvTVwRwZgf2PWwGv4T6J9D-I-thETi8,28289
|
|
34
|
-
smart_bot_factory/core/decorators.py,sha256=
|
|
34
|
+
smart_bot_factory/core/decorators.py,sha256=mYWiN9B0lrgV3uRAaFVkJTCKWZyTpVNM_AneuQcqifA,99872
|
|
35
35
|
smart_bot_factory/core/message_sender.py,sha256=0-SQcK4W1x__VgvyaeVRuFlXcxV56TsR_nNK07Nr4b4,32763
|
|
36
36
|
smart_bot_factory/core/router.py,sha256=ji7rzpuKaO8yKaxFW58WhlgG5ExXlbCgqCTONxAyqL4,15022
|
|
37
37
|
smart_bot_factory/core/router_manager.py,sha256=dUwesog-oHk1U2EDdS8p0e4MTSkwtx5_qXn6nrJ9l9I,9700
|
|
@@ -41,7 +41,7 @@ smart_bot_factory/creation/bot_builder.py,sha256=yGRmOPD7qCMbhcBiltHWISoKxWx8eqj
|
|
|
41
41
|
smart_bot_factory/creation/bot_testing.py,sha256=JDWXyJfZmbgo-DLdAPk8Sd9FiehtHHa4sLD17lBrTOc,55669
|
|
42
42
|
smart_bot_factory/dashboard/__init__.py,sha256=bDBOWQbcAL1Bmz4KVFouAKg8FN-c6EsC_-YthTt_mP4,100
|
|
43
43
|
smart_bot_factory/event/__init__.py,sha256=hPL449RULIOB-OXv1ZbGNiHctAYaOMUqhSWGPrDHYBM,212
|
|
44
|
-
smart_bot_factory/handlers/handlers.py,sha256=
|
|
44
|
+
smart_bot_factory/handlers/handlers.py,sha256=haxyVvFuyMWvfGCOiAvXPrez96bchoHnwQEEURMqiMI,62409
|
|
45
45
|
smart_bot_factory/integrations/openai_client.py,sha256=fwaJpwojFdLBWChcFWpFGOHK9upG-nCIwDochkCRRlY,24291
|
|
46
46
|
smart_bot_factory/integrations/supabase_client.py,sha256=XV1_caDAADnXLwCM7CkUdGfUNBNHBHYz-HBPSYmdGv4,63653
|
|
47
47
|
smart_bot_factory/message/__init__.py,sha256=-ehDZweUc3uKgmLLxFVsD-KWrDtnHpHms7pCrDelWo0,1950
|
|
@@ -52,8 +52,8 @@ smart_bot_factory/utils/__init__.py,sha256=UhsJXEHfrIK8h1AHsroHSwAriijk-LvnqLyvg
|
|
|
52
52
|
smart_bot_factory/utils/debug_routing.py,sha256=BOoDhKBg7UXe5uHQxRk3TSfPfLPOFqt0N7lAo6kjCOo,4719
|
|
53
53
|
smart_bot_factory/utils/prompt_loader.py,sha256=HS_6Vf-qvRBkhvyzu-HNVS1swFgmqWOKNNv0F6We_AQ,20060
|
|
54
54
|
smart_bot_factory/utils/user_prompt_loader.py,sha256=dk6P0X_3UcNqxjRtuIvb0LcPrp03zIIsstZwdmeCPaE,2519
|
|
55
|
-
smart_bot_factory-0.3.
|
|
56
|
-
smart_bot_factory-0.3.
|
|
57
|
-
smart_bot_factory-0.3.
|
|
58
|
-
smart_bot_factory-0.3.
|
|
59
|
-
smart_bot_factory-0.3.
|
|
55
|
+
smart_bot_factory-0.3.7.dist-info/METADATA,sha256=cfOUXXewYMK7EomidcIP78W_yjjCnWHtmQ7efPx8FMA,40662
|
|
56
|
+
smart_bot_factory-0.3.7.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
57
|
+
smart_bot_factory-0.3.7.dist-info/entry_points.txt,sha256=ybKEAI0WSb7WoRiey7QE-HHfn88UGV7nxLDxXq7b7SU,50
|
|
58
|
+
smart_bot_factory-0.3.7.dist-info/licenses/LICENSE,sha256=OrK3cwdUTzNzIhJvSPtJaVMoYIyC_sSx5EFE_FDMvGs,1092
|
|
59
|
+
smart_bot_factory-0.3.7.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|