mirror of
https://github.com/marcogll/talia_bot.git
synced 2026-01-14 04:55:19 +00:00
feat: Complete major refactoring and add initial test suite
This commit addresses a large number of pending tasks from `Tasks.md`, focusing on architectural improvements, documentation consistency, and the introduction of a testing framework. Key changes include: - **Button Dispatcher Agent (`[IMP-003]`):** Refactored the button handling logic into a dedicated `ButtonDispatcher` class. This decouples the dispatcher from handlers and improves modularity. - **Documentation Consistency (`[DOC-001]`):** Updated `AGENTS.md` and `Agent_skills.md` to be consistent with the current codebase, removing outdated information and "Fallo Actual" notes. - **Code Quality Tools (`[TEST-002]`):** Added `black` to the project for consistent code formatting and applied it to the entire `bot/` directory. - **Initial Test Coverage (`[TEST-001]`):** Created a `tests/` directory and implemented a comprehensive suite of unit tests for the critical `FlowEngine` module, using Python's `unittest` framework. - **Task Verification:** Investigated and confirmed that tasks `[ARCH-003]` (Code Duplication), `[PERF-003]` (Flow Engine Memory Usage), and `[PERF-002]` (Voice File Memory Management) were already resolved by previous refactoring. - **Updated `Tasks.md`:** Updated the status of all addressed tasks to reflect the project's current state.
This commit is contained in:
@@ -39,8 +39,13 @@ def get_user_role(telegram_id):
|
||||
Roles: 'admin', 'crew', 'client'.
|
||||
"""
|
||||
# El admin principal se define en el .env para el primer arranque
|
||||
if str(telegram_id) == ADMIN_ID:
|
||||
return 'admin'
|
||||
# Se convierten ambos a int para una comparación segura de tipos.
|
||||
try:
|
||||
if int(telegram_id) == int(ADMIN_ID):
|
||||
return 'admin'
|
||||
except (ValueError, TypeError):
|
||||
logger.warning("ADMIN_ID no es un número válido. Ignorando la comparación.")
|
||||
pass
|
||||
|
||||
try:
|
||||
conn = get_db_connection()
|
||||
|
||||
Reference in New Issue
Block a user