Skip to content

Commit

Permalink
Merge pull request #71 from lusegomez/ticket-69
Browse files Browse the repository at this point in the history
Ticket 69
  • Loading branch information
WinnaZ authored Jun 22, 2024
2 parents 01c1c7e + 49393b7 commit b751f69
Showing 1 changed file with 36 additions and 2 deletions.
38 changes: 36 additions & 2 deletions src/pycamp_bot/commands/projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ async def delete_project(update, context):


async def show_projects(update, context):
"""Prevent people for keep uploading projects"""
"""Show available projects"""
projects = Project.select()
text = []
for project in projects:
Expand All @@ -256,6 +256,39 @@ async def show_projects(update, context):
await update.message.reply_text(text)



async def show_participants(update, context):
"""Show participants for a project"""

if len(update.message.text.split()) < 2:
await context.bot.send_message(
chat_id=update.message.chat_id,
text="No se indico el nombre del proyecto. Modo de uso: '/participantes <NOMBRE_PROYECTO>'"
)
return
project_name = update.message.text.split()[1]
project = Project.select().where(Project.name == project_name)
if not project:
await context.bot.send_message(
chat_id=update.message.chat_id,
text="No se encontro el proyecto."
)
return

votes = Vote.select().where(
(Vote.project == project) & (Vote.interest))
participants = set()
for vote in votes:
participants.add(vote.pycampista.username)

response = f"Participantes:\n"
for participant in participants:
response = response + f"{participant} \n"

await update.message.reply_text(response)


=======
async def show_my_projects(update, context):
"""Let people see what projects they have voted for"""

Expand Down Expand Up @@ -302,7 +335,6 @@ async def show_my_projects(update, context):

await update.message.reply_text(text, parse_mode='MarkdownV2')


def set_handlers(application):
application.add_handler(load_project_handler)
application.add_handler(
Expand All @@ -313,6 +345,8 @@ def set_handlers(application):
CommandHandler('borrar_proyecto', delete_project))
application.add_handler(
CommandHandler('proyectos', show_projects))
application.add_handler(
CommandHandler('participantes', show_participants))
application.add_handler(
CommandHandler('mis_proyectos', show_my_projects))

0 comments on commit b751f69

Please sign in to comment.