mirror of
https://github.com/marcogll/talia_bot.git
synced 2026-01-13 13:25:19 +00:00
Merge pull request #3 from marcogll/feat/initial-project-structure-5769203822268670178
Feat/initial project structure 5769203822268670178
This commit is contained in:
53
app/main.py
53
app/main.py
@@ -1,10 +1,53 @@
|
||||
# app/main.py
|
||||
import logging
|
||||
from telegram import Update
|
||||
from telegram.ext import Application, CommandHandler, CallbackQueryHandler, ContextTypes
|
||||
|
||||
def main():
|
||||
"""
|
||||
Main function to run the bot.
|
||||
"""
|
||||
print("Talía Bot is running...")
|
||||
from config import TELEGRAM_BOT_TOKEN
|
||||
from permissions import get_user_role
|
||||
from modules.onboarding import handle_start as onboarding_handle_start
|
||||
|
||||
# Enable logging
|
||||
logging.basicConfig(
|
||||
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", level=logging.INFO
|
||||
)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
async def start(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
"""Sends a welcome message and menu when the /start command is issued."""
|
||||
chat_id = update.effective_chat.id
|
||||
user_role = get_user_role(chat_id)
|
||||
|
||||
logger.info(f"User {chat_id} started conversation with role: {user_role}")
|
||||
|
||||
# Delegate to the onboarding module
|
||||
response_text, reply_markup = onboarding_handle_start(user_role)
|
||||
|
||||
await update.message.reply_text(response_text, reply_markup=reply_markup)
|
||||
|
||||
async def button(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||
"""Parses the CallbackQuery and updates the message text."""
|
||||
query = update.callback_query
|
||||
await query.answer()
|
||||
# TODO: Implement handlers for the different callback queries
|
||||
await query.edit_message_text(text=f"Selected option: {query.data}")
|
||||
|
||||
def main() -> None:
|
||||
"""Start the bot."""
|
||||
if not TELEGRAM_BOT_TOKEN:
|
||||
logger.error("TELEGRAM_BOT_TOKEN is not set in the environment variables.")
|
||||
return
|
||||
|
||||
# Create the Application and pass it your bot's token.
|
||||
application = Application.builder().token(TELEGRAM_BOT_TOKEN).build()
|
||||
|
||||
# Add command handlers
|
||||
application.add_handler(CommandHandler("start", start))
|
||||
application.add_handler(CallbackQueryHandler(button))
|
||||
|
||||
# Run the bot until the user presses Ctrl-C
|
||||
logger.info("Starting Talía Bot...")
|
||||
application.run_polling()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
@@ -1,9 +1,42 @@
|
||||
# app/modules/onboarding.py
|
||||
from telegram import InlineKeyboardButton, InlineKeyboardMarkup
|
||||
|
||||
def handle_start(chat_id):
|
||||
def get_owner_menu():
|
||||
"""Returns the main menu for the owner."""
|
||||
keyboard = [
|
||||
[InlineKeyboardButton("📅 Ver mi agenda", callback_data='view_agenda')],
|
||||
[InlineKeyboardButton("⏳ Ver pendientes", callback_data='view_pending')],
|
||||
[InlineKeyboardButton("✅ Aprobar solicitud", callback_data='approve_request')],
|
||||
]
|
||||
return InlineKeyboardMarkup(keyboard)
|
||||
|
||||
def get_team_menu():
|
||||
"""Returns the main menu for a team member."""
|
||||
keyboard = [
|
||||
[InlineKeyboardButton("🕒 Proponer actividad", callback_data='propose_activity')],
|
||||
[InlineKeyboardButton("📄 Ver estatus de solicitudes", callback_data='view_requests_status')],
|
||||
]
|
||||
return InlineKeyboardMarkup(keyboard)
|
||||
|
||||
def get_client_menu():
|
||||
"""Returns the main menu for a client."""
|
||||
keyboard = [
|
||||
[InlineKeyboardButton("🗓️ Agendar una cita", callback_data='schedule_appointment')],
|
||||
[InlineKeyboardButton("ℹ️ Información de servicios", callback_data='get_service_info')],
|
||||
]
|
||||
return InlineKeyboardMarkup(keyboard)
|
||||
|
||||
def handle_start(user_role):
|
||||
"""
|
||||
Handles the /start command and sends a welcome message.
|
||||
Handles the /start command and sends a role-based welcome message and menu.
|
||||
"""
|
||||
print(f"[{chat_id}] Handling start command...")
|
||||
# TODO: Implement welcome message and main menu
|
||||
return "Welcome to Talía!"
|
||||
welcome_message = "Hola, soy Talía. ¿En qué puedo ayudarte hoy?"
|
||||
|
||||
if user_role == "owner":
|
||||
menu = get_owner_menu()
|
||||
elif user_role in ["admin", "team"]:
|
||||
menu = get_team_menu()
|
||||
else: # client
|
||||
menu = get_client_menu()
|
||||
|
||||
return welcome_message, menu
|
||||
|
||||
11
tasks.md
11
tasks.md
@@ -12,14 +12,14 @@ This file tracks the development tasks for the Talía project.
|
||||
|
||||
## Phase 2: Core Logic Implementation
|
||||
|
||||
- [ ] Implement `main.py` as the central orchestrator.
|
||||
- [ ] Implement `config.py` to handle environment variables.
|
||||
- [ ] Implement `permissions.py` for role-based access control.
|
||||
- [ ] Implement `webhook_client.py` for n8n communication.
|
||||
- [x] Implement `main.py` as the central orchestrator.
|
||||
- [x] Implement `config.py` to handle environment variables.
|
||||
- [x] Implement `permissions.py` for role-based access control.
|
||||
- [x] Implement `webhook_client.py` for n8n communication.
|
||||
|
||||
## Phase 3: Module Implementation
|
||||
|
||||
- [ ] Implement `onboarding.py` module.
|
||||
- [x] Implement `onboarding.py` module.
|
||||
- [ ] Implement `agenda.py` module.
|
||||
- [ ] Implement `citas.py` module.
|
||||
- [ ] Implement `equipo.py` module.
|
||||
@@ -39,3 +39,4 @@ This file tracks the development tasks for the Talía project.
|
||||
|
||||
- Created `tasks.md` to begin tracking development.
|
||||
- Completed initial project scaffolding.
|
||||
- Implemented the core logic for the bot, including the central orchestrator, permissions, and onboarding.
|
||||
|
||||
Reference in New Issue
Block a user