88
99
1010current_projects = {}
11- NOMBRE , DIFICULTAD , TOPIC = ["nombre" , "dificultad" , "topic" ]
11+ NOMBRE , DIFICULTAD , TOPIC , PARTICIPANTS = ["nombre" , "dificultad" , "topic" , "participantes " ]
1212
1313logger = logging .getLogger (__name__ )
1414
@@ -230,7 +230,7 @@ async def delete_project(update, context):
230230
231231
232232async def show_projects (update , context ):
233- """Prevent people for keep uploading projects"""
233+ """Show available projects"""
234234 projects = Project .select ()
235235 text = []
236236 for project in projects :
@@ -254,6 +254,38 @@ async def show_projects(update, context):
254254 await update .message .reply_text (text )
255255
256256
257+ async def show_participants (update , context ):
258+ """Show participants for a project"""
259+
260+ if len (update .message .text .split ()) < 2 :
261+ await context .bot .send_message (
262+ chat_id = update .message .chat_id ,
263+ text = "No se indico el nombre del proyecto. Modo de uso: '/participantes <NOMBRE_PROYECTO>'"
264+ )
265+ return
266+ project_name = update .message .text .split ()[1 ]
267+ project = Project .select ().where (Project .name == project_name )
268+ if not project :
269+ await context .bot .send_message (
270+ chat_id = update .message .chat_id ,
271+ text = "No se encontro el proyecto."
272+ )
273+ return
274+
275+ votes = Vote .select ().where (
276+ (Vote .project == project ) & (Vote .interest ))
277+ participants = set ()
278+ for vote in votes :
279+ participants .add (vote .pycampista .username )
280+
281+ response = f"Participantes:\n "
282+ for participant in participants :
283+ response = response + f"{ participant } \n "
284+
285+ await update .message .reply_text (response )
286+
287+
288+
257289def set_handlers (application ):
258290 application .add_handler (load_project_handler )
259291 application .add_handler (
@@ -264,3 +296,5 @@ def set_handlers(application):
264296 CommandHandler ('borrar_proyecto' , delete_project ))
265297 application .add_handler (
266298 CommandHandler ('proyectos' , show_projects ))
299+ application .add_handler (
300+ CommandHandler ('participantes' , show_participants ))
0 commit comments