@@ -38,11 +38,8 @@ async def should_be_able_to_announce(pycampista: str, proyect: Project) -> bool:
3838async def announce (update : Update , context : CallbackContext ) -> str :
3939 logger .info ("Announcement project process started" )
4040 parameters : list [str ] = update .message .text .split ()
41+ project_name = ("" ).join (parameters [1 :])
4142
42- if len (parameters ) > 2 :
43- await handle_error (context , update .message .chat_id , "format_error" )
44- logger .warning ("Error de formato en la solicitud. Too many parameters" )
45- return ConversationHandler .END
4643 state .username = update .message .from_user .username
4744 state .projects = Project .select ().join (Pycampista ).where (Pycampista .username == state .username )
4845
@@ -72,9 +69,10 @@ async def announce(update: Update, context: CallbackContext) -> str:
7269 text = f"""Ingresá el Nombre del Proyecto a anunciar.\n \n Tienes los siguientes proyectos:\n { project_list } """ ,
7370 )
7471
75- if len (parameters ) == 2 :
72+ if len (parameters ) > 2 :
7673 print ('-Handle correct commands-' )
77- state .p_name = update .message .text .split ()[1 ].lower ()
74+ project_name = (" " ).join (parameters [1 :])
75+ state .p_name = project_name
7876 _projects = Project .select ().join (Pycampista ).where (Project .name == state .p_name )
7977
8078 if len (_projects ) == 0 :
@@ -108,13 +106,10 @@ async def get_project(update: Update, context: CallbackContext) -> str:
108106 logger .info ("Getting project" )
109107 parameters_list : list [str ] = update .message .text .split ()
110108
111- if len (parameters_list ) > 2 :
112- await handle_error (context , update .message .chat_id , "format_error" )
113- return ConversationHandler .END
114-
115109 if "/anunciar" in parameters_list :
116- if len (parameters_list ) == 2 :
117- state .current_project = Project .select ().join (Pycampista ).where (Project .name == parameters_list [1 ].lower ())
110+ if len (parameters_list ) > 2 :
111+ project_name = " " .join (parameters_list [1 :])
112+ state .current_project = Project .select ().join (Pycampista ).where (Project .name == project_name .lower ())
118113 if not await should_be_able_to_announce (update .message .from_user .username , state .current_project [0 ]):
119114 await handle_error (context , update .message .chat_id , "format_error" , state .current_project )
120115 logger .warning (f"Project { parameters_list [1 ]} not found!" )
@@ -133,14 +128,9 @@ async def get_project(update: Update, context: CallbackContext) -> str:
133128 )
134129 return PROYECTO
135130
136- elif len (parameters_list ) == 2 :
137- await handle_error (context , update .message .chat_id , "format_error" )
138- logger .warning ("Error de formato en la solicitud. Too many parameters" )
139- return PROYECTO
140-
141131 else :
142- c_proyect = Project . select (). where ( Project . name == parameters_list [ 0 ]. lower ()). first ( )
143- print ( ' c_proyect: ' , c_proyect )
132+ project_name = ( " " ). join ( parameters_list )
133+ c_proyect = Project . select (). where ( Project . name == project_name ). first ( )
144134 if c_proyect :
145135 if await should_be_able_to_announce (update .message .from_user .username , c_proyect ):
146136 state .current_project = c_proyect
@@ -164,7 +154,7 @@ async def get_project(update: Update, context: CallbackContext) -> str:
164154 context ,
165155 update .message .chat_id ,
166156 "not_found" ,
167- project_name = parameters_list [ 0 ]
157+ project_name = project_name
168158 )
169159 logger .warning ("Error de formato en la solicitud. No se encontró el proyecto." )
170160 return PROYECTO
@@ -236,7 +226,6 @@ async def handle_error(context: CallbackContext, chat_id: int, error_key: str, *
236226 await context .bot .send_message (
237227 chat_id = chat_id ,
238228 text = error_message ,
239- #parse_mode='Markdown'
240229 )
241230 except Exception as e :
242231 logger .error (f"Error al enviar el mensaje: { e } " )
0 commit comments