@@ -232,7 +232,7 @@ async def delete_project(update, context):
232232
233233
234234async def show_projects (update , context ):
235- """Prevent people for keep uploading projects"""
235+ """Show available projects"""
236236 projects = Project .select ()
237237 text = []
238238 for project in projects :
@@ -256,6 +256,39 @@ async def show_projects(update, context):
256256 await update .message .reply_text (text )
257257
258258
259+
260+ async def show_participants (update , context ):
261+ """Show participants for a project"""
262+
263+ if len (update .message .text .split ()) < 2 :
264+ await context .bot .send_message (
265+ chat_id = update .message .chat_id ,
266+ text = "No se indico el nombre del proyecto. Modo de uso: '/participantes <NOMBRE_PROYECTO>'"
267+ )
268+ return
269+ project_name = update .message .text .split ()[1 ]
270+ project = Project .select ().where (Project .name == project_name )
271+ if not project :
272+ await context .bot .send_message (
273+ chat_id = update .message .chat_id ,
274+ text = "No se encontro el proyecto."
275+ )
276+ return
277+
278+ votes = Vote .select ().where (
279+ (Vote .project == project ) & (Vote .interest ))
280+ participants = set ()
281+ for vote in votes :
282+ participants .add (vote .pycampista .username )
283+
284+ response = f"Participantes:\n "
285+ for participant in participants :
286+ response = response + f"{ participant } \n "
287+
288+ await update .message .reply_text (response )
289+
290+
291+ == == == =
259292async def show_my_projects (update , context ):
260293 """Let people see what projects they have voted for"""
261294
@@ -302,7 +335,6 @@ async def show_my_projects(update, context):
302335
303336 await update .message .reply_text (text , parse_mode = 'MarkdownV2' )
304337
305-
306338def set_handlers (application ):
307339 application .add_handler (load_project_handler )
308340 application .add_handler (
@@ -313,6 +345,8 @@ def set_handlers(application):
313345 CommandHandler ('borrar_proyecto' , delete_project ))
314346 application .add_handler (
315347 CommandHandler ('proyectos' , show_projects ))
348+ application .add_handler (
349+ CommandHandler ('participantes' , show_participants ))
316350 application .add_handler (
317351 CommandHandler ('mis_proyectos' , show_my_projects ))
318352
0 commit comments