smart-bot-factory 0.1.0__tar.gz → 0.1.2__tar.gz
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-0.1.2/PKG-INFO +31 -0
- smart_bot_factory-0.1.2/__init__.py +53 -0
- smart_bot_factory-0.1.2/admin/__init__.py +16 -0
- {smart_bot_factory-0.1.0 → smart_bot_factory-0.1.2/admin}/admin_logic.py +35 -13
- smart_bot_factory-0.1.2/admin/admin_tester.py +151 -0
- smart_bot_factory-0.1.2/admin/timeout_checker.py +499 -0
- smart_bot_factory-0.1.2/analytics/__init__.py +7 -0
- {smart_bot_factory-0.1.0 → smart_bot_factory-0.1.2/analytics}/analytics_manager.py +355 -359
- {smart_bot_factory-0.1.0/src/smart_bot_factory → smart_bot_factory-0.1.2}/cli.py +75 -57
- {smart_bot_factory-0.1.0 → smart_bot_factory-0.1.2}/config.py +2 -2
- smart_bot_factory-0.1.2/core/__init__.py +22 -0
- {smart_bot_factory-0.1.0 → smart_bot_factory-0.1.2/core}/bot_utils.py +28 -1
- {smart_bot_factory-0.1.0/src/smart_bot_factory/events → smart_bot_factory-0.1.2/core}/decorators.py +229 -229
- {smart_bot_factory-0.1.0/src/smart_bot_factory/services → smart_bot_factory-0.1.2/core}/message_sender.py +30 -16
- smart_bot_factory-0.1.2/core/states.py +14 -0
- smart_bot_factory-0.1.2/creation/__init__.py +8 -0
- {smart_bot_factory-0.1.0/src/smart_bot_factory/core → smart_bot_factory-0.1.2/creation}/bot_builder.py +329 -337
- {smart_bot_factory-0.1.0 → smart_bot_factory-0.1.2/creation}/bot_testing.py +157 -83
- {smart_bot_factory-0.1.0 → smart_bot_factory-0.1.2/handlers}/handlers.py +10 -19
- smart_bot_factory-0.1.2/integrations/__init__.py +8 -0
- {smart_bot_factory-0.1.0 → smart_bot_factory-0.1.2}/pyproject.toml +8 -5
- smart_bot_factory-0.1.2/setup_checker.py +476 -0
- smart_bot_factory-0.1.2/utils/__init__.py +9 -0
- {smart_bot_factory-0.1.0 → smart_bot_factory-0.1.2/utils}/debug_routing.py +8 -0
- {smart_bot_factory-0.1.0 → smart_bot_factory-0.1.2/utils}/prompt_loader.py +14 -9
- {smart_bot_factory-0.1.0 → smart_bot_factory-0.1.2}/uv.lock +453 -25
- smart_bot_factory-0.1.0/.github/ISSUE_TEMPLATE//342/234/250-/320/267/320/260/320/277/321/200/320/276/321/201-/321/204/321/203/320/275/320/272/321/206/320/270/320/270.md +0 -20
- smart_bot_factory-0.1.0/.github/ISSUE_TEMPLATE//360/237/220/233-/320/261/320/260/320/263-/321/200/320/265/320/277/320/276/321/200/321/202.md +0 -26
- smart_bot_factory-0.1.0/.github/workflows/ci.yml +0 -59
- smart_bot_factory-0.1.0/.github/workflows/publish-private.yml +0 -34
- smart_bot_factory-0.1.0/.github/workflows/publish.yml +0 -31
- smart_bot_factory-0.1.0/.python-version +0 -1
- smart_bot_factory-0.1.0/CLI_README.md +0 -170
- smart_bot_factory-0.1.0/Dockerfile +0 -36
- smart_bot_factory-0.1.0/LICENSE +0 -21
- smart_bot_factory-0.1.0/PKG-INFO +0 -125
- smart_bot_factory-0.1.0/README.md +0 -93
- smart_bot_factory-0.1.0/README_SMART_BOT_FACTORY.md +0 -216
- smart_bot_factory-0.1.0/admin_test.py +0 -490
- smart_bot_factory-0.1.0/check_timeouts.py +0 -306
- smart_bot_factory-0.1.0/configs/growthmed-october-24/tests/challenging_scenarios.yaml +0 -108
- smart_bot_factory-0.1.0/configs/growthmed-october-24/tests/final_scenarios.yaml +0 -80
- smart_bot_factory-0.1.0/configs/growthmed-october-24/tests/fixes_elina.yaml +0 -14
- smart_bot_factory-0.1.0/configs/test-bot/env_example.txt +0 -1
- smart_bot_factory-0.1.0/configs/test-bot/prompts/1sales_context.txt +0 -9
- smart_bot_factory-0.1.0/configs/test-bot/prompts/2product_info.txt +0 -582
- smart_bot_factory-0.1.0/configs/test-bot/prompts/3objection_handling.txt +0 -66
- smart_bot_factory-0.1.0/configs/test-bot/prompts/final_instructions.txt +0 -232
- smart_bot_factory-0.1.0/configs/test-bot/prompts/help_message.txt +0 -28
- smart_bot_factory-0.1.0/configs/test-bot/prompts/welcome_message.txt +0 -7
- smart_bot_factory-0.1.0/configs/test-bot/welcome_file/welcome_file_msg.txt +0 -16
- smart_bot_factory-0.1.0/configs/test-bot/welcome_file//320/247/320/265/320/272 /320/273/320/270/321/201/321/202 /320/277/320/276 152/320/244/320/227 /320/270 323/320/244/320/227 /320/264/320/273/321/217 /320/274/320/265/320/264/320/270/321/206/320/270/320/275/321/213.pdf +0 -0
- smart_bot_factory-0.1.0/configs/valera/files//320/265/321/211/320/265_/320/272/320/276/321/202.jpg +0 -0
- smart_bot_factory-0.1.0/configs/valera/prompts/1sales_context.txt +0 -9
- smart_bot_factory-0.1.0/configs/valera/prompts/2product_info.txt +0 -582
- smart_bot_factory-0.1.0/configs/valera/prompts/3objection_handling.txt +0 -66
- smart_bot_factory-0.1.0/configs/valera/prompts/final_instructions.txt +0 -216
- smart_bot_factory-0.1.0/configs/valera/prompts/help_message.txt +0 -28
- smart_bot_factory-0.1.0/configs/valera/prompts/welcome_message.txt +0 -9
- smart_bot_factory-0.1.0/configs/valera/tests/challenging_scenarios.yaml +0 -108
- smart_bot_factory-0.1.0/configs/valera/tests/final_scenarios.yaml +0 -168
- smart_bot_factory-0.1.0/configs/valera/welcome_file/welcome_file_msg.txt +0 -12
- smart_bot_factory-0.1.0/configs/valera/welcome_file//320/247/320/265/320/272-/320/273/320/270/321/201/321/202 /320/264/320/273/321/217 /320/274/320/265/320/264/320/270/321/206/320/270/320/275/321/213.pdf +0 -0
- smart_bot_factory-0.1.0/configs/valera//321/201/320/272/320/270/320/264/320/272/320/270/mixkit-pet-owner-playing-with-a-cute-cat-1779-hd-ready.mp4 +0 -0
- smart_bot_factory-0.1.0/configs/valera//321/201/320/272/320/270/320/264/320/272/320/270//320/277/320/276/320/272/320/260.pdf +0 -0
- smart_bot_factory-0.1.0/configs/valera//321/201/320/272/320/270/320/264/320/272/320/270//320/277/321/200/320/270/320/262/320/265/321/202.pdf +0 -0
- smart_bot_factory-0.1.0/create_bot.py +0 -294
- smart_bot_factory-0.1.0/create_tag.sh +0 -143
- smart_bot_factory-0.1.0/debug_timeout.py +0 -244
- smart_bot_factory-0.1.0/docker-compose.yml +0 -18
- smart_bot_factory-0.1.0/env.example +0 -40
- smart_bot_factory-0.1.0/growthmed-helper.py +0 -65
- smart_bot_factory-0.1.0/growthmed-october-24.py +0 -65
- smart_bot_factory-0.1.0/launcher.py +0 -37
- smart_bot_factory-0.1.0/main.py +0 -120
- smart_bot_factory-0.1.0/new-bot.py +0 -78
- smart_bot_factory-0.1.0/quick_json_test.py +0 -234
- smart_bot_factory-0.1.0/requirements.txt +0 -8
- smart_bot_factory-0.1.0/save_backup.sh +0 -3
- smart_bot_factory-0.1.0/save_fixes.sh +0 -3
- smart_bot_factory-0.1.0/setup_check.py +0 -506
- smart_bot_factory-0.1.0/src/smart_bot_factory/__init__.py +0 -30
- smart_bot_factory-0.1.0/src/smart_bot_factory/core/__init__.py +0 -7
- smart_bot_factory-0.1.0/src/smart_bot_factory/events/__init__.py +0 -27
- smart_bot_factory-0.1.0/src/smart_bot_factory/integrations/__init__.py +0 -83
- smart_bot_factory-0.1.0/src/smart_bot_factory/integrations/bot_utils_integration.py +0 -224
- smart_bot_factory-0.1.0/src/smart_bot_factory/services/__init__.py +0 -12
- smart_bot_factory-0.1.0/src/smart_bot_factory/services/telegram_integration.py +0 -246
- smart_bot_factory-0.1.0/src/smart_bot_factory/tools/__init__.py +0 -19
- smart_bot_factory-0.1.0/src/smart_bot_factory/tools/decorators.py +0 -140
- smart_bot_factory-0.1.0/system_prompt_example.txt +0 -84
- smart_bot_factory-0.1.0/test-bot.py +0 -65
- smart_bot_factory-0.1.0/utm_link_generator.py +0 -106
- smart_bot_factory-0.1.0/valera-new.py +0 -65
- smart_bot_factory-0.1.0/valera.py +0 -65
- {smart_bot_factory-0.1.0 → smart_bot_factory-0.1.2}/.gitignore +0 -0
- {smart_bot_factory-0.1.0 → smart_bot_factory-0.1.2/admin}/admin_manager.py +0 -0
- {smart_bot_factory-0.1.0 → smart_bot_factory-0.1.2/admin}/admin_migration.sql +0 -0
- {smart_bot_factory-0.1.0 → smart_bot_factory-0.1.2}/configs/growthmed-helper/env_example.txt +0 -0
- {smart_bot_factory-0.1.0 → smart_bot_factory-0.1.2}/configs/growthmed-helper/prompts/1sales_context.txt +0 -0
- {smart_bot_factory-0.1.0 → smart_bot_factory-0.1.2}/configs/growthmed-helper/prompts/2product_info.txt +0 -0
- {smart_bot_factory-0.1.0 → smart_bot_factory-0.1.2}/configs/growthmed-helper/prompts/3objection_handling.txt +0 -0
- {smart_bot_factory-0.1.0 → smart_bot_factory-0.1.2}/configs/growthmed-helper/prompts/final_instructions.txt +0 -0
- {smart_bot_factory-0.1.0 → smart_bot_factory-0.1.2}/configs/growthmed-helper/prompts/help_message.txt +0 -0
- {smart_bot_factory-0.1.0 → smart_bot_factory-0.1.2}/configs/growthmed-helper/prompts/welcome_message.txt +0 -0
- {smart_bot_factory-0.1.0 → smart_bot_factory-0.1.2}/configs/growthmed-helper/welcome_file/welcome_file_msg.txt +0 -0
- {smart_bot_factory-0.1.0 → smart_bot_factory-0.1.2}/configs/growthmed-helper/welcome_file//320/247/320/265/320/272 /320/273/320/270/321/201/321/202 /320/277/320/276 152/320/244/320/227 /320/270 323/320/244/320/227 /320/264/320/273/321/217 /320/274/320/265/320/264/320/270/321/206/320/270/320/275/321/213.pdf" +0 -0
- {smart_bot_factory-0.1.0 → smart_bot_factory-0.1.2}/configs/growthmed-october-24/prompts/1sales_context.txt +0 -0
- {smart_bot_factory-0.1.0 → smart_bot_factory-0.1.2}/configs/growthmed-october-24/prompts/2product_info.txt +0 -0
- {smart_bot_factory-0.1.0 → smart_bot_factory-0.1.2}/configs/growthmed-october-24/prompts/3objection_handling.txt +0 -0
- {smart_bot_factory-0.1.0 → smart_bot_factory-0.1.2}/configs/growthmed-october-24/prompts/final_instructions.txt +0 -0
- {smart_bot_factory-0.1.0 → smart_bot_factory-0.1.2}/configs/growthmed-october-24/prompts/help_message.txt +0 -0
- {smart_bot_factory-0.1.0 → smart_bot_factory-0.1.2}/configs/growthmed-october-24/prompts/welcome_message.txt +0 -0
- {smart_bot_factory-0.1.0 → smart_bot_factory-0.1.2}/configs/growthmed-october-24/tests/quick_scenarios.yaml +0 -0
- {smart_bot_factory-0.1.0 → smart_bot_factory-0.1.2}/configs/growthmed-october-24/tests/realistic_scenarios.yaml +0 -0
- {smart_bot_factory-0.1.0 → smart_bot_factory-0.1.2}/configs/growthmed-october-24/tests/scenario_examples.yaml +0 -0
- {smart_bot_factory-0.1.0 → smart_bot_factory-0.1.2}/configs/growthmed-october-24/welcome_file/welcome_file_msg.txt +0 -0
- {smart_bot_factory-0.1.0 → smart_bot_factory-0.1.2}/configs/growthmed-october-24/welcome_file//320/247/320/265/320/272 /320/273/320/270/321/201/321/202 /320/277/320/276 152/320/244/320/227 /320/270 323/320/244/320/227 /320/264/320/273/321/217 /320/274/320/265/320/264/320/270/321/206/320/270/320/275/321/213.pdf" +0 -0
- {smart_bot_factory-0.1.0 → smart_bot_factory-0.1.2/core}/conversation_manager.py +0 -0
- {smart_bot_factory-0.1.0 → smart_bot_factory-0.1.2/database}/database_structure.sql +0 -0
- {smart_bot_factory-0.1.0 → smart_bot_factory-0.1.2/database}/schema.sql +0 -0
- {smart_bot_factory-0.1.0 → smart_bot_factory-0.1.2/integrations}/openai_client.py +0 -0
- {smart_bot_factory-0.1.0 → smart_bot_factory-0.1.2/integrations}/supabase_client.py +0 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: smart-bot-factory
|
|
3
|
+
Version: 0.1.2
|
|
4
|
+
Summary: Библиотека для создания умных чат-ботов
|
|
5
|
+
Author-email: Kopatych <kopatych@example.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Keywords: chatbot,cli,openai,supabase,telegram
|
|
8
|
+
Classifier: Development Status :: 4 - Beta
|
|
9
|
+
Classifier: Environment :: Console
|
|
10
|
+
Classifier: Framework :: AsyncIO
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Topic :: Communications :: Chat
|
|
20
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
21
|
+
Requires-Python: >=3.9
|
|
22
|
+
Requires-Dist: aiofiles>=23.0.0
|
|
23
|
+
Requires-Dist: aiogram>=3.4.1
|
|
24
|
+
Requires-Dist: click>=8.0.0
|
|
25
|
+
Requires-Dist: openai>=1.12.0
|
|
26
|
+
Requires-Dist: project-root-finder>=1.9
|
|
27
|
+
Requires-Dist: python-dotenv>=1.0.1
|
|
28
|
+
Requires-Dist: pytz>=2023.3
|
|
29
|
+
Requires-Dist: pyyaml>=6.0.2
|
|
30
|
+
Requires-Dist: supabase>=2.3.4
|
|
31
|
+
Requires-Dist: twine>=6.2.0
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Smart Bot Factory - библиотека для создания умных чат-ботов
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from .creation.bot_builder import BotBuilder
|
|
6
|
+
from .core.decorators import event_handler, schedule_task
|
|
7
|
+
from .core.message_sender import send_message_by_ai, send_message_by_human
|
|
8
|
+
from .config import Config
|
|
9
|
+
from .integrations.openai_client import OpenAIClient
|
|
10
|
+
from .integrations.supabase_client import SupabaseClient
|
|
11
|
+
from .core.conversation_manager import ConversationManager
|
|
12
|
+
from .admin.admin_manager import AdminManager
|
|
13
|
+
from .utils.prompt_loader import PromptLoader
|
|
14
|
+
from .handlers.handlers import setup_handlers
|
|
15
|
+
from .admin.admin_logic import setup_admin_handlers
|
|
16
|
+
from .core.bot_utils import setup_utils_handlers, parse_ai_response, process_events
|
|
17
|
+
from .utils.debug_routing import setup_debug_handlers
|
|
18
|
+
from .core.states import UserStates, AdminStates
|
|
19
|
+
from .creation.bot_testing import main as bot_testing_main
|
|
20
|
+
from .analytics.analytics_manager import AnalyticsManager
|
|
21
|
+
from .admin.timeout_checker import check_timeouts, setup_bot_environment
|
|
22
|
+
from .setup_checker import check_setup
|
|
23
|
+
from .admin.admin_tester import test_admin_system
|
|
24
|
+
from .cli import cli
|
|
25
|
+
|
|
26
|
+
__all__ = [
|
|
27
|
+
'BotBuilder',
|
|
28
|
+
'event_handler',
|
|
29
|
+
'schedule_task',
|
|
30
|
+
'send_message_by_ai',
|
|
31
|
+
'send_message_by_human',
|
|
32
|
+
'Config',
|
|
33
|
+
'OpenAIClient',
|
|
34
|
+
'SupabaseClient',
|
|
35
|
+
'ConversationManager',
|
|
36
|
+
'AdminManager',
|
|
37
|
+
'PromptLoader',
|
|
38
|
+
'setup_handlers',
|
|
39
|
+
'setup_admin_handlers',
|
|
40
|
+
'setup_utils_handlers',
|
|
41
|
+
'parse_ai_response',
|
|
42
|
+
'process_events',
|
|
43
|
+
'setup_debug_handlers',
|
|
44
|
+
'UserStates',
|
|
45
|
+
'AdminStates',
|
|
46
|
+
'bot_testing_main',
|
|
47
|
+
'AnalyticsManager',
|
|
48
|
+
'check_timeouts',
|
|
49
|
+
'setup_bot_environment',
|
|
50
|
+
'check_setup',
|
|
51
|
+
'test_admin_system',
|
|
52
|
+
'cli'
|
|
53
|
+
]
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Admin модули smart_bot_factory
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from .admin_logic import setup_admin_handlers
|
|
6
|
+
from .admin_manager import AdminManager
|
|
7
|
+
from .admin_tester import test_admin_system
|
|
8
|
+
from .timeout_checker import check_timeouts, setup_bot_environment
|
|
9
|
+
|
|
10
|
+
__all__ = [
|
|
11
|
+
'setup_admin_handlers',
|
|
12
|
+
'AdminManager',
|
|
13
|
+
'test_admin_system',
|
|
14
|
+
'check_timeouts',
|
|
15
|
+
'setup_bot_environment'
|
|
16
|
+
]
|
|
@@ -10,8 +10,8 @@ from aiogram.types import Message, CallbackQuery, InlineKeyboardMarkup, InlineKe
|
|
|
10
10
|
|
|
11
11
|
logger = logging.getLogger(__name__)
|
|
12
12
|
|
|
13
|
-
# Импортируем состояния
|
|
14
|
-
from
|
|
13
|
+
# Импортируем состояния
|
|
14
|
+
from ..core.states import UserStates, AdminStates
|
|
15
15
|
|
|
16
16
|
# Создаем роутер для админских обработчиков
|
|
17
17
|
admin_router = Router()
|
|
@@ -22,7 +22,8 @@ def setup_admin_handlers(dp):
|
|
|
22
22
|
|
|
23
23
|
async def admin_start_handler(message: Message, state: FSMContext):
|
|
24
24
|
"""Обработчик /start для админов в режиме администратора"""
|
|
25
|
-
from
|
|
25
|
+
from handlers import get_global_var
|
|
26
|
+
admin_manager = get_global_var('admin_manager')
|
|
26
27
|
|
|
27
28
|
await state.set_state(AdminStates.admin_mode)
|
|
28
29
|
|
|
@@ -54,7 +55,9 @@ async def admin_start_handler(message: Message, state: FSMContext):
|
|
|
54
55
|
@admin_router.message(Command("стат"))
|
|
55
56
|
async def admin_stats_handler(message: Message, state: FSMContext):
|
|
56
57
|
"""Статистика воронки"""
|
|
57
|
-
from
|
|
58
|
+
from handlers import get_global_var
|
|
59
|
+
admin_manager = get_global_var('admin_manager')
|
|
60
|
+
analytics_manager = get_global_var('analytics_manager')
|
|
58
61
|
|
|
59
62
|
if not admin_manager.is_admin(message.from_user.id):
|
|
60
63
|
return
|
|
@@ -79,7 +82,9 @@ async def admin_stats_handler(message: Message, state: FSMContext):
|
|
|
79
82
|
@admin_router.message(Command("история"))
|
|
80
83
|
async def admin_history_handler(message: Message, state: FSMContext):
|
|
81
84
|
"""История пользователя"""
|
|
82
|
-
from
|
|
85
|
+
from handlers import get_global_var
|
|
86
|
+
admin_manager = get_global_var('admin_manager')
|
|
87
|
+
analytics_manager = get_global_var('analytics_manager')
|
|
83
88
|
|
|
84
89
|
if not admin_manager.is_admin(message.from_user.id):
|
|
85
90
|
return
|
|
@@ -113,7 +118,11 @@ async def admin_history_handler(message: Message, state: FSMContext):
|
|
|
113
118
|
@admin_router.message(Command("чат"))
|
|
114
119
|
async def admin_chat_handler(message: Message, state: FSMContext):
|
|
115
120
|
"""Начать диалог с пользователем"""
|
|
116
|
-
from
|
|
121
|
+
from handlers import get_global_var
|
|
122
|
+
|
|
123
|
+
admin_manager = get_global_var('admin_manager')
|
|
124
|
+
supabase_client = get_global_var('supabase_client')
|
|
125
|
+
conversation_manager = get_global_var('conversation_manager')
|
|
117
126
|
|
|
118
127
|
if not admin_manager.is_admin(message.from_user.id):
|
|
119
128
|
return
|
|
@@ -164,7 +173,9 @@ async def admin_chat_handler(message: Message, state: FSMContext):
|
|
|
164
173
|
@admin_router.message(Command("чаты"))
|
|
165
174
|
async def admin_active_chats_command(message: Message, state: FSMContext):
|
|
166
175
|
"""Показать активные диалоги админов"""
|
|
167
|
-
from
|
|
176
|
+
from handlers import get_global_var
|
|
177
|
+
admin_manager = get_global_var('admin_manager')
|
|
178
|
+
conversation_manager = get_global_var('conversation_manager')
|
|
168
179
|
|
|
169
180
|
if not admin_manager.is_admin(message.from_user.id):
|
|
170
181
|
return
|
|
@@ -183,7 +194,9 @@ async def admin_active_chats_command(message: Message, state: FSMContext):
|
|
|
183
194
|
@admin_router.message(Command("стоп"))
|
|
184
195
|
async def admin_stop_handler(message: Message, state: FSMContext):
|
|
185
196
|
"""Завершить диалог"""
|
|
186
|
-
from
|
|
197
|
+
from handlers import get_global_var
|
|
198
|
+
admin_manager = get_global_var('admin_manager')
|
|
199
|
+
conversation_manager = get_global_var('conversation_manager')
|
|
187
200
|
|
|
188
201
|
if not admin_manager.is_admin(message.from_user.id):
|
|
189
202
|
return
|
|
@@ -220,8 +233,9 @@ async def admin_stop_handler(message: Message, state: FSMContext):
|
|
|
220
233
|
@admin_router.message(Command("админ"))
|
|
221
234
|
async def admin_toggle_handler(message: Message, state: FSMContext):
|
|
222
235
|
"""Переключение режима админа"""
|
|
223
|
-
from
|
|
224
|
-
|
|
236
|
+
from handlers import get_global_var
|
|
237
|
+
admin_manager = get_global_var('admin_manager')
|
|
238
|
+
from .handlers import user_start_handler
|
|
225
239
|
|
|
226
240
|
if not admin_manager.is_admin(message.from_user.id):
|
|
227
241
|
return
|
|
@@ -239,7 +253,10 @@ async def admin_toggle_handler(message: Message, state: FSMContext):
|
|
|
239
253
|
@admin_router.message(Command("debug_chat"))
|
|
240
254
|
async def debug_chat_handler(message: Message, state: FSMContext):
|
|
241
255
|
"""Отладка диалогов админов"""
|
|
242
|
-
from
|
|
256
|
+
from handlers import get_global_var
|
|
257
|
+
admin_manager = get_global_var('admin_manager')
|
|
258
|
+
conversation_manager = get_global_var('conversation_manager')
|
|
259
|
+
supabase_client = get_global_var('supabase_client')
|
|
243
260
|
|
|
244
261
|
if not admin_manager.is_admin(message.from_user.id):
|
|
245
262
|
return
|
|
@@ -287,7 +304,10 @@ async def debug_chat_handler(message: Message, state: FSMContext):
|
|
|
287
304
|
@admin_router.callback_query(F.data.startswith("admin_"))
|
|
288
305
|
async def admin_callback_handler(callback: CallbackQuery, state: FSMContext):
|
|
289
306
|
"""Обработчик callback кнопок админов"""
|
|
290
|
-
from
|
|
307
|
+
from handlers import get_global_var
|
|
308
|
+
admin_manager = get_global_var('admin_manager')
|
|
309
|
+
analytics_manager = get_global_var('analytics_manager')
|
|
310
|
+
conversation_manager = get_global_var('conversation_manager')
|
|
291
311
|
|
|
292
312
|
if not admin_manager.is_admin(callback.from_user.id):
|
|
293
313
|
await callback.answer("Нет доступа")
|
|
@@ -374,7 +394,9 @@ async def admin_callback_handler(callback: CallbackQuery, state: FSMContext):
|
|
|
374
394
|
@admin_router.message(StateFilter(AdminStates.admin_mode, AdminStates.in_conversation))
|
|
375
395
|
async def admin_message_handler(message: Message, state: FSMContext):
|
|
376
396
|
"""Обработчик сообщений админов"""
|
|
377
|
-
from
|
|
397
|
+
from handlers import get_global_var
|
|
398
|
+
admin_manager = get_global_var('admin_manager')
|
|
399
|
+
conversation_manager = get_global_var('conversation_manager')
|
|
378
400
|
|
|
379
401
|
if not admin_manager.is_admin(message.from_user.id):
|
|
380
402
|
return
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Утилита для тестирования системы администрирования бота
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import asyncio
|
|
6
|
+
import logging
|
|
7
|
+
import json
|
|
8
|
+
import re
|
|
9
|
+
import sys
|
|
10
|
+
import os
|
|
11
|
+
|
|
12
|
+
from ..config import Config
|
|
13
|
+
from ..integrations.supabase_client import SupabaseClient
|
|
14
|
+
from .admin_manager import AdminManager
|
|
15
|
+
from ..core.conversation_manager import ConversationManager
|
|
16
|
+
from ..analytics.analytics_manager import AnalyticsManager
|
|
17
|
+
from .timeout_checker import setup_bot_environment
|
|
18
|
+
|
|
19
|
+
logger = logging.getLogger(__name__)
|
|
20
|
+
|
|
21
|
+
async def test_admin_system(bot_name: str = "growthmed-october-24") -> bool:
|
|
22
|
+
"""
|
|
23
|
+
Тестирует систему администрирования бота
|
|
24
|
+
|
|
25
|
+
Args:
|
|
26
|
+
bot_name: Имя бота для тестирования
|
|
27
|
+
|
|
28
|
+
Returns:
|
|
29
|
+
bool: True если все тесты пройдены, False если найдены проблемы
|
|
30
|
+
"""
|
|
31
|
+
logger.info(f"🚀 Тестирование системы администрирования: {bot_name}")
|
|
32
|
+
logger.info(f"🤖 Bot ID будет автоопределен как: {bot_name}\n")
|
|
33
|
+
|
|
34
|
+
# Настраиваем окружение для бота (автоматически устанавливает BOT_ID)
|
|
35
|
+
config_dir = setup_bot_environment(bot_name)
|
|
36
|
+
if not config_dir:
|
|
37
|
+
return False
|
|
38
|
+
|
|
39
|
+
# Инициализируем конфигурацию
|
|
40
|
+
config = Config()
|
|
41
|
+
logger.info(f"📋 Конфигурация:")
|
|
42
|
+
logger.info(f" BOT_ID: {config.BOT_ID}")
|
|
43
|
+
logger.info(f" ADMIN_SESSION_TIMEOUT_MINUTES: {config.ADMIN_SESSION_TIMEOUT_MINUTES}")
|
|
44
|
+
logger.info(f" PROMT_FILES_DIR: {config.PROMT_FILES_DIR}")
|
|
45
|
+
logger.info(f" Найдено промпт-файлов: {len(config.PROMPT_FILES)}")
|
|
46
|
+
logger.info("")
|
|
47
|
+
|
|
48
|
+
# Проверяем админов
|
|
49
|
+
if not config.ADMIN_TELEGRAM_IDS:
|
|
50
|
+
logger.warning("⚠️ Админы не настроены (ADMIN_TELEGRAM_IDS пуст)")
|
|
51
|
+
return False
|
|
52
|
+
|
|
53
|
+
logger.info(f"👑 Админы: {config.ADMIN_TELEGRAM_IDS}")
|
|
54
|
+
logger.info("")
|
|
55
|
+
|
|
56
|
+
# Проверяем подключение к БД
|
|
57
|
+
try:
|
|
58
|
+
supabase_client = SupabaseClient(config.SUPABASE_URL, config.SUPABASE_KEY)
|
|
59
|
+
await supabase_client.initialize()
|
|
60
|
+
logger.info("✅ Подключение к Supabase успешно")
|
|
61
|
+
|
|
62
|
+
# Проверяем таблицы
|
|
63
|
+
tables = [
|
|
64
|
+
'sales_admins',
|
|
65
|
+
'admin_user_conversations',
|
|
66
|
+
'session_events',
|
|
67
|
+
'sales_chat_sessions',
|
|
68
|
+
'sales_messages'
|
|
69
|
+
]
|
|
70
|
+
|
|
71
|
+
logger.info("\n📊 Проверка таблиц:")
|
|
72
|
+
for table in tables:
|
|
73
|
+
try:
|
|
74
|
+
response = supabase_client.client.table(table).select('*').limit(1).execute()
|
|
75
|
+
logger.info(f" ✅ {table}")
|
|
76
|
+
except Exception as e:
|
|
77
|
+
logger.error(f" ❌ {table}: {e}")
|
|
78
|
+
return False
|
|
79
|
+
|
|
80
|
+
# Проверяем AdminManager
|
|
81
|
+
admin_manager = AdminManager(config, supabase_client)
|
|
82
|
+
logger.info(f"\n👑 AdminManager инициализирован ({len(admin_manager.admin_ids)} админов)")
|
|
83
|
+
|
|
84
|
+
# Проверяем ConversationManager
|
|
85
|
+
conversation_manager = ConversationManager(supabase_client, admin_manager)
|
|
86
|
+
logger.info("✅ ConversationManager инициализирован")
|
|
87
|
+
|
|
88
|
+
# Проверяем AnalyticsManager
|
|
89
|
+
analytics_manager = AnalyticsManager(supabase_client)
|
|
90
|
+
|
|
91
|
+
# Тестируем получение статистики
|
|
92
|
+
funnel_stats = await analytics_manager.get_funnel_stats(1)
|
|
93
|
+
logger.info("✅ AnalyticsManager работает")
|
|
94
|
+
|
|
95
|
+
# Проверяем активные диалоги
|
|
96
|
+
conversations = await conversation_manager.get_active_conversations()
|
|
97
|
+
logger.info(f"\n💬 Активные диалоги: {len(conversations)}")
|
|
98
|
+
|
|
99
|
+
if conversations:
|
|
100
|
+
for conv in conversations:
|
|
101
|
+
logger.info(f" • Диалог {conv['id']}: админ {conv['admin_id']} с пользователем {conv['user_id']}")
|
|
102
|
+
else:
|
|
103
|
+
logger.info(" Нет активных диалогов")
|
|
104
|
+
logger.info(" 💡 Создайте диалог командой /чат USER_ID для тестирования")
|
|
105
|
+
|
|
106
|
+
# Проверяем форматирование диалогов
|
|
107
|
+
if conversations:
|
|
108
|
+
formatted = conversation_manager.format_active_conversations(conversations)
|
|
109
|
+
logger.info("\n📝 Форматирование диалогов:")
|
|
110
|
+
logger.info(formatted)
|
|
111
|
+
|
|
112
|
+
logger.info("\n✅ Админская система готова к работе")
|
|
113
|
+
return True
|
|
114
|
+
|
|
115
|
+
except Exception as e:
|
|
116
|
+
logger.error(f"❌ Ошибка тестирования: {e}")
|
|
117
|
+
logger.exception("Стек ошибки:")
|
|
118
|
+
return False
|
|
119
|
+
|
|
120
|
+
def main():
|
|
121
|
+
"""Точка входа для запуска из командной строки"""
|
|
122
|
+
# Настройка логирования
|
|
123
|
+
logging.basicConfig(level=logging.INFO, format='%(message)s')
|
|
124
|
+
|
|
125
|
+
logger.info("🔍 Утилита тестирования админской системы")
|
|
126
|
+
logger.info("Использование:")
|
|
127
|
+
logger.info(" python -m smart_bot_factory.admin_tester [bot_name]")
|
|
128
|
+
logger.info(" python -m smart_bot_factory.admin_tester growthmed-october-24")
|
|
129
|
+
logger.info("")
|
|
130
|
+
|
|
131
|
+
if len(sys.argv) > 1 and sys.argv[1] in ['-h', '--help', 'help']:
|
|
132
|
+
return
|
|
133
|
+
|
|
134
|
+
# Определяем какого бота тестировать
|
|
135
|
+
bot_name = "growthmed-october-24" # по умолчанию
|
|
136
|
+
if len(sys.argv) > 1:
|
|
137
|
+
bot_name = sys.argv[1]
|
|
138
|
+
|
|
139
|
+
try:
|
|
140
|
+
success = asyncio.run(test_admin_system(bot_name))
|
|
141
|
+
if not success:
|
|
142
|
+
sys.exit(1)
|
|
143
|
+
except KeyboardInterrupt:
|
|
144
|
+
logger.info("\n⏹️ Прервано пользователем")
|
|
145
|
+
except Exception as e:
|
|
146
|
+
logger.error(f"\n💥 Критическая ошибка: {e}")
|
|
147
|
+
logger.exception("Стек ошибки:")
|
|
148
|
+
sys.exit(1)
|
|
149
|
+
|
|
150
|
+
if __name__ == "__main__":
|
|
151
|
+
main()
|