Skip to content

Commit b751f69

Browse files
authored
Merge pull request #71 from lusegomez/ticket-69
Ticket 69
2 parents 01c1c7e + 49393b7 commit b751f69

File tree

1 file changed

+36
-2
lines changed

1 file changed

+36
-2
lines changed

src/pycamp_bot/commands/projects.py

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ async def delete_project(update, context):
232232

233233

234234
async 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+
=======
259292
async 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-
306338
def 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

Comments
 (0)